Sha256: b5198dc9dcf0a51dbe7fdef1393d917e871994ae08c192d7de8f1960f6a6aee2
Contents?: true
Size: 564 Bytes
Versions: 28
Compression:
Stored size: 564 Bytes
Contents
'use strict'; /** * Syntactic sugar for invoking a function and expanding an array for arguments. * * Common use case would be to use `Function.prototype.apply`. * * ```js * function f(x, y, z) {} * var args = [1, 2, 3]; * f.apply(null, args); * ``` * * With `spread` this example can be re-written. * * ```js * spread(function(x, y, z) {})([1, 2, 3]); * ``` * * @param {Function} callback * @returns {Function} */ module.exports = function spread(callback) { return function wrap(arr) { return callback.apply(null, arr); }; };
Version data entries
28 entries across 16 versions & 5 rubygems