aboutsummaryrefslogtreecommitdiff
path: root/node_modules/es6-weak-map
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-08-14 05:01:11 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-08-14 05:02:09 +0200
commit363723fc84f7b8477592e0105aeb331ec9a017af (patch)
tree29f92724f34131bac64d6a318dd7e30612e631c7 /node_modules/es6-weak-map
parent5634e77ad96bfe1818f6b6ee70b7379652e5487f (diff)
downloadwallet-core-363723fc84f7b8477592e0105aeb331ec9a017af.tar.xz
node_modules
Diffstat (limited to 'node_modules/es6-weak-map')
-rw-r--r--node_modules/es6-weak-map/.lint13
-rw-r--r--node_modules/es6-weak-map/.npmignore4
-rw-r--r--node_modules/es6-weak-map/.travis.yml13
-rw-r--r--node_modules/es6-weak-map/CHANGES45
-rw-r--r--node_modules/es6-weak-map/LICENSE19
-rw-r--r--node_modules/es6-weak-map/README.md63
-rw-r--r--node_modules/es6-weak-map/implement.js7
-rw-r--r--node_modules/es6-weak-map/index.js3
-rw-r--r--node_modules/es6-weak-map/is-implemented.js20
-rw-r--r--node_modules/es6-weak-map/is-native-implemented.js8
-rw-r--r--node_modules/es6-weak-map/is-weak-map.js13
-rw-r--r--node_modules/es6-weak-map/package.json38
-rw-r--r--node_modules/es6-weak-map/polyfill.js66
-rw-r--r--node_modules/es6-weak-map/test/implement.js3
-rw-r--r--node_modules/es6-weak-map/test/index.js6
-rw-r--r--node_modules/es6-weak-map/test/is-implemented.js14
-rw-r--r--node_modules/es6-weak-map/test/is-native-implemented.js3
-rw-r--r--node_modules/es6-weak-map/test/is-weak-map.js16
-rw-r--r--node_modules/es6-weak-map/test/polyfill.js23
-rw-r--r--node_modules/es6-weak-map/test/valid-weak-map.js19
-rw-r--r--node_modules/es6-weak-map/valid-weak-map.js8
21 files changed, 404 insertions, 0 deletions
diff --git a/node_modules/es6-weak-map/.lint b/node_modules/es6-weak-map/.lint
new file mode 100644
index 000000000..3c9ef8da0
--- /dev/null
+++ b/node_modules/es6-weak-map/.lint
@@ -0,0 +1,13 @@
+@root
+
+module
+
+tabs
+indent 2
+maxlen 100
+
+ass
+nomen
+plusplus
+
+predef+ WeakMap
diff --git a/node_modules/es6-weak-map/.npmignore b/node_modules/es6-weak-map/.npmignore
new file mode 100644
index 000000000..155e41f69
--- /dev/null
+++ b/node_modules/es6-weak-map/.npmignore
@@ -0,0 +1,4 @@
+.DS_Store
+/node_modules
+/npm-debug.log
+/.lintcache
diff --git a/node_modules/es6-weak-map/.travis.yml b/node_modules/es6-weak-map/.travis.yml
new file mode 100644
index 000000000..d367a799e
--- /dev/null
+++ b/node_modules/es6-weak-map/.travis.yml
@@ -0,0 +1,13 @@
+sudo: false # use faster docker infrastructure
+language: node_js
+node_js:
+ - 0.12
+ - 4
+ - 6
+ - 7
+
+notifications:
+ email:
+ - medikoo+es6-weak-map@medikoo.com
+
+script: "npm test && npm run lint"
diff --git a/node_modules/es6-weak-map/CHANGES b/node_modules/es6-weak-map/CHANGES
new file mode 100644
index 000000000..7772891f1
--- /dev/null
+++ b/node_modules/es6-weak-map/CHANGES
@@ -0,0 +1,45 @@
+v2.0.2 -- 2017.03.15
+* Update dependencies
+
+v2.0.1 -- 2015.10.02
+* Update to use es6-symbol at v3
+
+v2.0.0 -- 2015.09.04
+* Relax native implementation detection, stringification of instance should returm
+ expected result (not necesarily prototype)
+
+v1.0.2 -- 2015.05.07
+* Add "ponyfill" keyword to meta description. Fixes #7
+
+v1.0.1 -- 2015.04.14
+* Fix isNativeImplemented, so it's not affected by #3619 V8 bug
+* Fix internal prototype resolution, in case where isNativeImplemented was true, and
+ native implementation was shadowed it got into stack overflow
+
+v1.0.0 -- 2015.04.13
+* It's v0.1.3 republished as v1.0.0
+
+v0.1.4 -- 2015.04.13
+* Republish v0.1.2 as v0.1.4 due to breaking changes
+ (v0.1.3 should have been published as next major)
+
+v0.1.3 -- 2015.04.12
+* Update up to changes in specification (require new, remove clear method)
+* Improve native implementation validation
+* Configure lint scripts
+* Rename LICENCE to LICENSE
+
+v0.1.2 -- 2014.09.01
+* Use internal random and unique id generator instead of external (time-uuid based).
+ Global uniqueness is not needed in scope of this module. Fixes #1
+
+v0.1.1 -- 2014.05.15
+* Improve valid WeakMap detection
+
+v0.1.0 -- 2014.04.29
+* Assure to depend only npm hosted dependencies
+* Update to use latest versions of dependencies
+* Use ES6 symbols internally
+
+v0.0.0 -- 2013.10.24
+Initial (dev version)
diff --git a/node_modules/es6-weak-map/LICENSE b/node_modules/es6-weak-map/LICENSE
new file mode 100644
index 000000000..aaf35282f
--- /dev/null
+++ b/node_modules/es6-weak-map/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-weak-map/README.md b/node_modules/es6-weak-map/README.md
new file mode 100644
index 000000000..ccbade23a
--- /dev/null
+++ b/node_modules/es6-weak-map/README.md
@@ -0,0 +1,63 @@
+# es6-weak-map
+## WeakMap collection as specified in ECMAScript6
+
+_Roughly inspired by Mark Miller's and Kris Kowal's [WeakMap implementation](https://github.com/drses/weak-map)_.
+
+Differences are:
+- Assumes compliant ES5 environment (no weird ES3 workarounds or hacks)
+- Well modularized CJS style
+- Based on one solution.
+
+### Limitations
+
+- Will fail on non extensible objects provided as keys
+
+### Installation
+
+ $ npm install es6-weak-map
+
+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/)
+
+### Usage
+
+If you want to make sure your environment implements `WeakMap`, do:
+
+```javascript
+require('es6-weak-map/implement');
+```
+
+If you'd like to use native version when it exists and fallback to polyfill if it doesn't, but without implementing `WeakMap` on global scope, do:
+
+```javascript
+var WeakMap = require('es6-weak-map');
+```
+
+If you strictly want to use polyfill even if native `WeakMap` exists, do:
+
+```javascript
+var WeakMap = require('es6-weak-map/polyfill');
+```
+
+#### API
+
+Best is to refer to [specification](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-weakmap-objects). Still if you want quick look, follow example:
+
+```javascript
+var WeakMap = require('es6-weak-map');
+
+var map = new WeakMap();
+var obj = {};
+
+map.set(obj, 'foo'); // map
+map.get(obj); // 'foo'
+map.has(obj); // true
+map.delete(obj); // true
+map.get(obj); // undefined
+map.has(obj); // false
+map.set(obj, 'bar'); // map
+map.has(obj); // false
+```
+
+## Tests [![Build Status](https://travis-ci.org/medikoo/es6-weak-map.svg)](https://travis-ci.org/medikoo/es6-weak-map)
+
+ $ npm test
diff --git a/node_modules/es6-weak-map/implement.js b/node_modules/es6-weak-map/implement.js
new file mode 100644
index 000000000..6c3f306b9
--- /dev/null
+++ b/node_modules/es6-weak-map/implement.js
@@ -0,0 +1,7 @@
+'use strict';
+
+if (!require('./is-implemented')()) {
+ Object.defineProperty(require('es5-ext/global'), 'WeakMap',
+ { value: require('./polyfill'), configurable: true, enumerable: false,
+ writable: true });
+}
diff --git a/node_modules/es6-weak-map/index.js b/node_modules/es6-weak-map/index.js
new file mode 100644
index 000000000..c2ff71b92
--- /dev/null
+++ b/node_modules/es6-weak-map/index.js
@@ -0,0 +1,3 @@
+'use strict';
+
+module.exports = require('./is-implemented')() ? WeakMap : require('./polyfill');
diff --git a/node_modules/es6-weak-map/is-implemented.js b/node_modules/es6-weak-map/is-implemented.js
new file mode 100644
index 000000000..6ef5082ef
--- /dev/null
+++ b/node_modules/es6-weak-map/is-implemented.js
@@ -0,0 +1,20 @@
+'use strict';
+
+module.exports = function () {
+ var weakMap, x;
+ if (typeof WeakMap !== 'function') return false;
+ try {
+ // WebKit doesn't support arguments and crashes
+ weakMap = new WeakMap([[x = {}, 'one'], [{}, 'two'], [{}, 'three']]);
+ } catch (e) {
+ return false;
+ }
+ if (String(weakMap) !== '[object WeakMap]') return false;
+ if (typeof weakMap.set !== 'function') return false;
+ if (weakMap.set({}, 1) !== weakMap) return false;
+ if (typeof weakMap.delete !== 'function') return false;
+ if (typeof weakMap.has !== 'function') return false;
+ if (weakMap.get(x) !== 'one') return false;
+
+ return true;
+};
diff --git a/node_modules/es6-weak-map/is-native-implemented.js b/node_modules/es6-weak-map/is-native-implemented.js
new file mode 100644
index 000000000..ddc4dbd29
--- /dev/null
+++ b/node_modules/es6-weak-map/is-native-implemented.js
@@ -0,0 +1,8 @@
+// Exports true if environment provides native `WeakMap` implementation, whatever that is.
+
+'use strict';
+
+module.exports = (function () {
+ if (typeof WeakMap !== 'function') return false;
+ return (Object.prototype.toString.call(new WeakMap()) === '[object WeakMap]');
+}());
diff --git a/node_modules/es6-weak-map/is-weak-map.js b/node_modules/es6-weak-map/is-weak-map.js
new file mode 100644
index 000000000..10bb2a156
--- /dev/null
+++ b/node_modules/es6-weak-map/is-weak-map.js
@@ -0,0 +1,13 @@
+'use strict';
+
+var toStringTagSymbol = require('es6-symbol').toStringTag
+
+ , toString = Object.prototype.toString
+ , id = '[object WeakMap]'
+ , Global = (typeof WeakMap === 'undefined') ? null : WeakMap;
+
+module.exports = function (x) {
+ return (x && ((Global && (x instanceof Global)) ||
+ (toString.call(x) === id) || (x[toStringTagSymbol] === 'WeakMap'))) ||
+ false;
+};
diff --git a/node_modules/es6-weak-map/package.json b/node_modules/es6-weak-map/package.json
new file mode 100644
index 000000000..22b37e106
--- /dev/null
+++ b/node_modules/es6-weak-map/package.json
@@ -0,0 +1,38 @@
+{
+ "name": "es6-weak-map",
+ "version": "2.0.2",
+ "description": "ECMAScript6 WeakMap polyfill",
+ "author": "Mariusz Nowak <medyk@medikoo.com> (http://www.medikoo.com/)",
+ "keywords": [
+ "map",
+ "weakmap",
+ "collection",
+ "es6",
+ "harmony",
+ "list",
+ "hash",
+ "gc",
+ "ponyfill"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/medikoo/es6-weak-map.git"
+ },
+ "dependencies": {
+ "d": "1",
+ "es5-ext": "^0.10.14",
+ "es6-iterator": "^2.0.1",
+ "es6-symbol": "^3.1.1"
+ },
+ "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-weak-map/polyfill.js b/node_modules/es6-weak-map/polyfill.js
new file mode 100644
index 000000000..6bef09f5b
--- /dev/null
+++ b/node_modules/es6-weak-map/polyfill.js
@@ -0,0 +1,66 @@
+'use strict';
+
+var setPrototypeOf = require('es5-ext/object/set-prototype-of')
+ , object = require('es5-ext/object/valid-object')
+ , value = require('es5-ext/object/valid-value')
+ , randomUniq = require('es5-ext/string/random-uniq')
+ , d = require('d')
+ , getIterator = require('es6-iterator/get')
+ , forOf = require('es6-iterator/for-of')
+ , toStringTagSymbol = require('es6-symbol').toStringTag
+ , isNative = require('./is-native-implemented')
+
+ , isArray = Array.isArray, defineProperty = Object.defineProperty
+ , hasOwnProperty = Object.prototype.hasOwnProperty, getPrototypeOf = Object.getPrototypeOf
+ , WeakMapPoly;
+
+module.exports = WeakMapPoly = function (/*iterable*/) {
+ var iterable = arguments[0], self;
+ if (!(this instanceof WeakMapPoly)) throw new TypeError('Constructor requires \'new\'');
+ if (isNative && setPrototypeOf && (WeakMap !== WeakMapPoly)) {
+ self = setPrototypeOf(new WeakMap(), getPrototypeOf(this));
+ } else {
+ self = this;
+ }
+ if (iterable != null) {
+ if (!isArray(iterable)) iterable = getIterator(iterable);
+ }
+ defineProperty(self, '__weakMapData__', d('c', '$weakMap$' + randomUniq()));
+ if (!iterable) return self;
+ forOf(iterable, function (val) {
+ value(val);
+ self.set(val[0], val[1]);
+ });
+ return self;
+};
+
+if (isNative) {
+ if (setPrototypeOf) setPrototypeOf(WeakMapPoly, WeakMap);
+ WeakMapPoly.prototype = Object.create(WeakMap.prototype, {
+ constructor: d(WeakMapPoly)
+ });
+}
+
+Object.defineProperties(WeakMapPoly.prototype, {
+ delete: d(function (key) {
+ if (hasOwnProperty.call(object(key), this.__weakMapData__)) {
+ delete key[this.__weakMapData__];
+ return true;
+ }
+ return false;
+ }),
+ get: d(function (key) {
+ if (hasOwnProperty.call(object(key), this.__weakMapData__)) {
+ return key[this.__weakMapData__];
+ }
+ }),
+ has: d(function (key) {
+ return hasOwnProperty.call(object(key), this.__weakMapData__);
+ }),
+ set: d(function (key, value) {
+ defineProperty(object(key), this.__weakMapData__, d('c', value));
+ return this;
+ }),
+ toString: d(function () { return '[object WeakMap]'; })
+});
+defineProperty(WeakMapPoly.prototype, toStringTagSymbol, d('c', 'WeakMap'));
diff --git a/node_modules/es6-weak-map/test/implement.js b/node_modules/es6-weak-map/test/implement.js
new file mode 100644
index 000000000..860027ed2
--- /dev/null
+++ b/node_modules/es6-weak-map/test/implement.js
@@ -0,0 +1,3 @@
+'use strict';
+
+module.exports = function (t, a) { a(typeof WeakMap, 'function'); };
diff --git a/node_modules/es6-weak-map/test/index.js b/node_modules/es6-weak-map/test/index.js
new file mode 100644
index 000000000..9b26e4fa7
--- /dev/null
+++ b/node_modules/es6-weak-map/test/index.js
@@ -0,0 +1,6 @@
+'use strict';
+
+module.exports = function (T, a) {
+ var x = {};
+ a((new T([[x, 'foo']])).get(x), 'foo');
+};
diff --git a/node_modules/es6-weak-map/test/is-implemented.js b/node_modules/es6-weak-map/test/is-implemented.js
new file mode 100644
index 000000000..0186871e2
--- /dev/null
+++ b/node_modules/es6-weak-map/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.WeakMap;
+ global.WeakMap = polyfill;
+ a(t(), true);
+ if (cache === undefined) delete global.WeakMap;
+ else global.WeakMap = cache;
+};
diff --git a/node_modules/es6-weak-map/test/is-native-implemented.js b/node_modules/es6-weak-map/test/is-native-implemented.js
new file mode 100644
index 000000000..df8ba0323
--- /dev/null
+++ b/node_modules/es6-weak-map/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-weak-map/test/is-weak-map.js b/node_modules/es6-weak-map/test/is-weak-map.js
new file mode 100644
index 000000000..ba8c04519
--- /dev/null
+++ b/node_modules/es6-weak-map/test/is-weak-map.js
@@ -0,0 +1,16 @@
+'use strict';
+
+var WeakMapPoly = 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 WeakMap !== 'undefined') {
+ a(t(new WeakMap()), true, "Native");
+ }
+ a(t(new WeakMapPoly()), true, "Polyfill");
+};
diff --git a/node_modules/es6-weak-map/test/polyfill.js b/node_modules/es6-weak-map/test/polyfill.js
new file mode 100644
index 000000000..aaffe4a1c
--- /dev/null
+++ b/node_modules/es6-weak-map/test/polyfill.js
@@ -0,0 +1,23 @@
+'use strict';
+
+module.exports = function (T, a) {
+ var x = {}, y = {}, z = {}, arr = [[x, 'raz'], [y, 'dwa']], map = new T(arr);
+
+ a(map instanceof T, true, "WeakMap");
+ a(map.has(x), true, "Has: true");
+ a(map.get(x), 'raz', "Get: contains");
+ a(map.has(z), false, "Has: false");
+ a(map.get(z), undefined, "Get: doesn't contain");
+ a(map.set(z, 'trzy'), map, "Set: return");
+ a(map.has(z), true, "Add");
+ a(map.delete({}), false, "Delete: false");
+
+ a(map.delete(x), true, "Delete: true");
+ a(map.get(x), undefined, "Get: after delete");
+ a(map.has(x), false, "Has: after delete");
+
+ a.h1("Empty initialization");
+ map = new T();
+ map.set(x, 'bar');
+ a(map.get(x), 'bar');
+};
diff --git a/node_modules/es6-weak-map/test/valid-weak-map.js b/node_modules/es6-weak-map/test/valid-weak-map.js
new file mode 100644
index 000000000..a7823421a
--- /dev/null
+++ b/node_modules/es6-weak-map/test/valid-weak-map.js
@@ -0,0 +1,19 @@
+'use strict';
+
+var WeakMapPoly = require('../polyfill');
+
+module.exports = function (t, a) {
+ var map;
+ 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 WeakMap !== 'undefined') {
+ map = new WeakMap();
+ a(t(map), map, "Native");
+ }
+ map = new WeakMapPoly();
+ a(t(map), map, "Polyfill");
+};
diff --git a/node_modules/es6-weak-map/valid-weak-map.js b/node_modules/es6-weak-map/valid-weak-map.js
new file mode 100644
index 000000000..bfb579fec
--- /dev/null
+++ b/node_modules/es6-weak-map/valid-weak-map.js
@@ -0,0 +1,8 @@
+'use strict';
+
+var isWeakMap = require('./is-weak-map');
+
+module.exports = function (x) {
+ if (!isWeakMap(x)) throw new TypeError(x + " is not a WeakMap");
+ return x;
+};