Skip to content

Instantly share code, notes, and snippets.

@ianfabs
Created March 5, 2019 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianfabs/48584d32d302e093d7d86dae5d60e703 to your computer and use it in GitHub Desktop.
Save ianfabs/48584d32d302e093d7d86dae5d60e703 to your computer and use it in GitHub Desktop.
A collection of lovely one-liners that I use
// A sleep implementation in javascript
const sleep = t => new Promise(r=>setTimeout(r,t));
// A function that rearranges an object returned by mongoose to play nicely with graphql resolvers
const objectify = o => (o.isArray()?o.map(e=>objectify(e)):({...o.toObject(),_id:o._id.toString()}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment