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 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, the function returns an empty object.
The function iterates over an object's own 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 ];
}
var obj = {
'a': 'beep',
'b': 'boop',
'c': 'foo',
'd': 'bar'
};
var out = groupOwn( obj, indicator );
// e.g., returns { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] }
Groups an object's own 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, the function returns an empty object.
The function iterates over an object's own 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 ];
}
var obj = {
'a': 'beep',
'b': 'boop',
'c': 'foo',
'd': 'bar'
};
var out = groupOwn( obj, indicator );
// e.g., returns { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] }
function indicator( v ) {
return v[ 0 ];
}
var obj = {
'a': 'beep',
'b': 'boop',
'c': 'foo',
'd': 'bar'
};
var opts = {
'returns': 'keys'
};
var out = groupOwn( obj, opts, indicator );
// e.g., returns { 'b': [ 'a', 'b', 'd' ], 'f': [ 'c' ] }
function indicator( v ) {
return v[ 0 ];
}
var obj = {
'a': 'beep',
'b': 'boop',
'c': 'foo',
'd': 'bar'
};
var opts = {
'returns': '*'
};
var out = groupOwn( 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