diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-08-14 05:01:11 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-08-14 05:02:09 +0200 |
commit | 363723fc84f7b8477592e0105aeb331ec9a017af (patch) | |
tree | 29f92724f34131bac64d6a318dd7e30612e631c7 /node_modules/es6-set | |
parent | 5634e77ad96bfe1818f6b6ee70b7379652e5487f (diff) | |
download | wallet-core-363723fc84f7b8477592e0105aeb331ec9a017af.tar.xz |
node_modules
Diffstat (limited to 'node_modules/es6-set')
39 files changed, 932 insertions, 0 deletions
diff --git a/node_modules/es6-set/.lint b/node_modules/es6-set/.lint new file mode 100644 index 000000000..89386b35c --- /dev/null +++ b/node_modules/es6-set/.lint @@ -0,0 +1,13 @@ +@root + +module + +tabs +indent 2 +maxlen 100 + +ass +nomen +plusplus + +predef+ Set diff --git a/node_modules/es6-set/.npmignore b/node_modules/es6-set/.npmignore new file mode 100644 index 000000000..155e41f69 --- /dev/null +++ b/node_modules/es6-set/.npmignore @@ -0,0 +1,4 @@ +.DS_Store +/node_modules +/npm-debug.log +/.lintcache diff --git a/node_modules/es6-set/.travis.yml b/node_modules/es6-set/.travis.yml new file mode 100644 index 000000000..09a917c05 --- /dev/null +++ b/node_modules/es6-set/.travis.yml @@ -0,0 +1,13 @@ +sudo: false # http://docs.travis-ci.com/user/workers/container-based-infrastructure/ +language: node_js +node_js: + - 0.12 + - 4 + - 6 + - 7 + +notifications: + email: + - medikoo+es6-set@medikoo.com + +script: "npm test && npm run lint" diff --git a/node_modules/es6-set/CHANGES b/node_modules/es6-set/CHANGES new file mode 100644 index 000000000..21ad4bf30 --- /dev/null +++ b/node_modules/es6-set/CHANGES @@ -0,0 +1,34 @@ +v0.1.5 -- 2017.03.16 +* Improve documentation +* Update dependencies + +v0.1.4 -- 2016.01.19 +* Ensure Set polyfill function name is `Set` (#2) + +v0.1.3 -- 2015.11.18 +* Relax validation of native implementation (do not require proper stringification of Set.prototype) + +v0.1.2 -- 2015.10.02 +* Improve native Set detection +* Fix spelling of LICENSE +* Set.prototype.filter extension +* Update dependencies + +v0.1.1 -- 2014.10.07 +* Fix isImplemented so it validates native Set properly +* Add getFirst and getLast extensions +* Configure linter scripts + +v0.1.0 -- 2014.04.29 +* Assure strictly npm hosted dependencies +* Introduce faster 'primitive' alternative (doesn't guarantee order of iteration) +* Add isNativeImplemented, and some, every and copy method extensions +* If native Set is provided polyfill extends it +* Optimize forEach iteration +* Remove comparator support (as it was removed from spec) +* Provide @@toStringTag symbol, ad @@iterator symbols on iterators +* Update to use latest dependencies versions +* Improve interals + +v0.0.0 -- 2013.10.12 +Initial (dev) version diff --git a/node_modules/es6-set/LICENSE b/node_modules/es6-set/LICENSE new file mode 100644 index 000000000..aaf35282f --- /dev/null +++ b/node_modules/es6-set/LICENSE @@ -0,0 +1,19 @@ +Copyright (C) 2013 Mariusz Nowak (www.medikoo.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/es6-set/README.md b/node_modules/es6-set/README.md new file mode 100644 index 000000000..4ec0a005f --- /dev/null +++ b/node_modules/es6-set/README.md @@ -0,0 +1,74 @@ +# es6-set +## Set collection as specified in ECMAScript6 + +__Warning: +v0.1 version does not ensure O(1) algorithm complexity (but O(n)). This shortcoming will be addressed in v1.0__ + +### Usage + +If you want to make sure your environment implements `Set`, do: + +```javascript +require('es6-set/implement'); +``` + +If you'd like to use native version when it exists and fallback to polyfill if it doesn't, but without implementing `Set` on global scope, do: + +```javascript +var Set = require('es6-set'); +``` + +If you strictly want to use polyfill even if native `Set` exists, do: + +```javascript +var Set = require('es6-set/polyfill'); +``` + +### Installation + + $ npm install es6-set + +To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: [Browserify](http://browserify.org/), [Webmake](https://github.com/medikoo/modules-webmake) or [Webpack](http://webpack.github.io/) + +#### API + +Best is to refer to [specification](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-set-objects). Still if you want quick look, follow examples: + +```javascript +var Set = require('es6-set'); + +var set = new Set(['raz', 'dwa', {}]); + +set.size; // 3 +set.has('raz'); // true +set.has('foo'); // false +set.add('foo'); // set +set.size // 4 +set.has('foo'); // true +set.has('dwa'); // true +set.delete('dwa'); // true +set.size; // 3 + +set.forEach(function (value) { + // 'raz', {}, 'foo' iterated +}); + +// FF nightly only: +for (value of set) { + // 'raz', {}, 'foo' iterated +} + +var iterator = set.values(); + +iterator.next(); // { done: false, value: 'raz' } +iterator.next(); // { done: false, value: {} } +iterator.next(); // { done: false, value: 'foo' } +iterator.next(); // { done: true, value: undefined } + +set.clear(); // undefined +set.size; // 0 +``` + +## Tests [![Build Status](https://travis-ci.org/medikoo/es6-set.png)](https://travis-ci.org/medikoo/es6-set) + + $ npm test diff --git a/node_modules/es6-set/ext/copy.js b/node_modules/es6-set/ext/copy.js new file mode 100644 index 000000000..a8fd5c20c --- /dev/null +++ b/node_modules/es6-set/ext/copy.js @@ -0,0 +1,5 @@ +'use strict'; + +var Set = require('../'); + +module.exports = function () { return new Set(this); }; diff --git a/node_modules/es6-set/ext/every.js b/node_modules/es6-set/ext/every.js new file mode 100644 index 000000000..ea64ebc56 --- /dev/null +++ b/node_modules/es6-set/ext/every.js @@ -0,0 +1,18 @@ +'use strict'; + +var callable = require('es5-ext/object/valid-callable') + , forOf = require('es6-iterator/for-of') + + , call = Function.prototype.call; + +module.exports = function (cb/*, thisArg*/) { + var thisArg = arguments[1], result = true; + callable(cb); + forOf(this, function (value, doBreak) { + if (!call.call(cb, thisArg, value)) { + result = false; + doBreak(); + } + }); + return result; +}; diff --git a/node_modules/es6-set/ext/filter.js b/node_modules/es6-set/ext/filter.js new file mode 100644 index 000000000..1178fc591 --- /dev/null +++ b/node_modules/es6-set/ext/filter.js @@ -0,0 +1,18 @@ +'use strict'; + +var callable = require('es5-ext/object/valid-callable') + , forOf = require('es6-iterator/for-of') + , isSet = require('../is-set') + , Set = require('../') + + , call = Function.prototype.call; + +module.exports = function (cb/*, thisArg*/) { + var thisArg = arguments[1], result; + callable(cb); + result = isSet(this) ? new this.constructor() : new Set(); + forOf(this, function (value) { + if (call.call(cb, thisArg, value)) result.add(value); + }); + return result; +}; diff --git a/node_modules/es6-set/ext/get-first.js b/node_modules/es6-set/ext/get-first.js new file mode 100644 index 000000000..b5d89fc13 --- /dev/null +++ b/node_modules/es6-set/ext/get-first.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function () { + return this.values().next().value; +}; diff --git a/node_modules/es6-set/ext/get-last.js b/node_modules/es6-set/ext/get-last.js new file mode 100644 index 000000000..d22ce737b --- /dev/null +++ b/node_modules/es6-set/ext/get-last.js @@ -0,0 +1,11 @@ +'use strict'; + +module.exports = function () { + var value, iterator = this.values(), item; + while (true) { + item = iterator.next(); + if (item.done) break; + value = item.value; + } + return value; +}; diff --git a/node_modules/es6-set/ext/some.js b/node_modules/es6-set/ext/some.js new file mode 100644 index 000000000..400a5a0c6 --- /dev/null +++ b/node_modules/es6-set/ext/some.js @@ -0,0 +1,18 @@ +'use strict'; + +var callable = require('es5-ext/object/valid-callable') + , forOf = require('es6-iterator/for-of') + + , call = Function.prototype.call; + +module.exports = function (cb/*, thisArg*/) { + var thisArg = arguments[1], result = false; + callable(cb); + forOf(this, function (value, doBreak) { + if (call.call(cb, thisArg, value)) { + result = true; + doBreak(); + } + }); + return result; +}; diff --git a/node_modules/es6-set/implement.js b/node_modules/es6-set/implement.js new file mode 100644 index 000000000..f03362e08 --- /dev/null +++ b/node_modules/es6-set/implement.js @@ -0,0 +1,7 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(require('es5-ext/global'), 'Set', + { value: require('./polyfill'), configurable: true, enumerable: false, + writable: true }); +} diff --git a/node_modules/es6-set/index.js b/node_modules/es6-set/index.js new file mode 100644 index 000000000..daa788619 --- /dev/null +++ b/node_modules/es6-set/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./is-implemented')() ? Set : require('./polyfill'); diff --git a/node_modules/es6-set/is-implemented.js b/node_modules/es6-set/is-implemented.js new file mode 100644 index 000000000..7f1bfbb7c --- /dev/null +++ b/node_modules/es6-set/is-implemented.js @@ -0,0 +1,24 @@ +'use strict'; + +module.exports = function () { + var set, iterator, result; + if (typeof Set !== 'function') return false; + set = new Set(['raz', 'dwa', 'trzy']); + if (String(set) !== '[object Set]') return false; + if (set.size !== 3) return false; + if (typeof set.add !== 'function') return false; + if (typeof set.clear !== 'function') return false; + if (typeof set.delete !== 'function') return false; + if (typeof set.entries !== 'function') return false; + if (typeof set.forEach !== 'function') return false; + if (typeof set.has !== 'function') return false; + if (typeof set.keys !== 'function') return false; + if (typeof set.values !== 'function') return false; + + iterator = set.values(); + result = iterator.next(); + if (result.done !== false) return false; + if (result.value !== 'raz') return false; + + return true; +}; diff --git a/node_modules/es6-set/is-native-implemented.js b/node_modules/es6-set/is-native-implemented.js new file mode 100644 index 000000000..e8b0160ec --- /dev/null +++ b/node_modules/es6-set/is-native-implemented.js @@ -0,0 +1,9 @@ +// Exports true if environment provides native `Set` implementation, +// whatever that is. + +'use strict'; + +module.exports = (function () { + if (typeof Set === 'undefined') return false; + return (Object.prototype.toString.call(Set.prototype) === '[object Set]'); +}()); diff --git a/node_modules/es6-set/is-set.js b/node_modules/es6-set/is-set.js new file mode 100644 index 000000000..6b491ddee --- /dev/null +++ b/node_modules/es6-set/is-set.js @@ -0,0 +1,12 @@ +'use strict'; + +var toString = Object.prototype.toString + , toStringTagSymbol = require('es6-symbol').toStringTag + + , id = '[object Set]' + , Global = (typeof Set === 'undefined') ? null : Set; + +module.exports = function (x) { + return (x && ((Global && ((x instanceof Global) || (x === Global.prototype))) || + (toString.call(x) === id) || (x[toStringTagSymbol] === 'Set'))) || false; +}; diff --git a/node_modules/es6-set/lib/iterator.js b/node_modules/es6-set/lib/iterator.js new file mode 100644 index 000000000..6069a8a13 --- /dev/null +++ b/node_modules/es6-set/lib/iterator.js @@ -0,0 +1,30 @@ +'use strict'; + +var setPrototypeOf = require('es5-ext/object/set-prototype-of') + , contains = require('es5-ext/string/#/contains') + , d = require('d') + , Iterator = require('es6-iterator') + , toStringTagSymbol = require('es6-symbol').toStringTag + + , defineProperty = Object.defineProperty + , SetIterator; + +SetIterator = module.exports = function (set, kind) { + if (!(this instanceof SetIterator)) return new SetIterator(set, kind); + Iterator.call(this, set.__setData__, set); + if (!kind) kind = 'value'; + else if (contains.call(kind, 'key+value')) kind = 'key+value'; + else kind = 'value'; + defineProperty(this, '__kind__', d('', kind)); +}; +if (setPrototypeOf) setPrototypeOf(SetIterator, Iterator); + +SetIterator.prototype = Object.create(Iterator.prototype, { + constructor: d(SetIterator), + _resolve: d(function (i) { + if (this.__kind__ === 'value') return this.__list__[i]; + return [this.__list__[i], this.__list__[i]]; + }), + toString: d(function () { return '[object Set Iterator]'; }) +}); +defineProperty(SetIterator.prototype, toStringTagSymbol, d('c', 'Set Iterator')); diff --git a/node_modules/es6-set/lib/primitive-iterator.js b/node_modules/es6-set/lib/primitive-iterator.js new file mode 100644 index 000000000..1f0326a3b --- /dev/null +++ b/node_modules/es6-set/lib/primitive-iterator.js @@ -0,0 +1,53 @@ +'use strict'; + +var clear = require('es5-ext/array/#/clear') + , assign = require('es5-ext/object/assign') + , setPrototypeOf = require('es5-ext/object/set-prototype-of') + , contains = require('es5-ext/string/#/contains') + , d = require('d') + , autoBind = require('d/auto-bind') + , Iterator = require('es6-iterator') + , toStringTagSymbol = require('es6-symbol').toStringTag + + , defineProperties = Object.defineProperties, keys = Object.keys + , unBind = Iterator.prototype._unBind + , PrimitiveSetIterator; + +PrimitiveSetIterator = module.exports = function (set, kind) { + if (!(this instanceof PrimitiveSetIterator)) { + return new PrimitiveSetIterator(set, kind); + } + Iterator.call(this, keys(set.__setData__), set); + kind = (!kind || !contains.call(kind, 'key+value')) ? 'value' : 'key+value'; + defineProperties(this, { + __kind__: d('', kind), + __data__: d('w', set.__setData__) + }); +}; +if (setPrototypeOf) setPrototypeOf(PrimitiveSetIterator, Iterator); + +PrimitiveSetIterator.prototype = Object.create(Iterator.prototype, assign({ + constructor: d(PrimitiveSetIterator), + _resolve: d(function (i) { + var value = this.__data__[this.__list__[i]]; + return (this.__kind__ === 'value') ? value : [value, value]; + }), + _unBind: d(function () { + this.__data__ = null; + unBind.call(this); + }), + toString: d(function () { return '[object Set Iterator]'; }) +}, autoBind({ + _onAdd: d(function (key) { this.__list__.push(key); }), + _onDelete: d(function (key) { + var index = this.__list__.lastIndexOf(key); + if (index < this.__nextIndex__) return; + this.__list__.splice(index, 1); + }), + _onClear: d(function () { + clear.call(this.__list__); + this.__nextIndex__ = 0; + }) +}))); +Object.defineProperty(PrimitiveSetIterator.prototype, toStringTagSymbol, + d('c', 'Set Iterator')); diff --git a/node_modules/es6-set/package.json b/node_modules/es6-set/package.json new file mode 100644 index 000000000..e56baf2f5 --- /dev/null +++ b/node_modules/es6-set/package.json @@ -0,0 +1,36 @@ +{ + "name": "es6-set", + "version": "0.1.5", + "description": "ECMAScript6 Set polyfill", + "author": "Mariusz Nowak <medyk@medikoo.com> (http://www.medikoo.com/)", + "keywords": [ + "set", + "collection", + "es6", + "harmony", + "list", + "hash" + ], + "repository": { + "type": "git", + "url": "git://github.com/medikoo/es6-set.git" + }, + "dependencies": { + "d": "1", + "es5-ext": "~0.10.14", + "es6-iterator": "~2.0.1", + "es6-symbol": "3.1.1", + "event-emitter": "~0.3.5" + }, + "devDependencies": { + "tad": "~0.2.7", + "xlint": "~0.2.2", + "xlint-jslint-medikoo": "~0.1.4" + }, + "scripts": { + "lint": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --no-cache --no-stream", + "lint-console": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --watch", + "test": "node ./node_modules/tad/bin/tad" + }, + "license": "MIT" +} diff --git a/node_modules/es6-set/polyfill.js b/node_modules/es6-set/polyfill.js new file mode 100644 index 000000000..51b1e6307 --- /dev/null +++ b/node_modules/es6-set/polyfill.js @@ -0,0 +1,80 @@ +'use strict'; + +var clear = require('es5-ext/array/#/clear') + , eIndexOf = require('es5-ext/array/#/e-index-of') + , setPrototypeOf = require('es5-ext/object/set-prototype-of') + , callable = require('es5-ext/object/valid-callable') + , d = require('d') + , ee = require('event-emitter') + , Symbol = require('es6-symbol') + , iterator = require('es6-iterator/valid-iterable') + , forOf = require('es6-iterator/for-of') + , Iterator = require('./lib/iterator') + , isNative = require('./is-native-implemented') + + , call = Function.prototype.call + , defineProperty = Object.defineProperty, getPrototypeOf = Object.getPrototypeOf + , SetPoly, getValues, NativeSet; + +if (isNative) NativeSet = Set; + +module.exports = SetPoly = function Set(/*iterable*/) { + var iterable = arguments[0], self; + if (!(this instanceof SetPoly)) throw new TypeError('Constructor requires \'new\''); + if (isNative && setPrototypeOf) self = setPrototypeOf(new NativeSet(), getPrototypeOf(this)); + else self = this; + if (iterable != null) iterator(iterable); + defineProperty(self, '__setData__', d('c', [])); + if (!iterable) return self; + forOf(iterable, function (value) { + if (eIndexOf.call(this, value) !== -1) return; + this.push(value); + }, self.__setData__); + return self; +}; + +if (isNative) { + if (setPrototypeOf) setPrototypeOf(SetPoly, NativeSet); + SetPoly.prototype = Object.create(NativeSet.prototype, { constructor: d(SetPoly) }); +} + +ee(Object.defineProperties(SetPoly.prototype, { + add: d(function (value) { + if (this.has(value)) return this; + this.emit('_add', this.__setData__.push(value) - 1, value); + return this; + }), + clear: d(function () { + if (!this.__setData__.length) return; + clear.call(this.__setData__); + this.emit('_clear'); + }), + delete: d(function (value) { + var index = eIndexOf.call(this.__setData__, value); + if (index === -1) return false; + this.__setData__.splice(index, 1); + this.emit('_delete', index, value); + return true; + }), + entries: d(function () { return new Iterator(this, 'key+value'); }), + forEach: d(function (cb/*, thisArg*/) { + var thisArg = arguments[1], iterator, result, value; + callable(cb); + iterator = this.values(); + result = iterator._next(); + while (result !== undefined) { + value = iterator._resolve(result); + call.call(cb, thisArg, value, value, this); + result = iterator._next(); + } + }), + has: d(function (value) { + return (eIndexOf.call(this.__setData__, value) !== -1); + }), + keys: d(getValues = function () { return this.values(); }), + size: d.gs(function () { return this.__setData__.length; }), + values: d(function () { return new Iterator(this); }), + toString: d(function () { return '[object Set]'; }) +})); +defineProperty(SetPoly.prototype, Symbol.iterator, d(getValues)); +defineProperty(SetPoly.prototype, Symbol.toStringTag, d('c', 'Set')); diff --git a/node_modules/es6-set/primitive/index.js b/node_modules/es6-set/primitive/index.js new file mode 100644 index 000000000..6bcad18d3 --- /dev/null +++ b/node_modules/es6-set/primitive/index.js @@ -0,0 +1,87 @@ +'use strict'; + +var callable = require('es5-ext/object/valid-callable') + , clear = require('es5-ext/object/clear') + , setPrototypeOf = require('es5-ext/object/set-prototype-of') + , d = require('d') + , iterator = require('es6-iterator/valid-iterable') + , forOf = require('es6-iterator/for-of') + , Set = require('../polyfill') + , Iterator = require('../lib/primitive-iterator') + , isNative = require('../is-native-implemented') + + , create = Object.create, defineProperties = Object.defineProperties + , defineProperty = Object.defineProperty, getPrototypeOf = Object.getPrototypeOf + , hasOwnProperty = Object.prototype.hasOwnProperty + , PrimitiveSet; + +module.exports = PrimitiveSet = function (/*iterable, serialize*/) { + var iterable = arguments[0], serialize = arguments[1], self; + if (!(this instanceof PrimitiveSet)) throw new TypeError('Constructor requires \'new\''); + if (isNative && setPrototypeOf) self = setPrototypeOf(new Set(), getPrototypeOf(this)); + else self = this; + if (iterable != null) iterator(iterable); + if (serialize !== undefined) { + callable(serialize); + defineProperty(self, '_serialize', d('', serialize)); + } + defineProperties(self, { + __setData__: d('c', create(null)), + __size__: d('w', 0) + }); + if (!iterable) return self; + forOf(iterable, function (value) { + var key = self._serialize(value); + if (key == null) throw new TypeError(value + " cannot be serialized"); + if (hasOwnProperty.call(self.__setData__, key)) return; + self.__setData__[key] = value; + ++self.__size__; + }); + return self; +}; +if (setPrototypeOf) setPrototypeOf(PrimitiveSet, Set); + +PrimitiveSet.prototype = create(Set.prototype, { + constructor: d(PrimitiveSet), + _serialize: d(function (value) { + if (value && (typeof value.toString !== 'function')) return null; + return String(value); + }), + add: d(function (value) { + var key = this._serialize(value); + if (key == null) throw new TypeError(value + " cannot be serialized"); + if (hasOwnProperty.call(this.__setData__, key)) return this; + this.__setData__[key] = value; + ++this.__size__; + this.emit('_add', key); + return this; + }), + clear: d(function () { + if (!this.__size__) return; + clear(this.__setData__); + this.__size__ = 0; + this.emit('_clear'); + }), + delete: d(function (value) { + var key = this._serialize(value); + if (key == null) return false; + if (!hasOwnProperty.call(this.__setData__, key)) return false; + delete this.__setData__[key]; + --this.__size__; + this.emit('_delete', key); + return true; + }), + entries: d(function () { return new Iterator(this, 'key+value'); }), + get: d(function (key) { + key = this._serialize(key); + if (key == null) return; + return this.__setData__[key]; + }), + has: d(function (value) { + var key = this._serialize(value); + if (key == null) return false; + return hasOwnProperty.call(this.__setData__, key); + }), + size: d.gs(function () { return this.__size__; }), + values: d(function () { return new Iterator(this); }) +}); diff --git a/node_modules/es6-set/test/ext/copy.js b/node_modules/es6-set/test/ext/copy.js new file mode 100644 index 000000000..84fe912a3 --- /dev/null +++ b/node_modules/es6-set/test/ext/copy.js @@ -0,0 +1,12 @@ +'use strict'; + +var toArray = require('es5-ext/array/to-array') + , Set = require('../../'); + +module.exports = function (t, a) { + var content = ['raz', 2, true], set = new Set(content), copy; + + copy = t.call(set); + a.not(copy, set, "Copy"); + a.deep(toArray(copy), content, "Content"); +}; diff --git a/node_modules/es6-set/test/ext/every.js b/node_modules/es6-set/test/ext/every.js new file mode 100644 index 000000000..f56ca385f --- /dev/null +++ b/node_modules/es6-set/test/ext/every.js @@ -0,0 +1,9 @@ +'use strict'; + +var Set = require('../../'); + +module.exports = function (t, a) { + a(t.call(new Set(), Boolean), true, "Empty set"); + a(t.call(new Set([2, 3, 4]), Boolean), true, "Truthy"); + a(t.call(new Set([2, 0, 4]), Boolean), false, "Falsy"); +}; diff --git a/node_modules/es6-set/test/ext/filter.js b/node_modules/es6-set/test/ext/filter.js new file mode 100644 index 000000000..46981859b --- /dev/null +++ b/node_modules/es6-set/test/ext/filter.js @@ -0,0 +1,12 @@ +'use strict'; + +var aFrom = require('es5-ext/array/from') + + , Set = require('../../'); + +module.exports = function (t, a) { + a.deep(aFrom(t.call(new Set(), Boolean)), [], "Empty set"); + a.deep(aFrom(t.call(new Set([2, 3, 4]), Boolean)), [2, 3, 4], "All true"); + a.deep(aFrom(t.call(new Set([0, false, 4]), Boolean)), [4], "Some false"); + a.deep(aFrom(t.call(new Set([0, false, null]), Boolean)), [], "All false"); +}; diff --git a/node_modules/es6-set/test/ext/get-first.js b/node_modules/es6-set/test/ext/get-first.js new file mode 100644 index 000000000..f99829e5a --- /dev/null +++ b/node_modules/es6-set/test/ext/get-first.js @@ -0,0 +1,12 @@ +'use strict'; + +var Set = require('../../'); + +module.exports = function (t, a) { + var content = ['raz', 2, true], set = new Set(content); + + a(t.call(set), 'raz'); + + set = new Set(); + a(t.call(set), undefined); +}; diff --git a/node_modules/es6-set/test/ext/get-last.js b/node_modules/es6-set/test/ext/get-last.js new file mode 100644 index 000000000..1dcc993ed --- /dev/null +++ b/node_modules/es6-set/test/ext/get-last.js @@ -0,0 +1,12 @@ +'use strict'; + +var Set = require('../../'); + +module.exports = function (t, a) { + var content = ['raz', 2, true], set = new Set(content); + + a(t.call(set), true); + + set = new Set(); + a(t.call(set), undefined); +}; diff --git a/node_modules/es6-set/test/ext/some.js b/node_modules/es6-set/test/ext/some.js new file mode 100644 index 000000000..84ce11916 --- /dev/null +++ b/node_modules/es6-set/test/ext/some.js @@ -0,0 +1,10 @@ +'use strict'; + +var Set = require('../../'); + +module.exports = function (t, a) { + a(t.call(new Set(), Boolean), false, "Empty set"); + a(t.call(new Set([2, 3, 4]), Boolean), true, "All true"); + a(t.call(new Set([0, false, 4]), Boolean), true, "Some false"); + a(t.call(new Set([0, false, null]), Boolean), false, "All false"); +}; diff --git a/node_modules/es6-set/test/implement.js b/node_modules/es6-set/test/implement.js new file mode 100644 index 000000000..4882d3786 --- /dev/null +++ b/node_modules/es6-set/test/implement.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof Set, 'function'); }; diff --git a/node_modules/es6-set/test/index.js b/node_modules/es6-set/test/index.js new file mode 100644 index 000000000..19c648650 --- /dev/null +++ b/node_modules/es6-set/test/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (T, a) { a((new T(['raz', 'dwa'])).size, 2); }; diff --git a/node_modules/es6-set/test/is-implemented.js b/node_modules/es6-set/test/is-implemented.js new file mode 100644 index 000000000..124793e73 --- /dev/null +++ b/node_modules/es6-set/test/is-implemented.js @@ -0,0 +1,14 @@ +'use strict'; + +var global = require('es5-ext/global') + , polyfill = require('../polyfill'); + +module.exports = function (t, a) { + var cache; + a(typeof t(), 'boolean'); + cache = global.Set; + global.Set = polyfill; + a(t(), true); + if (cache === undefined) delete global.Set; + else global.Set = cache; +}; diff --git a/node_modules/es6-set/test/is-native-implemented.js b/node_modules/es6-set/test/is-native-implemented.js new file mode 100644 index 000000000..df8ba0323 --- /dev/null +++ b/node_modules/es6-set/test/is-native-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t, 'boolean'); }; diff --git a/node_modules/es6-set/test/is-set.js b/node_modules/es6-set/test/is-set.js new file mode 100644 index 000000000..c969cce23 --- /dev/null +++ b/node_modules/es6-set/test/is-set.js @@ -0,0 +1,16 @@ +'use strict'; + +var SetPoly = require('../polyfill'); + +module.exports = function (t, a) { + a(t(undefined), false, "Undefined"); + a(t(null), false, "Null"); + a(t(true), false, "Primitive"); + a(t('raz'), false, "String"); + a(t({}), false, "Object"); + a(t([]), false, "Array"); + if (typeof Set !== 'undefined') { + a(t(new Set()), true, "Native"); + } + a(t(new SetPoly()), true, "Polyfill"); +}; diff --git a/node_modules/es6-set/test/lib/iterator.js b/node_modules/es6-set/test/lib/iterator.js new file mode 100644 index 000000000..9e5cfb91b --- /dev/null +++ b/node_modules/es6-set/test/lib/iterator.js @@ -0,0 +1,13 @@ +'use strict'; + +var Set = require('../../polyfill') + , toArray = require('es5-ext/array/to-array'); + +module.exports = function (T, a) { + var set = new Set(['raz', 'dwa']); + + a.deep(toArray(new T(set)), ['raz', 'dwa'], "Default"); + a.deep(toArray(new T(set, 'key+value')), [['raz', 'raz'], ['dwa', 'dwa']], + "Key & Value"); + a.deep(toArray(new T(set, 'value')), ['raz', 'dwa'], "Other"); +}; diff --git a/node_modules/es6-set/test/lib/primitive-iterator.js b/node_modules/es6-set/test/lib/primitive-iterator.js new file mode 100644 index 000000000..2a4956b80 --- /dev/null +++ b/node_modules/es6-set/test/lib/primitive-iterator.js @@ -0,0 +1,113 @@ +'use strict'; + +var Set = require('../../primitive') + , toArray = require('es5-ext/array/to-array') + , iteratorSymbol = require('es6-symbol').iterator + + , compare, map; + +compare = function (a, b) { + if (!a.value) return -1; + if (!b.value) return 1; + return a.value.localeCompare(b.value); +}; + +map = function (arr) { + return arr.sort().map(function (value) { + return { done: false, value: value }; + }); +}; + +module.exports = function (T) { + return { + "": function (a) { + var arr = ['raz', 'dwa', 'trzy', 'cztery', 'pięć'], it, y, z + , set = new Set(arr), result = []; + + it = new T(set); + a(it[iteratorSymbol](), it, "@@iterator"); + y = it.next(); + result.push(y); + z = it.next(); + a.not(y, z, "Recreate result"); + result.push(z); + result.push(it.next()); + result.push(it.next()); + result.push(it.next()); + a.deep(result.sort(compare), map(arr)); + a.deep(y = it.next(), { done: true, value: undefined }, "End"); + a.not(y, it.next(), "Recreate result on dead"); + }, + Emited: function (a) { + var arr = ['raz', 'dwa', 'trzy', 'cztery', 'pięć'], it + , set = new Set(arr), result = []; + + it = new T(set); + result.push(it.next()); + result.push(it.next()); + set.add('sześć'); + arr.push('sześć'); + result.push(it.next()); + set.delete('pięć'); + arr.splice(4, 1); + result.push(it.next()); + result.push(it.next()); + a.deep(result.sort(compare), map(arr)); + a.deep(it.next(), { done: true, value: undefined }, "End"); + }, + "Emited #2": function (a) { + var arr = ['raz', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć'], it + , set = new Set(arr), result = []; + + it = new T(set); + result.push(it.next()); + result.push(it.next()); + set.add('siedem'); + set.delete('siedem'); + result.push(it.next()); + result.push(it.next()); + set.delete('pięć'); + arr.splice(4, 1); + result.push(it.next()); + a.deep(result.sort(compare), map(arr)); + a.deep(it.next(), { done: true, value: undefined }, "End"); + }, + "Emited: Clear #1": function (a) { + var arr = ['raz', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć'], it + , set = new Set(arr), result = []; + + it = new T(set); + result.push(it.next()); + result.push(it.next()); + arr = ['raz', 'dwa']; + set.clear(); + a.deep(result.sort(compare), map(arr)); + a.deep(it.next(), { done: true, value: undefined }, "End"); + }, + "Emited: Clear #2": function (a) { + var arr = ['raz', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć'], it + , set = new Set(arr), result = []; + + it = new T(set); + result.push(it.next()); + result.push(it.next()); + set.clear(); + set.add('foo'); + set.add('bar'); + arr = ['raz', 'dwa', 'foo', 'bar']; + result.push(it.next()); + result.push(it.next()); + a.deep(result.sort(compare), map(arr)); + a.deep(it.next(), { done: true, value: undefined }, "End"); + }, + Kinds: function (a) { + var set = new Set(['raz', 'dwa']); + + a.deep(toArray(new T(set)).sort(), ['raz', 'dwa'].sort(), "Default"); + a.deep(toArray(new T(set, 'key+value')).sort(), + [['raz', 'raz'], ['dwa', 'dwa']].sort(), "Key & Value"); + a.deep(toArray(new T(set, 'value')).sort(), ['raz', 'dwa'].sort(), + "Other"); + } + }; +}; diff --git a/node_modules/es6-set/test/polyfill.js b/node_modules/es6-set/test/polyfill.js new file mode 100644 index 000000000..94ae3e6e6 --- /dev/null +++ b/node_modules/es6-set/test/polyfill.js @@ -0,0 +1,50 @@ +'use strict'; + +var aFrom = require('es5-ext/array/from') + , toArray = require('es5-ext/array/to-array'); + +module.exports = function (T, a) { + var arr = ['raz', 'dwa', 'trzy'], set = new T(arr), x = {}, y = {}, i = 0; + + a(set instanceof T, true, "Set"); + a(set.size, 3, "Size"); + a(set.has('raz'), true, "Has: true"); + a(set.has(x), false, "Has: false"); + a(set.add(x), set, "Add: return"); + a(set.has(x), true, "Add"); + a(set.size, 4, "Add: Size"); + a(set.delete({}), false, "Delete: false"); + + arr.push(x); + set.forEach(function () { + a.deep(aFrom(arguments), [arr[i], arr[i], set], + "ForEach: Arguments: #" + i); + a(this, y, "ForEach: Context: #" + i); + if (i === 0) { + a(set.delete('raz'), true, "Delete: true"); + a(set.has('raz'), false, "Delete"); + a(set.size, 3, "Delete: size"); + set.add('cztery'); + arr.push('cztery'); + } + i++; + }, y); + arr.splice(0, 1); + + a.deep(toArray(set.entries()), [['dwa', 'dwa'], ['trzy', 'trzy'], [x, x], + ['cztery', 'cztery']], "Entries"); + a.deep(toArray(set.keys()), ['dwa', 'trzy', x, 'cztery'], "Keys"); + a.deep(toArray(set.values()), ['dwa', 'trzy', x, 'cztery'], "Values"); + a.deep(toArray(set), ['dwa', 'trzy', x, 'cztery'], "Iterator"); + + set.clear(); + a(set.size, 0, "Clear: size"); + a(set.has('trzy'), false, "Clear: has"); + a.deep(toArray(set), [], "Clear: Values"); + + a.h1("Empty initialization"); + set = new T(); + set.add('foo'); + a(set.size, 1); + a(set.has('foo'), true); +}; diff --git a/node_modules/es6-set/test/primitive/index.js b/node_modules/es6-set/test/primitive/index.js new file mode 100644 index 000000000..88f9502fd --- /dev/null +++ b/node_modules/es6-set/test/primitive/index.js @@ -0,0 +1,50 @@ +'use strict'; + +var aFrom = require('es5-ext/array/from') + , getIterator = require('es6-iterator/get') + , toArray = require('es5-ext/array/to-array'); + +module.exports = function (T, a) { + var arr = ['raz', 'dwa', 'trzy'], set = new T(arr), x = 'other', y = 'other2' + , i = 0, result = []; + + a(set instanceof T, true, "Set"); + a(set.size, 3, "Size"); + a(set.has('raz'), true, "Has: true"); + a(set.has(x), false, "Has: false"); + a(set.add(x), set, "Add: return"); + a(set.has(x), true, "Add"); + a(set.size, 4, "Add: Size"); + a(set.delete('else'), false, "Delete: false"); + a(set.get('raz'), 'raz', "Get"); + + arr.push(x); + set.forEach(function () { + result.push(aFrom(arguments)); + a(this, y, "ForEach: Context: #" + i); + }, y); + + a.deep(result.sort(function (a, b) { + return a[0].localeCompare(b[0]); + }), arr.sort().map(function (val) { return [val, val, set]; })); + + a.deep(toArray(set.entries()).sort(), [['dwa', 'dwa'], ['trzy', 'trzy'], + [x, x], ['raz', 'raz']].sort(), "Entries"); + a.deep(toArray(set.keys()).sort(), ['dwa', 'trzy', x, 'raz'].sort(), + "Keys"); + a.deep(toArray(set.values()).sort(), ['dwa', 'trzy', x, 'raz'].sort(), + "Values"); + a.deep(toArray(getIterator(set)).sort(), ['dwa', 'trzy', x, 'raz'].sort(), + "Iterator"); + + set.clear(); + a(set.size, 0, "Clear: size"); + a(set.has('trzy'), false, "Clear: has"); + a.deep(toArray(set.values()), [], "Clear: Values"); + + a.h1("Empty initialization"); + set = new T(); + set.add('foo'); + a(set.size, 1); + a(set.has('foo'), true); +}; diff --git a/node_modules/es6-set/test/valid-set.js b/node_modules/es6-set/test/valid-set.js new file mode 100644 index 000000000..8c71f5f8c --- /dev/null +++ b/node_modules/es6-set/test/valid-set.js @@ -0,0 +1,19 @@ +'use strict'; + +var SetPoly = require('../polyfill'); + +module.exports = function (t, a) { + var set; + a.throws(function () { t(undefined); }, TypeError, "Undefined"); + a.throws(function () { t(null); }, TypeError, "Null"); + a.throws(function () { t(true); }, TypeError, "Primitive"); + a.throws(function () { t('raz'); }, TypeError, "String"); + a.throws(function () { t({}); }, TypeError, "Object"); + a.throws(function () { t([]); }, TypeError, "Array"); + if (typeof Set !== 'undefined') { + set = new Set(); + a(t(set), set, "Native"); + } + set = new SetPoly(); + a(t(set), set, "Polyfill"); +}; diff --git a/node_modules/es6-set/valid-set.js b/node_modules/es6-set/valid-set.js new file mode 100644 index 000000000..9336fd355 --- /dev/null +++ b/node_modules/es6-set/valid-set.js @@ -0,0 +1,8 @@ +'use strict'; + +var isSet = require('./is-set'); + +module.exports = function (x) { + if (!isSet(x)) throw new TypeError(x + " is not a Set"); + return x; +}; |