-
-
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
11 changed files
with
98 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require('../../modules/es.set'); | ||
require('../../modules/esnext.set.map'); | ||
|
||
module.exports = require('../../modules/_entry-unbind')('Set', '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
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 path = require('./_path'); | ||
var anObject = require('core-js-internals/an-object'); | ||
var bind = require('core-js-internals/bind-context'); | ||
var speciesConstructor = require('core-js-internals/species-constructor'); | ||
var Set = path.Set; | ||
var values = Set.prototype.values; | ||
|
||
// https://github.com/Ginden/collection-methods | ||
require('./_export')({ target: 'Set', proto: true, real: true, forced: require('./_is-pure') }, { | ||
map: function map(callbackfn /* , thisArg */) { | ||
var set = anObject(this); | ||
var iterator = values.call(set); | ||
var boundFn = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3); | ||
var newSet = new (speciesConstructor(this, Set))(); | ||
var step, value; | ||
while (!(step = iterator.next()).done) { | ||
newSet.add(boundFn(value = step.value, value, set)); | ||
} | ||
return newSet; | ||
} | ||
}); |
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,33 @@ | ||
import { STRICT } from '../helpers/constants'; | ||
|
||
import Set from 'core-js-pure/fn/set'; | ||
import from from 'core-js-pure/fn/array/from'; | ||
|
||
QUnit.test('Set#map', assert => { | ||
const { map } = Set.prototype; | ||
|
||
assert.isFunction(map); | ||
assert.arity(map, 1); | ||
if ('name' in map) assert.name(map, 'map'); | ||
assert.nonEnumerable(Set.prototype, 'map'); | ||
|
||
const set = new Set([1]); | ||
const context = {}; | ||
set.map(function (value, key, that) { | ||
assert.same(arguments.length, 3, 'correct number of callback arguments'); | ||
assert.same(value, 1, 'correct value in callback'); | ||
assert.same(key, 1, 'correct key in callback'); | ||
assert.same(that, set, 'correct link to set in callback'); | ||
assert.same(this, context, 'correct callback context'); | ||
}, context); | ||
|
||
assert.deepEqual(from(new Set([1, 2, 3]).map(it => it ** 2)), [1, 4, 9]); | ||
assert.deepEqual(from(new Set([1, 2, 3]).map(it => it % 2)), [1, 0]); | ||
|
||
assert.throws(() => map.call({}, () => { /* empty */ }), TypeError); | ||
|
||
if (STRICT) { | ||
assert.throws(() => map.call(undefined, () => { /* empty */ }), TypeError); | ||
assert.throws(() => map.call(undefined, () => { /* empty */ }), TypeError); | ||
} | ||
}); |
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,32 @@ | ||
import { STRICT } from '../helpers/constants'; | ||
|
||
QUnit.test('Set#map', assert => { | ||
const { map } = Set.prototype; | ||
const { from } = Array; | ||
|
||
assert.isFunction(map); | ||
assert.arity(map, 1); | ||
assert.name(map, 'map'); | ||
assert.looksNative(map); | ||
assert.nonEnumerable(Set.prototype, 'map'); | ||
|
||
const set = new Set([1]); | ||
const context = {}; | ||
set.map(function (value, key, that) { | ||
assert.same(arguments.length, 3, 'correct number of callback arguments'); | ||
assert.same(value, 1, 'correct value in callback'); | ||
assert.same(key, 1, 'correct key in callback'); | ||
assert.same(that, set, 'correct link to set in callback'); | ||
assert.same(this, context, 'correct callback context'); | ||
}, context); | ||
|
||
assert.deepEqual(from(new Set([1, 2, 3]).map(it => it ** 2)), [1, 4, 9]); | ||
assert.deepEqual(from(new Set([1, 2, 3]).map(it => it % 2)), [1, 0]); | ||
|
||
assert.throws(() => map.call({}, () => { /* empty */ }), TypeError); | ||
|
||
if (STRICT) { | ||
assert.throws(() => map.call(undefined, () => { /* empty */ }), TypeError); | ||
assert.throws(() => map.call(undefined, () => { /* empty */ }), TypeError); | ||
} | ||
}); |
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