-
-
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
13 changed files
with
97 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require('../../modules/es.set'); | ||
require('../../modules/esnext.set.find'); | ||
|
||
module.exports = require('../../modules/_entry-unbind')('Set', 'find'); |
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,19 @@ | ||
'use strict'; | ||
var path = require('./_path'); | ||
var anObject = require('core-js-internals/an-object'); | ||
var bind = require('core-js-internals/bind-context'); | ||
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') }, { | ||
find: function find(callbackfn /* , thisArg */) { | ||
var set = anObject(this); | ||
var iterator = values.call(set); | ||
var boundFn = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3); | ||
var step, value; | ||
while (!(step = iterator.next()).done) { | ||
if (boundFn(value = step.value, value, set)) 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
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,31 @@ | ||
import { STRICT } from '../helpers/constants'; | ||
|
||
import Set from 'core-js-pure/fn/set'; | ||
|
||
QUnit.test('Set#find', assert => { | ||
const { find } = Set.prototype; | ||
|
||
assert.isFunction(find); | ||
assert.arity(find, 1); | ||
if ('name' in find) assert.name(find, 'find'); | ||
assert.nonEnumerable(Set.prototype, 'find'); | ||
|
||
const set = new Set([1]); | ||
const context = {}; | ||
set.find(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.same(new Set([2, 3, 4]).find(it => it % 2), 3); | ||
|
||
assert.throws(() => find.call({}, () => { /* empty */ }), TypeError); | ||
|
||
if (STRICT) { | ||
assert.throws(() => find.call(undefined, () => { /* empty */ }), TypeError); | ||
assert.throws(() => find.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,30 @@ | ||
import { STRICT } from '../helpers/constants'; | ||
|
||
QUnit.test('Set#find', assert => { | ||
const { find } = Set.prototype; | ||
|
||
assert.isFunction(find); | ||
assert.arity(find, 1); | ||
assert.name(find, 'find'); | ||
assert.looksNative(find); | ||
assert.nonEnumerable(Set.prototype, 'find'); | ||
|
||
const set = new Set([1]); | ||
const context = {}; | ||
set.find(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.same(new Set([2, 3, 4]).find(it => it % 2), 3); | ||
|
||
assert.throws(() => find.call({}, () => { /* empty */ }), TypeError); | ||
|
||
if (STRICT) { | ||
assert.throws(() => find.call(undefined, () => { /* empty */ }), TypeError); | ||
assert.throws(() => find.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