-
-
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.
make collections
.of
method non-generic
- Loading branch information
Showing
13 changed files
with
43 additions
and
87 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
'use strict'; | ||
var arraySlice = require('../internals/array-slice'); | ||
var anObject = require('../internals/an-object'); | ||
|
||
// https://tc39.github.io/proposal-setmap-offrom/ | ||
module.exports = function of() { | ||
return new this(arraySlice(arguments)); | ||
module.exports = function (C, adder, ENTRY) { | ||
return function of() { | ||
var result = new C(); | ||
var length = arguments.length; | ||
for (var index = 0; index < length; index++) { | ||
var entry = arguments[index]; | ||
if (ENTRY) adder(result, anObject(entry)[0], entry[1]); | ||
else adder(result, entry); | ||
} return result; | ||
}; | ||
}; |
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,9 +1,10 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var of = require('../internals/collection-of'); | ||
var MapHelpers = require('../internals/map-helpers'); | ||
var createCollectionOf = require('../internals/collection-of'); | ||
|
||
// `Map.of` method | ||
// https://tc39.github.io/proposal-setmap-offrom/#sec-map.of | ||
$({ target: 'Map', stat: true, forced: true }, { | ||
of: of | ||
of: createCollectionOf(MapHelpers.Map, MapHelpers.set, true) | ||
}); |
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,9 +1,10 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var of = require('../internals/collection-of'); | ||
var SetHelpers = require('../internals/set-helpers'); | ||
var createCollectionOf = require('../internals/collection-of'); | ||
|
||
// `Set.of` method | ||
// https://tc39.github.io/proposal-setmap-offrom/#sec-set.of | ||
$({ target: 'Set', stat: true, forced: true }, { | ||
of: of | ||
of: createCollectionOf(SetHelpers.Set, SetHelpers.add, false) | ||
}); |
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,9 +1,10 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var of = require('../internals/collection-of'); | ||
var WeakMapHelpers = require('../internals/weak-map-helpers'); | ||
var createCollectionOf = require('../internals/collection-of'); | ||
|
||
// `WeakMap.of` method | ||
// https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.of | ||
$({ target: 'WeakMap', stat: true, forced: true }, { | ||
of: of | ||
of: createCollectionOf(WeakMapHelpers.WeakMap, WeakMapHelpers.set, true) | ||
}); |
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,9 +1,10 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var of = require('../internals/collection-of'); | ||
var WeakSetHelpers = require('../internals/weak-set-helpers'); | ||
var createCollectionOf = require('../internals/collection-of'); | ||
|
||
// `WeakSet.of` method | ||
// https://tc39.github.io/proposal-setmap-offrom/#sec-weakset.of | ||
$({ target: 'WeakSet', stat: true, forced: true }, { | ||
of: of | ||
of: createCollectionOf(WeakSetHelpers.WeakSet, WeakSetHelpers.add, false) | ||
}); |
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
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