Run
button on demand.
Error: Failed to load http://wzrd.in/standalone/sanctuary@latest
Promise.resolve(10).then(x => console.log(x));
Promise { <pending> }
var fn = function(){ return Array.from(arguments) }
R.unapply(R.identity)
Array.from
just spread const fn => (...args) => args.map(x => x * 10)
const update = todo => {
//:: String -> Either a b
id = toObjectId(todo._id);
//->_Right { value: '580a86e0ccb07e6a515f1244' }
return new Future((reject, resolve) => {
collection.updateOne({_id: id}, {$set:{done: todo.done}})
.then(data => resolve(data))
.catch(err => reject(err));
});
};
//getId:: todo -> Either e ObjectId
const getId = compose(toObjectId, prop('_id'));
//updateTodo :: ObjectId -> Todo -> Future e mongoResult
const updateTodo = futurize((_id, todo) => collection.updateOne({_id}, {$set:{done: todo.done}})
const update = (todo) => map(updateTodo(__, todo), getId(todo))
Obviously that could all be cleaned up.
Either e (Future e MongoResult)
toObjectId
return a Future instead of an Either (after all, they share the same basic shape)
chain
to flatten it
const updateOne = curry((coll, query, updates) => Future((rej, res) => coll.updateOne(query, updates).then(res, rej)));