All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.
288 |
289 |
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
290 |
291 |
292 |
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
293 |
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
294 |
Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
295 |
296 |
297 |
THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
298 |
299 |
300 |
--------------------------------------------------------------------------------
/map-polyfill.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | function assert(val, msg) {
4 | if (!val) {
5 | throw new TypeError(msg);
6 | }
7 | }
8 |
9 | function isObject(x) {
10 | return (typeof x === 'function' || typeof x === 'object');
11 | }
12 |
13 | function SpeciesConstructor(O, defaultConstructor) {
14 | assert(isObject(O), 'O is not Object');
15 |
16 | const C = O.constructor;
17 |
18 | if (typeof C === 'undefined') {
19 | return defaultConstructor;
20 | }
21 |
22 | if (!isObject(C)) {
23 | throw new TypeError('O.constructor is not an Object');
24 | }
25 |
26 | const S = C[Symbol.species];
27 |
28 | if (S == null) {
29 | return defaultConstructor;
30 | }
31 |
32 | if (typeof S === 'function' && !!S.prototype) {
33 | return S;
34 | }
35 |
36 | throw new TypeError('no constructor found');
37 | }
38 |
39 | function isCallable(x) {
40 | try {
41 | Function.prototype.toString.call(x);
42 | return true;
43 | } catch(e) {
44 | return false;
45 | }
46 | }
47 |
48 | function filter(callbackFn, thisArg) {
49 | assert(isObject(this), 'this is not an object');
50 | assert(isCallable(callbackFn), 'callback is not a function');
51 | const Ctor = SpeciesConstructor(this, Map);
52 | const retObj = new Ctor();
53 | const _set = retObj.set;
54 | for(const [key, value] of this) {
55 | if (Reflect.apply(callbackFn, thisArg, [value, key, this])) {
56 | Reflect.apply(_set, retObj, [key, value]);
57 | }
58 | }
59 | return retObj;
60 | }
61 |
62 | function mapValues(callbackFn, thisArg) {
63 | assert(isObject(this), 'this is not an object');
64 | assert(isCallable(callbackFn), 'callback is not a function');
65 | const Ctor = SpeciesConstructor(this, Map);
66 | const retObj = new Ctor();
67 | const _set = retObj.set;
68 | for(const [key, value] of this) {
69 | const newValue = Reflect.apply(callbackFn, thisArg, [value, key, this])
70 | Reflect.apply(_set, retObj, [key, newValue]);
71 | }
72 | return retObj;
73 | }
74 |
75 | function mapKeys(callbackFn, thisArg) {
76 | assert(isObject(this), 'this is not an object');
77 | assert(isCallable(callbackFn), 'callback is not a function');
78 | const Ctor = SpeciesConstructor(this, Map);
79 | const retObj = new Ctor();
80 | const _set = retObj.set;
81 | for(const [key, value] of this) {
82 | const newKey = Reflect.apply(callbackFn, thisArg, [value, key, this])
83 | Reflect.apply(_set, retObj, [newKey, value]);
84 | }
85 | return retObj;
86 | }
87 |
88 | function merge(iterable) {
89 | assert(isObject(this), 'this is not an object');
90 | const Ctor = SpeciesConstructor(this, Map);
91 | return new Ctor([...this, ...iterable]);
92 | }
93 |
94 | function groupBy(iterable, keyDerivative) {
95 | assert(isObject(this), 'this is not an object');
96 | assert(isCallable(this), 'this is not a function');
97 | assert(Map === this || Map.isPrototypeOf(this), 'this is not a Map constructor');
98 | const retObj = new this();
99 | for(const element of iterable) {
100 | const derivedKey = Reflect.apply(keyDerivative, null, [element]);
101 | if (!retObj.has(derivedKey)) {
102 | retObj.set(derivedKey, []);
103 | }
104 | const arr = retObj.get(derivedKey);
105 | arr.push(element);
106 | }
107 | return retObj;
108 | }
109 |
110 | function keyBy(iterable, keyDerivative) {
111 | assert(isObject(this), 'this is not an object');
112 | assert(isCallable(this), 'this is not a function');
113 | assert(Map === this || Map.isPrototypeOf(this), 'this is not a Map constructor');
114 | const retObj = new this();
115 | for(const element of iterable) {
116 | const derivedKey = Reflect.apply(keyDerivative, null, [element]);
117 | retObj.set(derivedKey, value);
118 | }
119 | return retObj;
120 | }
121 |
122 | assert(typeof Map === 'function', 'Map does not exist');
123 | const prototypeMethods = {
124 | mapValues,
125 | mapKeys,
126 | filter,
127 | merge,
128 | };
129 | const staticMethods = {
130 | groupBy,
131 | keyBy
132 | };
133 | for (const [key, value] of Object.entries(prototypeMethods)) {
134 | Object.defineProperty(Map.prototype, key, {
135 | configurable: true,
136 | value
137 | });
138 | }
139 | for (const [key, value] of Object.entries(staticMethods)) {
140 | Object.defineProperty(Map, key, {
141 | configurable: true,
142 | value
143 | });
144 | }
145 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "name": "proposal-set-methods",
4 | "description": "New collection methods proposal for JavaScript",
5 | "license": "MIT",
6 | "scripts": {
7 | "spec": "ecmarkup --assets=external spec/index.html docs/index.html",
8 | "watch": "npx ecmarkup --watch --assets=external spec/index.html docs/index.html",
9 | "test": "mocha -r ./set-polyfill.js -r ./map-polyfill.js test/*/*.spec.js",
10 | "format": "emu-format --write spec/**/*.html"
11 | },
12 | "type": "module",
13 | "version": "1.0.0",
14 | "repository": {
15 | "type": "git",
16 | "url": "git+https://github.com/Ginden/set-methods.git"
17 | },
18 | "keywords": [],
19 | "author": "Michał Wadas ",
20 | "bugs": {
21 | "url": "https://github.com/tc39/proposal-collection-methods/issues"
22 | },
23 | "homepage": "https://github.com/tc39/proposal-collection-methods#readme",
24 | "dependencies": {
25 | "chai": "^5.1.1",
26 | "mocha": "^10.7.0"
27 | },
28 | "devDependencies": {
29 | "ecmarkup": "^19.0.0"
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/rationales.md:
--------------------------------------------------------------------------------
1 | # Set prototype methods
2 |
3 | ## Set.prototype.filter
4 |
5 | * Added to make all collections similar in capabilities. Should mimic [Array.prototype.filter](https://tc39.github.io/ecma262/#sec-array.prototype.filter) as close as reasonable.
6 |
7 | ## Set.prototype.map
8 |
9 | * Added to make all collections similar in capabilities. Should mimic [Array.prototype.map](https://tc39.github.io/ecma262/#sec-array.prototype.map) as close as reasonable.
10 |
11 |
12 | ## Set.prototype.find
13 |
14 | * Added to make all collections similar in capabilities. Should mimic [Array.prototype.find](https://tc39.github.io/ecma262/#sec-array.prototype.find) as close as reasonable.
15 | * [Problematic behaviour](https://github.com/tc39/proposal-collection-methods/issues/6)
16 |
17 | ## Set.prototype.reduce
18 |
19 | * Added to make all collections similar in capabilities. Should mimic [Array.prototype.reduce](https://tc39.github.io/ecma262/#sec-array.prototype.reduce) as close as reasonable.
20 | * Static linters can check if function used by Set.prototype.reduce is [associative](https://en.wikipedia.org/wiki/Associative_property) and [commutative](https://en.wikipedia.org/wiki/Commutative_property). Otherwise, results can be surprising to user.
21 |
22 | ## Set.prototype.join
23 |
24 | * Added to make all collections similar in capabilities. Should mimic [Array.prototype.join](https://tc39.github.io/ecma262/#sec-array.prototype.join) as close as reasonable.
25 |
26 | ## Set.prototype.some
27 |
28 | * Added to make all collections similar in capabilities. Should mimic [Array.prototype.some](https://tc39.github.io/ecma262/#sec-array.prototype.some) as close as reasonable.
29 |
30 |
31 | ## Set.prototype.every
32 |
33 | * Added to make all collections similar in capabilities. Should mimic [Array.prototype.every](https://tc39.github.io/ecma262/#sec-array.prototype.every) as close as reasonable.
34 |
35 |
36 | ## Set.prototype.addAll
37 |
38 | * `Set.prototype.add` can't be extended due to pattern of `arr.forEach(set.add, set)` and `arr.forEach(set.add.bind(set))`.
39 | * Doesn't create new set like [`Set.prototype.union`](https://tc39.github.io/proposal-set-methods/#Set.prototype.union)
40 |
41 |
42 | ## Set.prototype.deleteAll
43 |
44 | * `Set.prototype.delete` can't be extended due to pattern of `arr.forEach(set.delete, set)` and `arr.forEach(set.delete.bind(set))`.
45 |
46 |
47 |
48 | # Map prototype methods
49 |
50 | ## Map.prototype.filter
51 |
52 | * Added to make all collections similar in capabilities. Should mimic [Array.prototype.filter](https://tc39.github.io/ecma262/#sec-array.prototype.filter) as close as reasonable.
53 |
54 |
55 | ## Map.prototype.mapValues
56 |
57 | TBA
58 |
59 |
60 | ## Map.prototype.mapKeys
61 |
62 | TBA
63 |
64 |
65 | ## Map.prototype.reduce
66 |
67 | * Added to make all collections similar in capabilities. Should mimic [Array.prototype.reduce](https://tc39.github.io/ecma262/#sec-array.prototype.reduce) as close as reasonable.
68 |
69 |
70 | ## Map.prototype.find
71 |
72 | * Added to make all collections similar in capabilities. Should mimic [Array.prototype.find](https://tc39.github.io/ecma262/#sec-array.prototype.find).
73 | * This methods find value and returns it. It can be reasonable to return pair `[key, value]` or merge it with `findKey`.
74 |
75 | ## Map.prototype.findKey
76 | * This methods find value and returns its key. It can be reasonable to return pair `[key, value]` or merge it with `find`.
77 |
78 | ## Map.prototype.keyOf(searchElement)
79 |
80 | * This methods returns first key where `SameValueZero(p.[[Value]], searchElement)` is *true*.
81 |
82 | ## Map.prototype.some
83 |
84 | * Added to make all collections similar in capabilities. Should mimic [Array.prototype.some](https://tc39.github.io/ecma262/#sec-array.prototype.some) as close as reasonable.
85 |
86 |
87 | ## Map.prototype.every
88 |
89 | * Added to make all collections similar in capabilities. Should mimic [Array.prototype.some](https://tc39.github.io/ecma262/#sec-array.prototype.some) as close as reasonable.
90 |
91 | ## Map.prototype.includes
92 |
93 | * Added to make all collections similar in capabilities. Should mimic [Array.prototype.includes](https://tc39.github.io/ecma262/#sec-array.prototype.includes) as close as reasonable.
94 |
95 |
96 | ## Map.prototype.update
97 |
98 | TBA
99 |
100 |
101 | ## Map.prototype.deleteAll
102 |
103 | TBA
104 |
105 |
106 | ## Map.prototype.merge
107 |
108 | TBA
109 |
110 |
111 | # Map static methods
112 |
113 | ## Map.groupBy
114 |
115 | TBA
116 |
117 | ## Map.keyBy
118 |
119 | TBA
120 |
--------------------------------------------------------------------------------
/set-polyfill.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var originalSet = Set;
4 |
5 | function assert(val, msg) {
6 | if (!val) {
7 | throw new TypeError(msg);
8 | }
9 | }
10 |
11 | function isObject(x) {
12 | return (typeof x === 'function' || typeof x === 'object');
13 | }
14 |
15 | function SpeciesConstructor(O, defaultConstructor) {
16 | assert(isObject(O), 'O is not Object');
17 |
18 | var C = O.constructor;
19 |
20 | if (typeof C === 'undefined') {
21 | return defaultConstructor;
22 | }
23 |
24 | if (!isObject(C)) {
25 | throw new TypeError('O.constructor is not an Object');
26 | }
27 |
28 | var S = C[Symbol.species];
29 |
30 | if (S == null) {
31 | return defaultConstructor;
32 | }
33 |
34 | if (typeof S === 'function' && !!S.prototype) {
35 | return S;
36 | }
37 |
38 | throw new TypeError('no constructor found');
39 | }
40 |
41 | function isCallable(x) {
42 | try {
43 | Function.prototype.toString.call(x);
44 | return true;
45 | } catch(e) {
46 | return false;
47 | }
48 | }
49 |
50 | function isSet(obj) {
51 | const methodNames = ['has', 'add', 'forEach', 'delete', 'keys', 'values', 'entries'];
52 | return !!(
53 | obj &&
54 | methodNames.every(key=>key in obj && typeof obj[key] === 'function') &&
55 | 'size' in obj &&
56 | typeof obj.size === 'number' &&
57 | Number.isInteger(obj.size)
58 | );
59 | }
60 |
61 | function filter(predicate, thisArg = null) {
62 | assert(typeof predicate === 'function');
63 | assert(isSet(this));
64 | const ret = new (SpeciesConstructor(this));
65 | for (const element of this) {
66 | if (Reflect.apply(predicate, thisArg, [element, element, this])) {
67 | ret.add(element);
68 | }
69 | }
70 | return ret;
71 | }
72 |
73 | function map(mapFunction, thisArg = null) {
74 | assert(typeof mapFunction === 'function');
75 | assert(isSet(this));
76 | const ret = new (SpeciesConstructor(this));
77 | for (const element of this) {
78 | ret.add(Reflect.apply(mapFunction, thisArg, [element, element, this]))
79 | }
80 | return ret;
81 | }
82 |
83 | function some(predicate, thisArg = null) {
84 | assert(typeof predicate === 'function');
85 | assert(isSet(this));
86 | for (const element of this) {
87 | if (Reflect.apply(predicate, thisArg, [element, element, this])) {
88 | return true;
89 | }
90 | }
91 | return false;
92 | }
93 |
94 | function find(predicate, thisArg = null) {
95 | assert(typeof predicate === 'function');
96 | assert(isSet(this));
97 | for (const element of this) {
98 | if (Reflect.apply(predicate, thisArg, [element, element, this])) {
99 | return element;
100 | }
101 | }
102 | return undefined;
103 | }
104 |
105 | function every(predicate, thisArg = null) {
106 | assert(typeof predicate === 'function');
107 | assert(isSet(this));
108 | for (const element of this) {
109 | if (!Reflect.apply(predicate, thisArg, [element, element, this])) {
110 | return false;
111 | }
112 | }
113 | return true;
114 | }
115 |
116 |
117 |
118 | function addAll(...args) {
119 | assert(isSet(this));
120 | for (const element of args) {
121 | this.add(element);
122 | }
123 | return this;
124 | }
125 |
126 | function deleteAll(...items) {
127 | const len = items.length;
128 | const set = this;
129 | assert(isObject(set), 'set is not an Object');
130 |
131 | let k = 0;
132 | const remover = set.delete;
133 | assert(isCallable(remover), 'remover is not a function');
134 |
135 | while (k < len) {
136 | const value = items[k];
137 | Reflect.apply(remover, set, [value]);
138 | k++;
139 | }
140 | return this;
141 | }
142 |
143 | assert(typeof Set === 'function', 'Set does not exist');
144 | const prototypeMethods = [
145 | ['map', map],
146 | ['filter', filter],
147 | ['some', some],
148 | ['every', every],
149 | ['find', find],
150 | ['addAll', addAll],
151 | ['deleteAll', deleteAll],
152 | ];
153 | const staticMethods = [
154 | ['isSet', isSet]
155 | ];
156 | for (const [key, value] of prototypeMethods) {
157 | Object.defineProperty(Set.prototype, key, {
158 | configurable: true,
159 | value
160 | });
161 | }
162 | for (const [key, value] of staticMethods) {
163 | Object.defineProperty(Set, key, {
164 | configurable: true,
165 | value
166 | });
167 | }
168 |
--------------------------------------------------------------------------------
/spec/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | title: New collections methods
5 | location: https://tc39.github.io/proposal-collection-methods/
6 | repository: https://github.com/tc39/proposal-collection-methods
7 | contributors: Michał Wadas, Ecma International
8 |
When the `keyBy` method is called, the following steps are taken:
3 |
4 |
5 | 1. Let _C_ be the *this* value.
6 | 1. If IsConstructor(_C_) is *true*
7 | 1. Let _map_ be ? Construct(_C_)
8 | 1. Else,
9 | 1. Throw a *TypeError*.
10 | 1. If _map_ does not have a ~[[MapData]]~ internal slot, throw a *TypeError* exception.
11 | 1. If IsCallable(_callbackfn_) is false, throw a *TypeError* exception.
12 | 1. Let _set_ be ? Get(_map_, "set")
13 | 1. Let _iteratorRecord_ be ? GetIterator(_iterable_).
14 | 1. Repeat,
15 | 1. Let _next_ be ? IteratorStep(_iteratorRecord_).
16 | 1. If _next_ is *false*, return _map_.
17 | 1. Let _item_ be ? IteratorValue(_next_).
18 | 1. Let _key_ be Call(_callbackfn_, *null*, « _item_ »)
19 | 1. Let _status_ be Call(_set_, _map_, « _key_.[[Value]], _value_.[[Value]] »).
20 | 1. If _status_ is an abrupt completion, return ? IteratorClose(_iteratorRecord_, _status_).
21 |
22 |
--------------------------------------------------------------------------------
/spec/map/prototype-delete-all.html:
--------------------------------------------------------------------------------
1 |
2 |
When the `deleteAll` method is called, the following steps are taken:
3 |
4 |
The `length` property of the `deleteAll` method is *0*.
5 |
6 |
7 | 1. Let _len_ be the actual number of arguments passed to this function.
8 | 1. Let _items_ be the List of arguments passed to this function.
9 | 1. Let _map_ be the *this* value.
10 | 1. If Type(_map_) is not Object, throw a *TypeError* exception.
11 | 1. If _map_ does not have a ~[[MapData]]~ internal slot, throw a *TypeError* exception.
12 | 1. Let _k_ be 0.
13 | 1. Let _remover_ be ? Get(_map_, "delete")
14 | 1. If IsCallable(_remover_) is *false*, throw a *TypeError* exception.
15 | 1. Repeat while _k_ < _len_
16 | 1. Let _value_ be _items_[_k_].
17 | 1. Call(_remover_, _map_, _value_)
18 | 1. Increase _k_ by 1.
19 | 1. Return _map_.
20 |
21 |
22 |
--------------------------------------------------------------------------------
/spec/map/prototype-every.html:
--------------------------------------------------------------------------------
1 |
2 |
When the `every` method is called, the following steps are taken:
3 |
4 |
5 | 1. Let _M_ be the *this* value.
6 | 1. Perform ? RequireInternalSlot(_M_, [[MapData]]).
7 | 1. If IsCallable(_predicate_) is **false**, throw a *TypeError* exception.
8 | 1. Let _entries_ be the List that is _map_.[[MapData]].
9 | 1. For each Record { [[Key]], [[Value]] } _e_ of _M_.[[MapData]], do
10 | 1. If _e_.[[Key]] is not ~empty~, then
11 | 1. Let _testResult_ be ToBoolean(? Call(_predicate_, _T_, « _e_.[[Value]], _e_.[[Key]], _map_ »))
12 | 1. If _testResult_ is *false*, then return *false*
13 | 1. Return *true*.
14 |
15 |
16 |
--------------------------------------------------------------------------------
/spec/map/prototype-filter.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | This code serves as placeholder until formal spec is written for this method.
4 |
5 |
6 |
7 | 1. Let _map_ be the *this* value.
8 | 1. If Type(_map_) is not Object, throw a *TypeError* exception.
9 | 1. If _map_ does not have a ~[[MapData]]~ internal slot, throw a *TypeError* exception.
10 | 1. If IsCallable(_callbackfn_) is false, throw a *TypeError* exception.
11 | 1. If _thisArg_ was supplied, let _T_ be _thisArg_; else let _T_ be *undefined*.
12 | 1. Let _Ctr_ be ? SpeciesConstructor(_map_, %Map%)
13 | 1. Let _newMap_ be ? Construct(_Ctr_)
14 | 1. Let _adder_ be ? Get(_newSet_, "set")
15 | 1. If IsCallable(_adder_) is *false*, throw a TypeError.
16 | 1. Let _entries_ be the List that is _map_.[[MapData]]
17 | 1. Let _newMapData_ be new empty List.
18 | 1. For each Record { [[Key]], [[Value]] } _p_ that is an element of entries, do
19 | 1. If _p_.[[Key]] is not empty, then
20 | 1. Let _key_ be _p_.[[Key]]
21 | 1. Let _value_ be _p_.[[Value]]
22 | 1. Let _selected_ be ToBoolean(? Call(_callbackfn_, _T_, « _value_, _key_, _map_ »))
23 | 1. If _selected_ is *true*, then
24 | 1. Let _pair_ be CreateArrayFromList(« _value_, _key_ »)
25 | 1. Append _pair_ as last element to _newMapData_.
26 | 1. Return ? AddEntriesFromIterable(_map_, CreateArrayFromList(_newMapData_), _adder_).
27 |
28 |
--------------------------------------------------------------------------------
/spec/map/prototype-find-key.html:
--------------------------------------------------------------------------------
1 |
2 |
When the `findKey` method is called, the following steps are taken:
3 |
4 |
5 | 1. Let _map_ be the *this* value.
6 | 1. If Type(_map_) is not Object, throw a *TypeError* exception.
7 | 1. If _map_ does not have a ~[[MapData]]~ internal slot, throw a *TypeError* exception.
8 | 1. If IsCallable(_callbackfn_) is false, throw a *TypeError* exception.
9 | 1. If _thisArg_ was supplied, let _T_ be _thisArg_; else let _T_ be *undefined*.
10 | 1. Let _entries_ be the List that is _map_.[[MapData]].
11 | 1. For each Record { [[Key]], [[Value]] } _e_ that is an element of _entries_, in original key insertion order, do:
12 | 1. If _e_.[[Key]] is not ~empty~, then
13 | 1. Let _testResult_ be ToBoolean(? Call(_callbackfn_, _T_, « _e_.[[Value]], _e_.[[Key]], _map_ »)).
14 | 1. If _testResult_ is *true*, then return _e_.[[Key]].
15 | 1. Return *undefined*.
16 |
17 |
18 |
--------------------------------------------------------------------------------
/spec/map/prototype-find.html:
--------------------------------------------------------------------------------
1 |
2 |
When the `find` method is called, the following steps are taken:
3 |
4 |
5 | 1. Let _map_ be the *this* value.
6 | 1. If Type(_map_) is not Object, throw a *TypeError* exception.
7 | 1. If _map_ does not have a ~[[MapData]]~ internal slot, throw a *TypeError* exception.
8 | 1. If IsCallable(_callbackfn_) is false, throw a *TypeError* exception.
9 | 1. If _thisArg_ was supplied, let _T_ be _thisArg_; else let _T_ be *undefined*.
10 | 1. Let _entries_ be the List that is _map_.[[MapData]].
11 | 1. For each Record { [[Key]], [[Value]] } _e_ that is an element of _entries_, in original key insertion order, do:
12 | 1. If _e_.[[Key]] is not ~empty~, then
13 | 1. Let _testResult_ be ToBoolean(? Call(_callbackfn_, _T_, « _e_.[[Value]], _e_.[[Key]], _map_ »)).
14 | 1. If _testResult_ is *true*, then return _e_.[[Value]].
15 | 1. Return *undefined*.
16 |
17 |
18 |
--------------------------------------------------------------------------------
/spec/map/prototype-includes.html:
--------------------------------------------------------------------------------
1 |
2 |
When the `includes` method is called, the following steps are taken:
3 |
4 |
5 | 1. Let _map_ be the *this* value.
6 | 1. If Type(_map_) is not Object, throw a *TypeError* exception.
7 | 1. If _map_ does not have a ~[[MapData]]~ internal slot, throw a *TypeError* exception.
8 | 1. Let _entries_ be the List that is _map_.[[MapData]].
9 | 1. For each Record { [[Key]], [[Value]] } _e_ that is an element of _entries_, in original key insertion order, do:
10 | 1. If _e_.[[Key]] is not ~empty~, then
11 | 1. If SameValueZero(_searchElement_, _e_.[[Value]]) is *true*, return *true*.
12 | 1. Return *false*.
13 |
14 |
15 |
--------------------------------------------------------------------------------
/spec/map/prototype-key-of.html:
--------------------------------------------------------------------------------
1 |
2 |
When the `keyOf` method is called, the following steps are taken:
3 |
4 |
5 | 1. Let _map_ be the *this* value.
6 | 1. If Type(_map_) is not Object, throw a *TypeError* exception.
7 | 1. If _map_ does not have a ~[[MapData]]~ internal slot, throw a *TypeError* exception.
8 | 1. Let _entries_ be the List that is _map_.[[MapData]].
9 | 1. For each Record { [[Key]], [[Value]] } _e_ that is an element of _entries_, in original key insertion order, do:
10 | 1. If _e_.[[Key]] is not ~empty~, then
11 | 1. Let _same_ be the result of performing Strict Equality Comparison _searchElement_ === _e_.[[Value]].
12 | 1. If _same_ is *true*, then return _e_.[[Key]].
13 | 1. Return *undefined*.
14 |
15 |
16 |
--------------------------------------------------------------------------------
/spec/map/prototype-map-keys.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | This code serves as placeholder until formal spec is written for this method.
4 |
5 |
6 |
7 | function mapKeys(callbackFn, thisArg) {
8 | assert(isObject(this), 'this is not an object');
9 | assert(isCallable(callbackFn), 'callback is not a function');
10 | const Ctor = SpeciesConstructor(this, Map);
11 | const retObj = new Ctor();
12 | const _set = retObj.set;
13 | for(const [key, value] of this) {
14 | const newKey = Reflect.apply(callbackFn, thisArg, [value, key, this])
15 | Reflect.apply(_set, retObj, [newKey, value]);
16 | }
17 | return retObj;
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/spec/map/prototype-map-values.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | This code serves as placeholder until formal spec is written for this method.
4 |
5 |
6 |
7 | function mapValues(callbackFn, thisArg) {
8 | assert(isObject(this), 'this is not an object');
9 | assert(isCallable(callbackFn), 'callback is not a function');
10 | const Ctor = SpeciesConstructor(this, Map);
11 | const retObj = new Ctor();
12 | const _set = retObj.set;
13 | for(const [key, value] of this) {
14 | const newValue = Reflect.apply(callbackFn, thisArg, [value, key, this])
15 | Reflect.apply(_set, retObj, [key, newValue]);
16 | }
17 | return retObj;
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/spec/map/prototype-merge.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | This code serves as placeholder until formal spec is written for this method.
4 |
5 |
6 |
7 | function merge(...iterables) {
8 | assert(isObject(this), 'this is not an object');
9 | assert(this instanceof Map, 'this is not a Map instance');
10 | for(const iterable of iterables) {
11 | for(const [key, value] of iterable) {
12 | this.set(key, value);
13 | }
14 | }
15 |
16 | return this;
17 | }
18 |
When the `reduce` method is called, the following steps are taken:
3 |
4 |
5 | 1. Let _map_ be the *this* value.
6 | 1. If Type(_map_) is not Object, throw a *TypeError* exception.
7 | 1. If _map_ does not have a ~[[MapData]]~ internal slot, throw a *TypeError* exception.
8 | 1. If IsCallable(_callbackfn_) is false, throw a *TypeError* exception.
9 | 1. Let _entries_ be the List that is _map_.[[MapData]].
10 | 1. Let _accumulator_ be *undefined*
11 | 1. Let _first_ be *true*.
12 | 1. If _initialValue_ is present, then
13 | 1. Set _accumulator_ to _initialValue_
14 | 1. For each Record { [[Key]], [[Value]] } _e_ that is an element of _entries_, in original key insertion order, do:
15 | 1. If _e_.[[Key]] is not ~empty~, then
16 | 1. If _first_ be *true* and _initialValue_ is not present:
17 | 1. Set _accumulator_ to _e_.[[Value]]
18 | 1. Else,
19 | 1. Set _accumulator_ to ? Call(_callbackfn_, undefined, « _accumulator_, _e_.[[Value]], _e_.[[Key]], _map_ »)
20 | 1. Set _first_ to *false*
21 | 1. If _first_ is *true* and _initialValue_ is not present, throw *TypeError* exception.
22 | 1. Return _accumulator_.
23 |
24 |
--------------------------------------------------------------------------------
/spec/map/prototype-some.html:
--------------------------------------------------------------------------------
1 |
2 |
When the `some` method is called, the following steps are taken:
3 |
4 |
5 | 1. Let _map_ be the *this* value.
6 | 1. If Type(_map_) is not Object, throw a *TypeError* exception.
7 | 1. If _map_ does not have a ~[[MapData]]~ internal slot, throw a *TypeError* exception.
8 | 1. If IsCallable(_callbackfn_) is false, throw a *TypeError* exception.
9 | 1. If _thisArg_ was supplied, let _T_ be _thisArg_; else let _T_ be *undefined*.
10 | 1. Let _entries_ be the List that is _map_.[[MapData]].
11 | 1. For each Record { [[Key]], [[Value]] } _e_ that is an element of _entries_, in original key insertion order, do:
12 | 1. If _e_.[[Key]] is not ~empty~, then
13 | 1. Let _testResult_ be ToBoolean(? Call(_callbackfn_, _T_, « _e_.[[Value]], _e_.[[Key]], _map_ »))
14 | 1. If _testResult_ is *true*, then return *true*
15 | 1. Return *false*.
16 |
17 |
18 |
--------------------------------------------------------------------------------
/spec/map/prototype-update.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | This code serves as placeholder until formal spec is written for this method.
4 |
5 |
6 |
7 | function update(key, cb, thunk) {
8 | assert(isObject(this), 'this is not an object');
9 | assert(isCallable(callbackFn), 'callback is not a function');
10 | asset(isMap(this), 'this is not a Map instance');
11 | const isPresentInMap = this.has(key);
12 | if (isPresentInMap === false && arguments.length < 3) {
13 | throw new Error('Invalid!');
14 | }
15 | const value = isPresentInMap ? this.get(key) : thunk(key, this);
16 | const newValue = cb(value, key, this);
17 | this.set(key, newValue);
18 | return this;
19 | }
20 |
When the `addAll` method is called, the following steps are taken:
3 |
4 |
5 | 1. Let _len_ be the actual number of arguments passed to this function.
6 | 1. Let _items_ be the List of arguments passed to this function.
7 | 1. Let _set_ be the *this* value.
8 | 1. If Type(_set_) is not Object, throw a *TypeError* exception.
9 | 1. If _set_ does not have a ~[[SetData]]~ internal slot, throw a *TypeError* exception.
10 | 1. Let _elements_ be CreateArrayFromList(items).
11 | 1. Let _adder_ be ? Get(_set_, "add")
12 | 1. Return ? AddEntriesFromIterable(_set_, _elements_, _adder_).
13 |
14 |
15 |
16 |
The `length` property of the `addAll` method is *0*.
When the `every` method is called, the following steps are taken:
3 |
4 |
5 | 1. Let _O_ be the *this* value.
6 | 1. Perform ? RequireInternalSlot(_O_, [[SetData]]).
7 | 1. If IsCallable(_predicate_) is *false*, throw a *TypeError* exception.
8 | 1. Let _entries_ be _O_.[[SetData]]
9 | 1. Let _thisSize_ be the number of elements in _O_.[[SetData]].
10 | 1. Let _index_ be 0.
11 | 1. Repeat, while _index_ < _thisSize_,
12 | 1. Let _e_ be _O_.[[SetData]][_index_].
13 | 1. Set _index_ to _index_ + 1.
14 | 1. If _e_ is not `empty`, then
15 | 1. Let _testResult_ be ToBoolean(? Call(_predicate_, _thisArg_, « _e_, _e_, _set_ »))
16 | 1. If _testResult_ is *false*, then return *false*
17 | 1. Return *true*.
18 |
19 |
20 |
--------------------------------------------------------------------------------
/spec/set/prototype-filter.html:
--------------------------------------------------------------------------------
1 |
2 |
When the `filter` method is called, the following steps are taken:
3 |
4 |
5 | 1. Let _O_ be the *this* value.
6 | 1. Perform ? RequireInternalSlot(_O_, [[SetData]]).
7 | 1. If IsCallable(_callbackfn_) is *false*, throw a *TypeError* exception.
8 | 1. Let _resultSetData_ be a new empty List.
9 | 1. Let _entries_ be _O_.[[SetData]]
10 | 1. Let _thisSize_ be the number of elements in _O_.[[SetData]].
11 | 1. Let _index_ be 0.
12 | 1. Repeat, while _index_ < _thisSize_,
13 | 1. Let _e_ be _O_.[[SetData]][_index_].
14 | 1. Set _index_ to _index_ + 1.
15 | 1. If _e_ is not ~empty~, then
16 | 1. Let _selected_ be ToBoolean(? Call(_callbackfn_, _thisArg_, « _kValue_, _kValue_, _O_ »)).
17 | 1. If _selected_ is *true*, then:
18 | 1. Append _e_ to _resultSetData_.
19 | 1. Let _result_ be OrdinaryObjectCreate(%Set.prototype%, « [[SetData]] »).
20 | 1. Set _result_.[[SetData]] to _resultSetData_.
21 | 1. Return _result_.
22 |
23 |
--------------------------------------------------------------------------------
/spec/set/prototype-find.html:
--------------------------------------------------------------------------------
1 |
2 |
When the `find` method is called, the following steps are taken:
3 |
4 |
5 | 1. Let _O_ be the *this* value.
6 | 1. Perform ? RequireInternalSlot(_O_, [[SetData]]).
7 | 1. If IsCallable(_predicate_) is false, throw a *TypeError* exception.
8 | 1. Let _entries_ be _O_.[[SetData]]
9 | 1. Let _thisSize_ be the number of elements in _O_.[[SetData]].
10 | 1. Let _index_ be 0.
11 | 1. Repeat, while _index_ < _thisSize_,
12 | 1. Let _e_ be _O_.[[SetData]][_index_].
13 | 1. Set _index_ to _index_ + 1.
14 | 1. If _e_ is not ~empty~, then
15 | 1. Let _testResult_ be ToBoolean(? Call(_predicate_, _thisArg_, « _e_, _e_, _O_ »))
16 | 1. If _testResult_ is *true*, then return _e_
17 | 1. Return *undefined*.
18 |
19 |
--------------------------------------------------------------------------------
/spec/set/prototype-join.html:
--------------------------------------------------------------------------------
1 |
2 |
When the `join` method is called, the following steps are taken:
3 |
4 |
5 | 1. Let _set_ be the *this* value.
6 | 1. If Type(_set_) is not Object, throw a *TypeError* exception.
7 | 1. If _set_ does not have a [[SetData]] internal slot, throw a *TypeError* exception.
8 | 1. If _separator_ is *undefined*, let _sep_ be the single-element String `","`.
9 | 1. Else, let _sep_ be ? ToString(_separator_).
10 | 1. Let _R_ be the empty String.
11 | 1. Let _k_ be *false*.
12 | 1. Let _entries_ be _O_.[[SetData]]
13 | 1. Let _thisSize_ be the number of elements in _O_.[[SetData]].
14 | 1. Let _index_ be 0.
15 | 1. Repeat, while _index_ < _thisSize_,
16 | 1. Let _e_ be _O_.[[SetData]][_index_].
17 | 1. Set _index_ to _index_ + 1.
18 | 1. If _e_ is not ~empty~, then
19 | 1. If _k_ is *true*, let _R_ be the string-concatenation of _R_ and _sep_.
20 | 1. Set _k_ to *true*.
21 | 1. Let _next_ be ? ToString(_e_).
22 | 1. Set _R_ to the string-concatenation of _R_ and _next_.
23 | 1. Return _R_.
24 |
25 |
--------------------------------------------------------------------------------
/spec/set/prototype-map.html:
--------------------------------------------------------------------------------
1 |
2 |
When the `map` method is called, the following steps are taken:
3 |
4 |
5 | 1. Let _O_ be the *this* value.
6 | 1. Perform ? RequireInternalSlot(_O_, [[SetData]]).
7 | 1. If IsCallable(_callbackfn_) is *false*, throw a *TypeError* exception.
8 | 1. Let _resultSetData_ be a new empty List.
9 | 1. Let _entries_ be _O_.[[SetData]]
10 | 1. Let _thisSize_ be the number of elements in _O_.[[SetData]].
11 | 1. Let _index_ be 0.
12 | 1. Repeat, while _index_ < _thisSize_,
13 | 1. Let _e_ be _O_.[[SetData]][_index_].
14 | 1. Set _index_ to _index_ + 1.
15 | 1. If _e_ is not ~empty~, then
16 | 1. Let _mappedValue_ be ? Call(_callbackfn_, _thisArg_, « _kValue_, _kValue_, _O_ »).
17 | 1. Append _mappedValue_ to _resultSetData_.
18 | 1. Let _result_ be OrdinaryObjectCreate(%Set.prototype%, « [[SetData]] »).
19 | 1. Set _result_.[[SetData]] to _resultSetData_.
20 | 1. Return _result_.
21 |
22 |
--------------------------------------------------------------------------------
/spec/set/prototype-reduce.html:
--------------------------------------------------------------------------------
1 |
2 |
When the `reduce` method is called, the following steps are taken:
3 |
4 |
5 | 1. Let _set_ be the *this* value.
6 | 1. If Type(_set_) is not Object, throw a *TypeError* exception.
7 | 1. If _set_ does not have a [[SetData]] internal slot, throw a *TypeError* exception.
8 | 1. If IsCallable(_callbackfn_) is false, throw a *TypeError* exception.
9 | 1. Let _entries_ be the List that is _set_.[[SetData]].
10 | 1. Let _accumulator_ be *undefined*
11 | 1. Let _first_ be *true*.
12 | 1. If _initialValue_ is present, then
13 | 1. Set _accumulator_ to _initialValue_
14 | 1. For each _e_ that is an element of _entries_, in original insertion order, do:
15 | 1. If _e_ is not `empty`, then
16 | 1. If _first_ be *true* and _initialValue_ is not present:
17 | 1. Set _accumulator_ to _e_
18 | 1. Else,
19 | 1. Set _accumulator_ to ? Call(_callbackfn_, undefined, « _accumulator_, _e_, _e_, _map_ »)
20 | 1. Set _first_ to *false*
21 | 1. If _first_ is *true* and _initialValue_ is not present, throw *TypeError* exception.
22 | 1. Return _accumulator_.
23 |
24 |
--------------------------------------------------------------------------------
/spec/set/prototype-remove-elements.html:
--------------------------------------------------------------------------------
1 |
2 |
When the `deleteAll` method is called, the following steps are taken:
3 |
4 |
5 | 1. Let _len_ be the actual number of arguments passed to this function.
6 | 1. Let _items_ be the List of arguments passed to this function.
7 | 1. Let _set_ be the *this* value.
8 | 1. If Type(_set_) is not Object, throw a *TypeError* exception.
9 | 1. Let _k_ be 0.
10 | 1. Let _remover_ be ? Get(_set_, "delete")
11 | 1. If IsCallable(_remover_) is *false*, throw a *TypeError* exception.
12 | 1. Let _allDeleted_ be *true*.
13 | 1. Repeat while _k_ < _len_
14 | 1. Let _value_ be _items_[_k_].
15 | 1. Let _wasDeleted_ be Call(_remover_, _set_, _value_)
16 | 1. Set `allDeleted` to be `allDeleted` && `wasDeleted`
17 | 1. Increase _k_ by 1.
18 | 1. Return ToBoolean(`allDeleted`);
19 |
20 |
21 |
--------------------------------------------------------------------------------
/spec/set/prototype-some.html:
--------------------------------------------------------------------------------
1 |
2 |
When the `some` method is called, the following steps are taken:
3 |
4 |
5 | 1. Let _set_ be the *this* value.
6 | 1. If Type(_set_) is not Object, throw a *TypeError* exception.
7 | 1. If _set_ does not have a [[SetData]] internal slot, throw a *TypeError* exception.
8 | 1. If IsCallable(_predicate_) is false, throw a *TypeError* exception.
9 | 1. Let _entries_ be _O_.[[SetData]]
10 | 1. Let _thisSize_ be the number of elements in _O_.[[SetData]].
11 | 1. Let _index_ be 0.
12 | 1. Repeat, while _index_ < _thisSize_,
13 | 1. Let _e_ be _O_.[[SetData]][_index_].
14 | 1. Set _index_ to _index_ + 1.
15 | 1. If _e_ is not ~empty~, then
16 | 1. Let _testResult_ be ToBoolean(? Call(_predicate_, _thisArg_, « _e_, _e_, _O_ »))
17 | 1. If _testResult_ is *true*, then return _testResult_
18 | 1. Return *false*.
19 |
20 |
21 |
--------------------------------------------------------------------------------
/spec/weak-map/prototype-delete-all.html:
--------------------------------------------------------------------------------
1 |
2 |
When the `deleteAll` method is called, the following steps are taken:
3 |
4 |
5 | 1. Let _len_ be the actual number of arguments passed to this function.
6 | 1. Let _items_ be the List of arguments passed to this function.
7 | 1. Let _weakmap_ be the *this* value.
8 | 1. If Type(_weakmap_) is not Object, throw a *TypeError* exception.
9 | 1. Let _k_ be 0.
10 | 1. Let _remover_ be ? Get(_weakmap_, "delete")
11 | 1. If IsCallable(_remover_) is *false*, throw a *TypeError* exception.
12 | 1. Repeat while _k_ < _len_
13 | 1. Let _value_ be _items_[_k_].
14 | 1. Call(_remover_, _weakmap_, _value_)
15 | 1. Increase _k_ by 1.
16 | 1. Return _weakmap_.
17 |
18 |
19 |
20 |
The `length` property of the `deleteAll` method is *0*.
When the `addAll` method is called, the following steps are taken:
3 |
4 |
5 | 1. Let _len_ be the actual number of arguments passed to this function.
6 | 1. Let _items_ be the List of arguments passed to this function.
7 | 1. Let _weakset_ be the *this* value.
8 | 1. If Type(_weakset_) is not Object, throw a *TypeError* exception.
9 | 1. Let _k_ be 0.
10 | 1. Let _adder_ be ? Get(_weakset_, "add")
11 | 1. If IsCallable(_adder_) is *false*, throw a *TypeError* exception.
12 | 1. Repeat while _k_ < _len_
13 | 1. Let _kValue_ be _items_[_k_].
14 | 1. Call(_adder_, _weakset_, _kValue_)
15 | 1. Increase _k_ by 1.
16 | 1. Return _weakset_.
17 |
18 |
19 |
20 |
The `length` property of the `addAll` method is *0*.
When the `deleteAll` method is called, the following steps are taken:
3 |
4 |
5 | 1. Let _len_ be the actual number of arguments passed to this function.
6 | 1. Let _items_ be the List of arguments passed to this function.
7 | 1. Let _weakset_ be the *this* value.
8 | 1. If Type(_weakset_) is not Object, throw a *TypeError* exception.
9 | 1. Let _k_ be 0.
10 | 1. Let _remover_ be ? Get(_weakset_, "delete")
11 | 1. If IsCallable(_remover_) is *false*, throw a *TypeError* exception.
12 | 1. Repeat while _k_ < _len_
13 | 1. Let _value_ be _items_[_k_].
14 | 1. Call(_remover_, _weakset_, _value_)
15 | 1. Increase _k_ by 1.
16 | 1. Return _weakset_.
17 |
18 |
19 |
20 |
The `length` property of the `deleteAll` method is *0*.
21 |
--------------------------------------------------------------------------------
/test/set/add_elements.spec.js:
--------------------------------------------------------------------------------
1 | import {assert} from 'chai';
2 |
3 | describe.skip('Set.prototype.addAll', () => {
4 | it('Should be present', () => {
5 | const set = new Set();
6 | assert.isFunction(set.addAll);
7 | assert.isFunction(Set.prototype.addAll);
8 | })
9 | })
10 |
--------------------------------------------------------------------------------
/test/set/every.spec.js:
--------------------------------------------------------------------------------
1 | import {assert} from 'chai';
2 |
3 | describe.skip('Set.prototype.every', () => {
4 | it('Should be present', () => {
5 | const set = new Set();
6 | assert.isFunction(set.every);
7 | assert.isFunction(Set.prototype.every);
8 | })
9 | })
10 |
--------------------------------------------------------------------------------
/test/set/filter.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | import {assert} from 'chai';
4 |
5 | describe.skip('Set.prototype.filter', () => {
6 | it('Should be present', () => {
7 | const set = new Set();
8 | assert.isFunction(set.filter);
9 | assert.isFunction(Set.prototype.filter);
10 | })
11 | })
12 |
--------------------------------------------------------------------------------
/test/set/find.spec.js:
--------------------------------------------------------------------------------
1 | import {assert} from 'chai';
2 |
3 | describe.skip('Set.prototype.find', () => {
4 | it('Should be present', () => {
5 | const set = new Set();
6 | assert.isFunction(set.find);
7 | assert.isFunction(Set.prototype.find);
8 | })
9 | })
10 |
--------------------------------------------------------------------------------
/test/set/map.spec.js:
--------------------------------------------------------------------------------
1 | import {assert} from 'chai';
2 |
3 | describe.skip('Set.prototype.map', () => {
4 | it('Should be present', () => {
5 | const set = new Set();
6 | assert.isFunction(set.map);
7 | assert.isFunction(Set.prototype.map);
8 | })
9 | })
10 |
--------------------------------------------------------------------------------
/test/set/reduce.spec.js:
--------------------------------------------------------------------------------
1 | import {assert} from 'chai';
2 |
3 | describe.skip('Set.prototype.reduce', () => {
4 | it('Should be present', () => {
5 | const set = new Set();
6 | assert.isFunction(set.reduce);
7 | assert.isFunction(Set.prototype.reduce);
8 | })
9 | })
10 |
--------------------------------------------------------------------------------
/test/set/remove_elements.spec.js:
--------------------------------------------------------------------------------
1 | import {assert} from 'chai';
2 |
3 | describe('Set.prototype.deleteAll', () => {
4 | it('Should be present', () => {
5 | const set = new Set();
6 | assert.isFunction(set.deleteAll);
7 | assert.isFunction(Set.prototype.deleteAll);
8 | });
9 |
10 | it('Should remove elements from Set', () => {
11 | const set = new Set([1, 2, 3]);
12 | const actual = set.deleteAll(1, 2);
13 | const expected = new Set([3]);
14 | assert.deepEqual(actual, expected);
15 | });
16 |
17 | it('Should not remove elements if they dont exist', () => {
18 | const set = new Set([1, 2, 3]);
19 | const actual = set.deleteAll(4, 5);
20 | const expected = new Set([1, 2, 3]);
21 | assert.deepEqual(actual, expected);
22 | });
23 | })
24 |
--------------------------------------------------------------------------------
/test/set/some.spec.js:
--------------------------------------------------------------------------------
1 | import {assert} from 'chai';
2 |
3 | describe.skip('Set.prototype.some', () => {
4 | it('Should be present', () => {
5 | const set = new Set();
6 | assert.isFunction(set.some);
7 | assert.isFunction(Set.prototype.some);
8 | })
9 | })
10 |
--------------------------------------------------------------------------------