Skip to content

Instantly share code, notes, and snippets.

@raine
Last active August 29, 2015 14:11
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 raine/18436cc3aecab990b62d to your computer and use it in GitHub Desktop.
Save raine/18436cc3aecab990b62d to your computer and use it in GitHub Desktop.
Promise.all(map(API.userByName, users))
  .tap(function(users) {
    req.log.info({ users: users });
  })
Promise.all(map(API.userByName, users))
  .tap(compose( req.log.info, createMapEntry('users') ))

// no go -- [TypeError: Object.keys called on non-object]
Promise.all(map(API.userByName, users))
  .tap(compose( req.log.info.bind(req.log.info), createMapEntry('users') ))

// works but imo on the same level on ugly scale as the first one 
Promise.all(map(API.userByName, users))
  .tap(users => req.log.info({ users }))

// probably prefer this most but requires transpiler
@buzzdecafe
Copy link

would this work:

Promise.all(map(API.userByName, users))
  .tap(compose( R.bind(req.log.info, req.log), createMapEntry('users') ))

?

not much of an improvement, really 😺

@buzzdecafe
Copy link

@CrossEye recommends:

var logInfo = R.bind(req.log.info, req.log);
Promise.all(map(API.userByName, users))
  .tap(compose(logInfo, createMapEntry('users') ))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment