Skip to content
/ but Public

🛰 But expands your functional horizons to the edge of the universe

License

Notifications You must be signed in to change notification settings

bevacqua/but

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

but Build Status

But expands your functional horizons to the edge of the universe

If only there was a way to pass along a callback with just a single argument.

You know how you like chaining asynchronous function calls but sometimes weird arguments get in the way of your waterfall series with unpredictable arguments?

How about attempting to parseInt in a map only to find out map spews three arguments?

NO MORE!

npm install but --save

Usage

Functional arguments giving you headaches?

Before
n.map(function (val) {
  return parseInt(val);
});
After
n.map(but(parseInt));

Works on .forEach or any functional array method as well! Classy.

Before
n.forEach(function (val) {
  console.log(val);
});
After
n.forEach(but(console.log.bind(console))); // you can omit bind on node.js

Mongoose being weird?

Before
async.waterfall([
  function (next) {
    new User(model).save(function (err) {
      next(err);
    });
  },
  function (next) {
    // MOAR CODE
  }
])
After
async.waterfall([
  function (next) {
    new User(model).save(but(next));
  },
  function (next) {
    // MOAR CODE
  }
])

Why?

It had to be done. It is known.

License

MIT

About

🛰 But expands your functional horizons to the edge of the universe

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published