Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kjirou/npm-callback-end

By wrapping the function that sets the last callback, so that you can omit the argument when calling
https://github.com/kjirou/npm-callback-end

Last synced: 14 days ago
JSON representation

By wrapping the function that sets the last callback, so that you can omit the argument when calling

Awesome Lists containing this project

README

        

callback-end [![Build Status](https://travis-ci.org/kjirou/npm-callback-end.svg?branch=master)](https://travis-ci.org/kjirou/npm-callback-end)
============

By wrapping the function that sets the last callback, so that you can omit the argument when calling.

## Installation
```
npm install callback-end
```

## Examples
```
var callbackEnd = require('callback-end');

var func = function(foo, bar, cb){
return Array.prototype.slice.apply(arguments);
};

var wrapped = callbackEnd(func);

console.log(
wrapped(1, 2, function(){}) // -> [1, 2, function(){}]
);

// Omit a "bar" arg
console.log(
wrapped(1, function(){}) // -> [1, undefined, function(){}]
);

// Omit "foo" and "bar" args
console.log(
wrapped(function(){}) // -> [undefined, undefined, function(){}]
);
```