-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
167 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -223,4 +223,8 @@ export default { | |
3.33: [ | ||
'esnext.regexp.escape', | ||
], | ||
3.34: [ | ||
'es.map.group-by', | ||
'es.object.group-by', | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,5 @@ | ||
'use strict'; | ||
require('../../modules/es.map'); | ||
var parent = require('../../stable/map/group-by'); | ||
require('../../modules/esnext.map.group-by'); | ||
var call = require('../../internals/function-call'); | ||
var isCallable = require('../../internals/is-callable'); | ||
var path = require('../../internals/path'); | ||
|
||
var Map = path.Map; | ||
var mapGroupBy = Map.groupBy; | ||
|
||
module.exports = function groupBy(source, iterable, keyDerivative) { | ||
return call(mapGroupBy, isCallable(this) ? this : Map, source, iterable, keyDerivative); | ||
}; | ||
module.exports = parent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
'use strict'; | ||
require('../../modules/es.object.create'); | ||
var parent = require('../../stable/object/group-by'); | ||
require('../../modules/esnext.object.group-by'); | ||
|
||
var path = require('../../internals/path'); | ||
|
||
module.exports = path.Object.groupBy; | ||
module.exports = parent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
require('../../modules/es.map'); | ||
require('../../modules/es.map.group-by'); | ||
var call = require('../../internals/function-call'); | ||
var isCallable = require('../../internals/is-callable'); | ||
var path = require('../../internals/path'); | ||
|
||
var Map = path.Map; | ||
var mapGroupBy = Map.groupBy; | ||
|
||
module.exports = function groupBy(source, iterable, keyDerivative) { | ||
return call(mapGroupBy, isCallable(this) ? this : Map, source, iterable, keyDerivative); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
require('../../modules/es.object.create'); | ||
require('../../modules/es.object.group-by'); | ||
|
||
var path = require('../../internals/path'); | ||
|
||
module.exports = path.Object.groupBy; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var uncurryThis = require('../internals/function-uncurry-this'); | ||
var aCallable = require('../internals/a-callable'); | ||
var requireObjectCoercible = require('../internals/require-object-coercible'); | ||
var iterate = require('../internals/iterate'); | ||
var MapHelpers = require('../internals/map-helpers'); | ||
var IS_PURE = require('../internals/is-pure'); | ||
|
||
var Map = MapHelpers.Map; | ||
var has = MapHelpers.has; | ||
var get = MapHelpers.get; | ||
var set = MapHelpers.set; | ||
var push = uncurryThis([].push); | ||
|
||
// `Map.groupBy` method | ||
// https://github.com/tc39/proposal-array-grouping | ||
$({ target: 'Map', stat: true, forced: IS_PURE }, { | ||
groupBy: function groupBy(items, callbackfn) { | ||
requireObjectCoercible(items); | ||
aCallable(callbackfn); | ||
var map = new Map(); | ||
var k = 0; | ||
iterate(items, function (value) { | ||
var key = callbackfn(value, k++); | ||
if (!has(map, key)) set(map, key, [value]); | ||
else push(get(map, key), value); | ||
}); | ||
return map; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var getBuiltIn = require('../internals/get-built-in'); | ||
var uncurryThis = require('../internals/function-uncurry-this'); | ||
var aCallable = require('../internals/a-callable'); | ||
var requireObjectCoercible = require('../internals/require-object-coercible'); | ||
var toPropertyKey = require('../internals/to-property-key'); | ||
var iterate = require('../internals/iterate'); | ||
|
||
var create = getBuiltIn('Object', 'create'); | ||
var push = uncurryThis([].push); | ||
|
||
// `Object.groupBy` method | ||
// https://github.com/tc39/proposal-array-grouping | ||
$({ target: 'Object', stat: true }, { | ||
groupBy: function groupBy(items, callbackfn) { | ||
requireObjectCoercible(items); | ||
aCallable(callbackfn); | ||
var obj = create(null); | ||
var k = 0; | ||
iterate(items, function (value) { | ||
var key = toPropertyKey(callbackfn(value, k++)); | ||
// in some IE versions, `hasOwnProperty` returns incorrect result on integer keys | ||
// but since it's a `null` prototype object, we can safely use `in` | ||
if (key in obj) push(obj[key], value); | ||
else obj[key] = [value]; | ||
}); | ||
return obj; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,3 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var uncurryThis = require('../internals/function-uncurry-this'); | ||
var aCallable = require('../internals/a-callable'); | ||
var requireObjectCoercible = require('../internals/require-object-coercible'); | ||
var iterate = require('../internals/iterate'); | ||
var MapHelpers = require('../internals/map-helpers'); | ||
var IS_PURE = require('../internals/is-pure'); | ||
|
||
var Map = MapHelpers.Map; | ||
var has = MapHelpers.has; | ||
var get = MapHelpers.get; | ||
var set = MapHelpers.set; | ||
var push = uncurryThis([].push); | ||
|
||
// `Map.groupBy` method | ||
// https://github.com/tc39/proposal-array-grouping | ||
$({ target: 'Map', stat: true, forced: IS_PURE }, { | ||
groupBy: function groupBy(items, callbackfn) { | ||
requireObjectCoercible(items); | ||
aCallable(callbackfn); | ||
var map = new Map(); | ||
var k = 0; | ||
iterate(items, function (value) { | ||
var key = callbackfn(value, k++); | ||
if (!has(map, key)) set(map, key, [value]); | ||
else push(get(map, key), value); | ||
}); | ||
return map; | ||
} | ||
}); | ||
// TODO: Remove from `core-js@4` | ||
require('../modules/es.map.group-by'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,3 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var getBuiltIn = require('../internals/get-built-in'); | ||
var uncurryThis = require('../internals/function-uncurry-this'); | ||
var aCallable = require('../internals/a-callable'); | ||
var requireObjectCoercible = require('../internals/require-object-coercible'); | ||
var toPropertyKey = require('../internals/to-property-key'); | ||
var iterate = require('../internals/iterate'); | ||
|
||
var create = getBuiltIn('Object', 'create'); | ||
var push = uncurryThis([].push); | ||
|
||
// `Object.groupBy` method | ||
// https://github.com/tc39/proposal-array-grouping | ||
$({ target: 'Object', stat: true }, { | ||
groupBy: function groupBy(items, callbackfn) { | ||
requireObjectCoercible(items); | ||
aCallable(callbackfn); | ||
var obj = create(null); | ||
var k = 0; | ||
iterate(items, function (value) { | ||
var key = toPropertyKey(callbackfn(value, k++)); | ||
// in some IE versions, `hasOwnProperty` returns incorrect result on integer keys | ||
// but since it's a `null` prototype object, we can safely use `in` | ||
if (key in obj) push(obj[key], value); | ||
else obj[key] = [value]; | ||
}); | ||
return obj; | ||
} | ||
}); | ||
// TODO: Remove from `core-js@4` | ||
require('../modules/es.object.group-by'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
'use strict'; | ||
var parent = require('../../es/map/group-by'); | ||
|
||
module.exports = parent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
'use strict'; | ||
var parent = require('../../es/object/group-by'); | ||
|
||
module.exports = parent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
tests/unit-pure/esnext.map.group-by.js → tests/unit-pure/es.map.group-by.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/unit-pure/esnext.object.group-by.js → tests/unit-pure/es.object.group-by.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters