-
-
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.
update
Map
upsert proposal to the new API
- Loading branch information
Showing
25 changed files
with
190 additions
and
21 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
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use strict'; | ||
require('../../modules/es.map'); | ||
require('../../modules/esnext.map.get-or-insert-computed'); | ||
var entryUnbind = require('../../internals/entry-unbind'); | ||
|
||
module.exports = entryUnbind('Map', 'getOrInsertComputed'); |
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,6 @@ | ||
'use strict'; | ||
require('../../modules/es.map'); | ||
require('../../modules/esnext.map.get-or-insert'); | ||
var entryUnbind = require('../../internals/entry-unbind'); | ||
|
||
module.exports = entryUnbind('Map', 'getOrInsert'); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use strict'; | ||
require('../../modules/es.weak-map'); | ||
require('../../modules/esnext.weak-map.get-or-insert-computed'); | ||
var entryUnbind = require('../../internals/entry-unbind'); | ||
|
||
module.exports = entryUnbind('WeakMap', 'getOrInsertComputed'); |
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,6 @@ | ||
'use strict'; | ||
require('../../modules/es.weak-map'); | ||
require('../../modules/esnext.weak-map.get-or-insert'); | ||
var entryUnbind = require('../../internals/entry-unbind'); | ||
|
||
module.exports = entryUnbind('WeakMap', 'getOrInsert'); |
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
22 changes: 22 additions & 0 deletions
22
packages/core-js/modules/esnext.map.get-or-insert-computed.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var aCallable = require('../internals/a-callable'); | ||
var aMap = require('../internals/a-map'); | ||
var MapHelpers = require('../internals/map-helpers'); | ||
|
||
var get = MapHelpers.get; | ||
var has = MapHelpers.has; | ||
var set = MapHelpers.set; | ||
|
||
// `Map.prototype.getOrInsertComputed` method | ||
// https://github.com/tc39/proposal-upsert | ||
$({ target: 'Map', proto: true, real: true, forced: true }, { | ||
getOrInsertComputed: function getOrInsertComputed(key, callbackfn) { | ||
aMap(this); | ||
aCallable(callbackfn); | ||
if (has(this, key)) return get(this, key); | ||
var value = callbackfn(key); | ||
set(this, key, value); | ||
return value; | ||
} | ||
}); |
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,18 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var aMap = require('../internals/a-map'); | ||
var MapHelpers = require('../internals/map-helpers'); | ||
|
||
var get = MapHelpers.get; | ||
var has = MapHelpers.has; | ||
var set = MapHelpers.set; | ||
|
||
// `Map.prototype.getOrInsert` method | ||
// https://github.com/tc39/proposal-upsert | ||
$({ target: 'Map', proto: true, real: true, forced: true }, { | ||
getOrInsert: function getOrInsert(key, value) { | ||
if (has(aMap(this), key)) return get(this, key); | ||
set(this, key, value); | ||
return value; | ||
} | ||
}); |
22 changes: 22 additions & 0 deletions
22
packages/core-js/modules/esnext.weak-map.get-or-insert-computed.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var aCallable = require('../internals/a-callable'); | ||
var aWeakMap = require('../internals/a-weak-map'); | ||
var WeakMapHelpers = require('../internals/weak-map-helpers'); | ||
|
||
var get = WeakMapHelpers.get; | ||
var has = WeakMapHelpers.has; | ||
var set = WeakMapHelpers.set; | ||
|
||
// `WeakMap.prototype.getOrInsertComputed` method | ||
// https://github.com/tc39/proposal-upsert | ||
$({ target: 'WeakMap', proto: true, real: true, forced: true }, { | ||
getOrInsertComputed: function getOrInsertComputed(key, callbackfn) { | ||
aWeakMap(this); | ||
aCallable(callbackfn); | ||
if (has(this, key)) return get(this, key); | ||
var value = callbackfn(key); | ||
set(this, key, value); | ||
return value; | ||
} | ||
}); |
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,18 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var aWeakMap = require('../internals/a-weak-map'); | ||
var WeakMapHelpers = require('../internals/weak-map-helpers'); | ||
|
||
var get = WeakMapHelpers.get; | ||
var has = WeakMapHelpers.has; | ||
var set = WeakMapHelpers.set; | ||
|
||
// `WeakMap.prototype.getOrInsert` method | ||
// https://github.com/tc39/proposal-upsert | ||
$({ target: 'WeakMap', proto: true, real: true, forced: true }, { | ||
getOrInsert: function getOrInsert(key, value) { | ||
if (has(aWeakMap(this), key)) return get(this, key); | ||
set(this, key, value); | ||
return value; | ||
} | ||
}); |
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,6 @@ | ||
'use strict'; | ||
// https://github.com/tc39/proposal-upsert | ||
require('../modules/esnext.map.get-or-insert'); | ||
require('../modules/esnext.map.get-or-insert-computed'); | ||
require('../modules/esnext.weak-map.get-or-insert'); | ||
require('../modules/esnext.weak-map.get-or-insert-computed'); |
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
Oops, something went wrong.