Returns a boolean indicating which group an object's own and inherited property values belongs to.
Returns a boolean indicating which group an object's own and inherited property values belongs to.
Returns a boolean indicating which group an object's own and inherited property values belongs to.
Splits an object's own and inherited property values into two groups according to a predicate function.
When invoked, the predicate function is provided two arguments:
value
: object valuekey
: object keyIf a predicate function returns a truthy value, a value is placed in the first group; otherwise, a value is placed in the second group.
If provided an empty object with no prototype, the function returns an empty array.
The function iterates over an object's own and inherited properties.
Key iteration order is not guaranteed, and, thus, result order is not guaranteed.
input object
predicate function indicating which group an element in the input object belongs to
group results
function predicate( v ) {
return v[ 0 ] === 'b';
}
function Foo() {
this.a = 'beep';
this.b = 'boop';
return this;
}
Foo.prototype = Object.create( null );
Foo.prototype.c = 'foo';
Foo.prototype.d = 'bar';
var obj = new Foo();
var out = bifurcateIn( obj, predicate );
// e.g., returns [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ]
Splits an object's own and inherited property values into two groups according to a predicate function.
When invoked, the predicate function is provided two arguments:
value
: object valuekey
: object keyIf a predicate function returns a truthy value, a value is placed in the first group; otherwise, a value is placed in the second group.
If provided an empty object with no prototype, the function returns an empty array.
The function iterates over an object's own and inherited properties.
Key iteration order is not guaranteed, and, thus, result order is not guaranteed.
function options
predicate function indicating which group an element in the input object belongs to
group results
function predicate( v ) {
return v[ 0 ] === 'b';
}
function Foo() {
this.a = 'beep';
this.b = 'boop';
return this;
}
Foo.prototype = Object.create( null );
Foo.prototype.c = 'foo';
Foo.prototype.d = 'bar';
var obj = new Foo();
var opts = {
'returns': 'keys'
};
var out = bifurcateIn( obj, opts, predicate );
// e.g., returns [ [ 'a', 'b', 'd' ], [ 'c' ] ]
function predicate( v ) {
return v[ 0 ] === 'b';
}
function Foo() {
this.a = 'beep';
this.b = 'boop';
return this;
}
Foo.prototype = Object.create( null );
Foo.prototype.c = 'foo';
Foo.prototype.d = 'bar';
var obj = new Foo();
var opts = {
'returns': '*'
};
var out = bifurcateIn( obj, opts, predicate );
// e.g., returns [ [ [ 'a', 'beep' ], [ 'b', 'boop' ], [ 'd', 'bar' ] ], [ [ 'c', 'foo' ] ] ]
Returns a boolean indicating which group an object's own and inherited property values belongs to.
object value
object key
boolean indicating whether a property value should be placed in the first or second group