Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
895 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 | var $ = require('../internals/export');
|
---|
3 | var IS_PURE = require('../internals/is-pure');
|
---|
4 | var getBuiltIn = require('../internals/get-built-in');
|
---|
5 | var anObject = require('../internals/an-object');
|
---|
6 | var aFunction = require('../internals/a-function');
|
---|
7 | var speciesConstructor = require('../internals/species-constructor');
|
---|
8 | var iterate = require('../internals/iterate');
|
---|
9 |
|
---|
10 | // `Set.prototype.intersection` method
|
---|
11 | // https://github.com/tc39/proposal-set-methods
|
---|
12 | $({ target: 'Set', proto: true, real: true, forced: IS_PURE }, {
|
---|
13 | intersection: function intersection(iterable) {
|
---|
14 | var set = anObject(this);
|
---|
15 | var newSet = new (speciesConstructor(set, getBuiltIn('Set')))();
|
---|
16 | var hasCheck = aFunction(set.has);
|
---|
17 | var adder = aFunction(newSet.add);
|
---|
18 | iterate(iterable, function (value) {
|
---|
19 | if (hasCheck.call(set, value)) adder.call(newSet, value);
|
---|
20 | });
|
---|
21 | return newSet;
|
---|
22 | }
|
---|
23 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.