summaryrefslogtreecommitdiff
path: root/tools/eslint/node_modules/escope/node_modules/es6-map/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tools/eslint/node_modules/escope/node_modules/es6-map/lib')
-rw-r--r--tools/eslint/node_modules/escope/node_modules/es6-map/lib/iterator-kinds.js4
-rw-r--r--tools/eslint/node_modules/escope/node_modules/es6-map/lib/iterator.js38
-rw-r--r--tools/eslint/node_modules/escope/node_modules/es6-map/lib/primitive-iterator.js57
3 files changed, 99 insertions, 0 deletions
diff --git a/tools/eslint/node_modules/escope/node_modules/es6-map/lib/iterator-kinds.js b/tools/eslint/node_modules/escope/node_modules/es6-map/lib/iterator-kinds.js
new file mode 100644
index 0000000000..5367b38d94
--- /dev/null
+++ b/tools/eslint/node_modules/escope/node_modules/es6-map/lib/iterator-kinds.js
@@ -0,0 +1,4 @@
+'use strict';
+
+module.exports = require('es5-ext/object/primitive-set')('key',
+ 'value', 'key+value');
diff --git a/tools/eslint/node_modules/escope/node_modules/es6-map/lib/iterator.js b/tools/eslint/node_modules/escope/node_modules/es6-map/lib/iterator.js
new file mode 100644
index 0000000000..60f1e8c9e3
--- /dev/null
+++ b/tools/eslint/node_modules/escope/node_modules/es6-map/lib/iterator.js
@@ -0,0 +1,38 @@
+'use strict';
+
+var setPrototypeOf = require('es5-ext/object/set-prototype-of')
+ , d = require('d')
+ , Iterator = require('es6-iterator')
+ , toStringTagSymbol = require('es6-symbol').toStringTag
+ , kinds = require('./iterator-kinds')
+
+ , defineProperties = Object.defineProperties
+ , unBind = Iterator.prototype._unBind
+ , MapIterator;
+
+MapIterator = module.exports = function (map, kind) {
+ if (!(this instanceof MapIterator)) return new MapIterator(map, kind);
+ Iterator.call(this, map.__mapKeysData__, map);
+ if (!kind || !kinds[kind]) kind = 'key+value';
+ defineProperties(this, {
+ __kind__: d('', kind),
+ __values__: d('w', map.__mapValuesData__)
+ });
+};
+if (setPrototypeOf) setPrototypeOf(MapIterator, Iterator);
+
+MapIterator.prototype = Object.create(Iterator.prototype, {
+ constructor: d(MapIterator),
+ _resolve: d(function (i) {
+ if (this.__kind__ === 'value') return this.__values__[i];
+ if (this.__kind__ === 'key') return this.__list__[i];
+ return [this.__list__[i], this.__values__[i]];
+ }),
+ _unBind: d(function () {
+ this.__values__ = null;
+ unBind.call(this);
+ }),
+ toString: d(function () { return '[object Map Iterator]'; })
+});
+Object.defineProperty(MapIterator.prototype, toStringTagSymbol,
+ d('c', 'Map Iterator'));
diff --git a/tools/eslint/node_modules/escope/node_modules/es6-map/lib/primitive-iterator.js b/tools/eslint/node_modules/escope/node_modules/es6-map/lib/primitive-iterator.js
new file mode 100644
index 0000000000..b9eada37c1
--- /dev/null
+++ b/tools/eslint/node_modules/escope/node_modules/es6-map/lib/primitive-iterator.js
@@ -0,0 +1,57 @@
+'use strict';
+
+var clear = require('es5-ext/array/#/clear')
+ , assign = require('es5-ext/object/assign')
+ , setPrototypeOf = require('es5-ext/object/set-prototype-of')
+ , toStringTagSymbol = require('es6-symbol').toStringTag
+ , d = require('d')
+ , autoBind = require('d/auto-bind')
+ , Iterator = require('es6-iterator')
+ , kinds = require('./iterator-kinds')
+
+ , defineProperties = Object.defineProperties, keys = Object.keys
+ , unBind = Iterator.prototype._unBind
+ , PrimitiveMapIterator;
+
+PrimitiveMapIterator = module.exports = function (map, kind) {
+ if (!(this instanceof PrimitiveMapIterator)) {
+ return new PrimitiveMapIterator(map, kind);
+ }
+ Iterator.call(this, keys(map.__mapKeysData__), map);
+ if (!kind || !kinds[kind]) kind = 'key+value';
+ defineProperties(this, {
+ __kind__: d('', kind),
+ __keysData__: d('w', map.__mapKeysData__),
+ __valuesData__: d('w', map.__mapValuesData__)
+ });
+};
+if (setPrototypeOf) setPrototypeOf(PrimitiveMapIterator, Iterator);
+
+PrimitiveMapIterator.prototype = Object.create(Iterator.prototype, assign({
+ constructor: d(PrimitiveMapIterator),
+ _resolve: d(function (i) {
+ if (this.__kind__ === 'value') return this.__valuesData__[this.__list__[i]];
+ if (this.__kind__ === 'key') return this.__keysData__[this.__list__[i]];
+ return [this.__keysData__[this.__list__[i]],
+ this.__valuesData__[this.__list__[i]]];
+ }),
+ _unBind: d(function () {
+ this.__keysData__ = null;
+ this.__valuesData__ = null;
+ unBind.call(this);
+ }),
+ toString: d(function () { return '[object Map 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(PrimitiveMapIterator.prototype, toStringTagSymbol,
+ d('c', 'Map Iterator'));