Skip to content

unspread

Subhajit Sahu edited this page Jul 29, 2022 · 2 revisions

Generate a (first) parameter-collapsed version of a function.

Similar: spread, unspread.


function unspread(x)
// x: a function
const xfunction = require('extra-function');


var fn = xfunction.unspread(Math.min);
fn([7, 4, 9]);  // Math.min(7, 4, 9)
// → 4

var fn = xfunction.unspread((x, i, I) => x.slice(i, I));
fn([[1, 2, 3, 4], 2]);  // [1, 2, 3, 4].slice(2)
// → [3, 4]


References

Clone this wiki locally