input collection
collection indicating which group an element in the input collection belongs to
results
var arr = [ 'beep', 'boop', 'foo', 'bar' ];
var filter = [ true, true, false, true ];
var out = bifurcate( arr, filter );
// returns [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ]
Splits values into two groups.
filter
is truthy, then the corresponding element in the input collection belongs to the first group; otherwise, the collection element belongs to the second group.input collection
function options
collection indicating which group an element in the input collection belongs to
results
var arr = [ 'beep', 'boop', 'foo', 'bar' ];
var filter = [ true, true, false, true ];
var opts = {
'returns': 'indices'
};
var out = bifurcate( arr, opts, filter );
// returns [ [ 0, 1, 3 ], [ 2 ] ]
var arr = [ 'beep', 'boop', 'foo', 'bar' ];
var filter = [ true, true, false, true ];
var opts = {
'returns': '*'
};
var out = bifurcate( arr, opts, filter );
// returns [ [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], [ [ 2, 'foo' ] ] ]
Splits values into two groups.
Notes
filter
is truthy, then the corresponding element in the input collection belongs to the first group; otherwise, the collection element belongs to the second group.first and last arguments must be the same length