Skip to content

m59peacemaker/js-find-callback

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Find Callback

Finds and returns a node-style callback (function that is the last argument) from given array or returns undefined if not found.

Install

npm install find-callback

Usage

var findCb = require('find-callback')

function foo(arg1, optionalArg, cb) {
  cb = findCb(arguments)
  //etc
  someAsyncFn(function() {
    //etc
    cb() // may be arguments[1] if the `optionalArg` was not used
  })
}

foo('some arg', function() {
  //etc
})

Parameters

array

Type: Array or arguments object

The array to search for a node-style callback. The last item in the array will be returned if it is a function.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published