Specifies which group a property belongs to.
Specifies which group a property belongs to.
Specifies which group a property belongs to.
Groups an object's own and inherited property values according to an indicator function.
When invoked, the indicator function is provided two arguments:
value
: object valuekey
: object keyThe value returned by an indicator function should be a value which can be serialized as an object key.
If provided an empty object with no prototype, the function returns an empty object.
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
indicator function indicating which group an element in the input object belongs to
group results
function indicator( v ) {
return v[ 0 ];
}
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 = groupIn( obj, indicator );
// e.g., returns { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] }
Groups an object's own and inherited property values according to an indicator function.
When invoked, the indicator function is provided two arguments:
value
: object valuekey
: object keyThe value returned by an indicator function should be a value which can be serialized as an object key.
If provided an empty object with no prototype, the function returns an empty object.
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
function options
indicator function indicating which group an element in the input object belongs to
group results
function indicator( v ) {
return v[ 0 ];
}
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 = groupIn( obj, opts, indicator );
// e.g., returns { 'b': [ 'a', 'b', 'd' ], 'f': [ 'c' ] }
function indicator( v ) {
return v[ 0 ];
}
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 = groupIn( obj, opts, indicator );
// e.g., returns { 'b': [ [ 'a', 'beep' ], [ 'b', 'boop' ], [ 'd', 'bar' ] ], 'f': [ [ 'c', 'foo' ] ] }
Specifies which group a property belongs to.
object value
object key
group key