Skip to content

lexich/extract-args

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About extract-args

Smart extract arguments from javascript function with default params and callback in the end

Build Status NPM version Coverage Status

import extractArgs from "extract-args";
import _ from "lodash";

function test(...args) {
  const [a, b, cb] = extractArgs(args, [1, 2]);
  a === _.isUndefined(args[0]) ? 1 : args[1]; // true
  b === _.isUndefined(args[1]) ? 2 : args[2]; // true
  _.isFunction(cb); // true independ of args[2]
}

About

Smart extract arguments from javascript function with default params and callback in the end

Resources

License

Stars

Watchers

Forks

Packages

No packages published