fix: prevent asset conflicts between React and Grid.js versions

Add coexistence checks to all enqueue methods to prevent loading
both React and Grid.js assets simultaneously.

Changes:
- ReactAdmin.php: Only enqueue React assets when ?react=1
- Init.php: Skip Grid.js when React active on admin pages
- Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0
- Customer.php, Product.php, License.php: Add coexistence checks

Now the toggle between Classic and React versions works correctly.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
dwindown
2026-04-18 17:02:14 +07:00
parent bd9cdac02e
commit e8fbfb14c1
74973 changed files with 6658406 additions and 71 deletions

25
node_modules/equivalent-key-map/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,25 @@
### v0.2.2 (2018-09-26)
- Fix: Resolve issue where `has` (and consequentally internal reuse such as in `delete`) would wrongly return `false` on keys whose values were assigned as [falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy).
### v0.2.1 (2018-07-23)
- Fix: Resolve issue where cloning from another instance of `EquivalentKeyMap` could result in incorrect value assignment on path.
### v0.2.0 (2018-05-04)
- New: Clone from existing `EquivalentKeyMap` instance by passing as constructor argument.
- New: Added `forEach` method and `size` property.
- Improved: Cache last calls to `get` and `set` for lookup shortcutting.
### v0.1.2 (2018-04-26)
- Fix: Avoid conflicts on empty object and array keys.
### v0.1.1 (2018-04-25)
- Fix: Avoid conflicts where objects with numeric keys could be considered equivalent to arrays.
### v0.1.0 (2018-04-24)
- Initial release

7
node_modules/equivalent-key-map/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,7 @@
[The MIT License (MIT)](https://opensource.org/licenses/MIT)
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.

113
node_modules/equivalent-key-map/README.md generated vendored Normal file
View File

@@ -0,0 +1,113 @@
# EquivalentKeyMap
`EquivalentKeyMap` is a variant of a [`Map` object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) which enables lookup by _equivalent_ (deeply equal) object and array keys.
## Example
With a standard `Map`, a value is only returned if its key is strictly equal to the one used in assigning its value.
```js
const map = new Map();
map.set( { a: 1 }, 10 );
map.get( { a: 1 } );
// ⇒ undefined
```
By contrast, `EquivalentKeyMap` considers key equality of objects and arrays deeply:
```js
const map = new EquivalentKeyMap();
map.set( { a: 1 }, 10 );
map.get( { a: 1 } );
// ⇒ 10
```
## Installation
EquivalentKeyMap is published as an [npm](https://www.npmjs.com/) package:
```
npm install equivalent-key-map
```
Browser-ready versions are available from [unpkg](https://unpkg.com/equivalent-key-map/dist/equivalent-key-map.min.js). The browser-ready version assigns itself on the global scope as `EquivalentKeyMap`.
```html
<script src="https://unpkg.com/equivalent-key-map/dist/equivalent-key-map.min.js"></script>
<script>
var map = new EquivalentKeyMap();
// ...
</script>
```
## Usage
`EquivalentKeyMap` is intended to recreate the same API properties and methods available for `Map`:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
**Note:** Currently, only methods and properties supported by IE11 are implemented (see [Browser compatibility](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Browser_compatibility)).
## Performance Considerations
There is inevitably some overhead in tracking object and array references deeply, contrasted with the standard Map object. This is a compromise you should consider when deciding whether you need deep key equality behavior.
That said, `EquivalentKeyMap` was implemented with performance in mind, and is significantly faster — and importantaly, more [correct](https://github.com/aduth/equivalent-key-map/blob/210f42bbd431c7c10da33d310cf56ef3b3ca96e7/test/index.js#L67-L71) — than a number of [alternative naive approaches](https://github.com/aduth/equivalent-key-map/tree/master/benchmark/impl). It also optimizes for repeated calls with the same object reference, memoizing the latest invocation of `get` to shortcut lookups.
### Benchmarks
The following benchmark results describe the behavior of `EquivalentMap#get` with keys of varying property lengths.
>**`EquivalentKeyMap (2 properties, equal reference) x 38,726,559 ops/sec ±1.25% (87 runs sampled)`**
>**`EquivalentKeyMap (8 properties, equal reference) x 43,395,727 ops/sec ±0.64% (91 runs sampled)`**
>**`EquivalentKeyMap (18 properties, equal reference) x 51,334,445 ops/sec ±0.54% (87 runs sampled)`**
>
>**`EquivalentKeyMap (2 properties) x 2,419,300 ops/sec ±1.37% (85 runs sampled)`**
>**`EquivalentKeyMap (8 properties) x 1,362,012 ops/sec ±0.40% (90 runs sampled)`**
>**`EquivalentKeyMap (18 properties) x 569,431 ops/sec ±0.93% (88 runs sampled)`**
>
>`JSONStringifyNaiveMap (2 properties) x 1,958,910 ops/sec ±0.33% (94 runs sampled)`
>`JSONStringifyNaiveMap (8 properties) x 1,038,380 ops/sec ±0.34% (94 runs sampled)`
>`JSONStringifyNaiveMap (18 properties) x 600,017 ops/sec ±0.39% (91 runs sampled)`
>
>`JSONStringifyOptimizedMap (2 properties) x 2,143,323 ops/sec ±0.36% (94 runs sampled)`
>`JSONStringifyOptimizedMap (8 properties) x 1,088,846 ops/sec ±0.51% (92 runs sampled)`
>`JSONStringifyOptimizedMap (18 properties) x 627,801 ops/sec ±0.31% (91 runs sampled)`
>
>`JSONStableStringifyMap (2 properties) x 279,919 ops/sec ±0.91% (85 runs sampled)`
>`JSONStableStringifyMap (8 properties) x 129,635 ops/sec ±0.55% (93 runs sampled)`
>`JSONStableStringifyMap (18 properties) x 64,372 ops/sec ±0.40% (94 runs sampled)`
>
>`FasterStableStringifyMap (2 properties) x 383,185 ops/sec ±0.79% (85 runs sampled)`
>`FasterStableStringifyMap (8 properties) x 174,948 ops/sec ±0.48% (88 runs sampled)`
>`FasterStableStringifyMap (18 properties) x 89,142 ops/sec ±0.46% (94 runs sampled)`
>
>`TupleStringifyMap (2 properties) x 885,499 ops/sec ±0.50% (92 runs sampled)`
>`TupleStringifyMap (8 properties) x 404,241 ops/sec ±0.56% (90 runs sampled)`
>`TupleStringifyMap (18 properties) x 206,659 ops/sec ±0.74% (93 runs sampled)`
>
>`StableQuerystringMap (2 properties) x 920,191 ops/sec ±0.72% (86 runs sampled)`
>`StableQuerystringMap (8 properties) x 343,097 ops/sec ±0.40% (92 runs sampled)`
>`StableQuerystringMap (18 properties) x 157,483 ops/sec ±0.50% (93 runs sampled)`
You can run these on your own machine by cloning the repository, installing dependencies, and running `npm run benchmark`.
```
git clone https://github.com/aduth/equivalent-key-map.git
cd equivalent-key-map
npm install
npm run benchmark
```
## Browser Support
`EquivalentKeyMap` is implemented using `Map` and follows the corresponding [browser compatibility](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Browser_compatibility). Notably, this includes all modern browsers and Internet Explorer 11. The `Map` methods not supported by Internet Explorer 11 are not used by `EquivalentKeyMap` and can be safely overlooked.
If you need support for older browsers, it's recommended that you use a polyfill such as [`core-js`](https://github.com/zloirock/core-js) or [polyfill.io](https://polyfill.io/v2/docs/).
## License
Copyright 2018 Andrew Duthie
Released under the [MIT License](https://github.com/aduth/equivalent-key-map/tree/master/LICENSE.md).

View File

@@ -0,0 +1,310 @@
var EquivalentKeyMap = (function () {
'use strict';
function _typeof(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
/**
* Given an instance of EquivalentKeyMap, returns its internal value pair tuple
* for a key, if one exists. The tuple members consist of the last reference
* value for the key (used in efficient subsequent lookups) and the value
* assigned for the key at the leaf node.
*
* @param {EquivalentKeyMap} instance EquivalentKeyMap instance.
* @param {*} key The key for which to return value pair.
*
* @return {?Array} Value pair, if exists.
*/
function getValuePair(instance, key) {
var _map = instance._map,
_arrayTreeMap = instance._arrayTreeMap,
_objectTreeMap = instance._objectTreeMap; // Map keeps a reference to the last object-like key used to set the
// value, which can be used to shortcut immediately to the value.
if (_map.has(key)) {
return _map.get(key);
} // Sort keys to ensure stable retrieval from tree.
var properties = Object.keys(key).sort(); // Tree by type to avoid conflicts on numeric object keys, empty value.
var map = Array.isArray(key) ? _arrayTreeMap : _objectTreeMap;
for (var i = 0; i < properties.length; i++) {
var property = properties[i];
map = map.get(property);
if (map === undefined) {
return;
}
var propertyValue = key[property];
map = map.get(propertyValue);
if (map === undefined) {
return;
}
}
var valuePair = map.get('_ekm_value');
if (!valuePair) {
return;
} // If reached, it implies that an object-like key was set with another
// reference, so delete the reference and replace with the current.
_map.delete(valuePair[0]);
valuePair[0] = key;
map.set('_ekm_value', valuePair);
_map.set(key, valuePair);
return valuePair;
}
/**
* Variant of a Map object which enables lookup by equivalent (deeply equal)
* object and array keys.
*/
var EquivalentKeyMap =
/*#__PURE__*/
function () {
/**
* Constructs a new instance of EquivalentKeyMap.
*
* @param {Iterable.<*>} iterable Initial pair of key, value for map.
*/
function EquivalentKeyMap(iterable) {
_classCallCheck(this, EquivalentKeyMap);
this.clear();
if (iterable instanceof EquivalentKeyMap) {
// Map#forEach is only means of iterating with support for IE11.
var iterablePairs = [];
iterable.forEach(function (value, key) {
iterablePairs.push([key, value]);
});
iterable = iterablePairs;
}
if (iterable != null) {
for (var i = 0; i < iterable.length; i++) {
this.set(iterable[i][0], iterable[i][1]);
}
}
}
/**
* Accessor property returning the number of elements.
*
* @return {number} Number of elements.
*/
_createClass(EquivalentKeyMap, [{
key: "set",
/**
* Add or update an element with a specified key and value.
*
* @param {*} key The key of the element to add.
* @param {*} value The value of the element to add.
*
* @return {EquivalentKeyMap} Map instance.
*/
value: function set(key, value) {
// Shortcut non-object-like to set on internal Map.
if (key === null || _typeof(key) !== 'object') {
this._map.set(key, value);
return this;
} // Sort keys to ensure stable assignment into tree.
var properties = Object.keys(key).sort();
var valuePair = [key, value]; // Tree by type to avoid conflicts on numeric object keys, empty value.
var map = Array.isArray(key) ? this._arrayTreeMap : this._objectTreeMap;
for (var i = 0; i < properties.length; i++) {
var property = properties[i];
if (!map.has(property)) {
map.set(property, new EquivalentKeyMap());
}
map = map.get(property);
var propertyValue = key[property];
if (!map.has(propertyValue)) {
map.set(propertyValue, new EquivalentKeyMap());
}
map = map.get(propertyValue);
} // If an _ekm_value exists, there was already an equivalent key. Before
// overriding, ensure that the old key reference is removed from map to
// avoid memory leak of accumulating equivalent keys. This is, in a
// sense, a poor man's WeakMap, while still enabling iterability.
var previousValuePair = map.get('_ekm_value');
if (previousValuePair) {
this._map.delete(previousValuePair[0]);
}
map.set('_ekm_value', valuePair);
this._map.set(key, valuePair);
return this;
}
/**
* Returns a specified element.
*
* @param {*} key The key of the element to return.
*
* @return {?*} The element associated with the specified key or undefined
* if the key can't be found.
*/
}, {
key: "get",
value: function get(key) {
// Shortcut non-object-like to get from internal Map.
if (key === null || _typeof(key) !== 'object') {
return this._map.get(key);
}
var valuePair = getValuePair(this, key);
if (valuePair) {
return valuePair[1];
}
}
/**
* Returns a boolean indicating whether an element with the specified key
* exists or not.
*
* @param {*} key The key of the element to test for presence.
*
* @return {boolean} Whether an element with the specified key exists.
*/
}, {
key: "has",
value: function has(key) {
if (key === null || _typeof(key) !== 'object') {
return this._map.has(key);
} // Test on the _presence_ of the pair, not its value, as even undefined
// can be a valid member value for a key.
return getValuePair(this, key) !== undefined;
}
/**
* Removes the specified element.
*
* @param {*} key The key of the element to remove.
*
* @return {boolean} Returns true if an element existed and has been
* removed, or false if the element does not exist.
*/
}, {
key: "delete",
value: function _delete(key) {
if (!this.has(key)) {
return false;
} // This naive implementation will leave orphaned child trees. A better
// implementation should traverse and remove orphans.
this.set(key, undefined);
return true;
}
/**
* Executes a provided function once per each key/value pair, in insertion
* order.
*
* @param {Function} callback Function to execute for each element.
* @param {*} thisArg Value to use as `this` when executing
* `callback`.
*/
}, {
key: "forEach",
value: function forEach(callback) {
var _this = this;
var thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this;
this._map.forEach(function (value, key) {
// Unwrap value from object-like value pair.
if (key !== null && _typeof(key) === 'object') {
value = value[1];
}
callback.call(thisArg, value, key, _this);
});
}
/**
* Removes all elements.
*/
}, {
key: "clear",
value: function clear() {
this._map = new Map();
this._arrayTreeMap = new Map();
this._objectTreeMap = new Map();
}
}, {
key: "size",
get: function get() {
return this._map.size;
}
}]);
return EquivalentKeyMap;
}();
return EquivalentKeyMap;
}());

View File

@@ -0,0 +1 @@
var EquivalentKeyMap=function(){"use strict";function c(e){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function a(e,t){var r=e._map,n=e._arrayTreeMap,a=e._objectTreeMap;if(r.has(t))return r.get(t);for(var i=Object.keys(t).sort(),o=Array.isArray(t)?n:a,u=0;u<i.length;u++){var s=i[u];if(void 0===(o=o.get(s)))return;var l=t[s];if(void 0===(o=o.get(l)))return}var c=o.get("_ekm_value");return c?(r.delete(c[0]),c[0]=t,o.set("_ekm_value",c),r.set(t,c),c):void 0}return function(){function l(e){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),this.clear(),e instanceof l){var r=[];e.forEach(function(e,t){r.push([t,e])}),e=r}if(null!=e)for(var t=0;t<e.length;t++)this.set(e[t][0],e[t][1])}var e,t,r;return e=l,(t=[{key:"set",value:function(e,t){if(null===e||"object"!==c(e))return this._map.set(e,t),this;for(var r=Object.keys(e).sort(),n=[e,t],a=Array.isArray(e)?this._arrayTreeMap:this._objectTreeMap,i=0;i<r.length;i++){var o=r[i];a.has(o)||a.set(o,new l),a=a.get(o);var u=e[o];a.has(u)||a.set(u,new l),a=a.get(u)}var s=a.get("_ekm_value");return s&&this._map.delete(s[0]),a.set("_ekm_value",n),this._map.set(e,n),this}},{key:"get",value:function(e){if(null===e||"object"!==c(e))return this._map.get(e);var t=a(this,e);return t?t[1]:void 0}},{key:"has",value:function(e){return null===e||"object"!==c(e)?this._map.has(e):void 0!==a(this,e)}},{key:"delete",value:function(e){return!!this.has(e)&&(this.set(e,void 0),!0)}},{key:"forEach",value:function(r){var n=this,a=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this;this._map.forEach(function(e,t){null!==t&&"object"===c(t)&&(e=e[1]),r.call(a,e,t,n)})}},{key:"clear",value:function(){this._map=new Map,this._arrayTreeMap=new Map,this._objectTreeMap=new Map}},{key:"size",get:function(){return this._map.size}}])&&n(e.prototype,t),r&&n(e,r),l}()}();

307
node_modules/equivalent-key-map/equivalent-key-map.js generated vendored Normal file
View File

@@ -0,0 +1,307 @@
'use strict';
function _typeof(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
/**
* Given an instance of EquivalentKeyMap, returns its internal value pair tuple
* for a key, if one exists. The tuple members consist of the last reference
* value for the key (used in efficient subsequent lookups) and the value
* assigned for the key at the leaf node.
*
* @param {EquivalentKeyMap} instance EquivalentKeyMap instance.
* @param {*} key The key for which to return value pair.
*
* @return {?Array} Value pair, if exists.
*/
function getValuePair(instance, key) {
var _map = instance._map,
_arrayTreeMap = instance._arrayTreeMap,
_objectTreeMap = instance._objectTreeMap; // Map keeps a reference to the last object-like key used to set the
// value, which can be used to shortcut immediately to the value.
if (_map.has(key)) {
return _map.get(key);
} // Sort keys to ensure stable retrieval from tree.
var properties = Object.keys(key).sort(); // Tree by type to avoid conflicts on numeric object keys, empty value.
var map = Array.isArray(key) ? _arrayTreeMap : _objectTreeMap;
for (var i = 0; i < properties.length; i++) {
var property = properties[i];
map = map.get(property);
if (map === undefined) {
return;
}
var propertyValue = key[property];
map = map.get(propertyValue);
if (map === undefined) {
return;
}
}
var valuePair = map.get('_ekm_value');
if (!valuePair) {
return;
} // If reached, it implies that an object-like key was set with another
// reference, so delete the reference and replace with the current.
_map.delete(valuePair[0]);
valuePair[0] = key;
map.set('_ekm_value', valuePair);
_map.set(key, valuePair);
return valuePair;
}
/**
* Variant of a Map object which enables lookup by equivalent (deeply equal)
* object and array keys.
*/
var EquivalentKeyMap =
/*#__PURE__*/
function () {
/**
* Constructs a new instance of EquivalentKeyMap.
*
* @param {Iterable.<*>} iterable Initial pair of key, value for map.
*/
function EquivalentKeyMap(iterable) {
_classCallCheck(this, EquivalentKeyMap);
this.clear();
if (iterable instanceof EquivalentKeyMap) {
// Map#forEach is only means of iterating with support for IE11.
var iterablePairs = [];
iterable.forEach(function (value, key) {
iterablePairs.push([key, value]);
});
iterable = iterablePairs;
}
if (iterable != null) {
for (var i = 0; i < iterable.length; i++) {
this.set(iterable[i][0], iterable[i][1]);
}
}
}
/**
* Accessor property returning the number of elements.
*
* @return {number} Number of elements.
*/
_createClass(EquivalentKeyMap, [{
key: "set",
/**
* Add or update an element with a specified key and value.
*
* @param {*} key The key of the element to add.
* @param {*} value The value of the element to add.
*
* @return {EquivalentKeyMap} Map instance.
*/
value: function set(key, value) {
// Shortcut non-object-like to set on internal Map.
if (key === null || _typeof(key) !== 'object') {
this._map.set(key, value);
return this;
} // Sort keys to ensure stable assignment into tree.
var properties = Object.keys(key).sort();
var valuePair = [key, value]; // Tree by type to avoid conflicts on numeric object keys, empty value.
var map = Array.isArray(key) ? this._arrayTreeMap : this._objectTreeMap;
for (var i = 0; i < properties.length; i++) {
var property = properties[i];
if (!map.has(property)) {
map.set(property, new EquivalentKeyMap());
}
map = map.get(property);
var propertyValue = key[property];
if (!map.has(propertyValue)) {
map.set(propertyValue, new EquivalentKeyMap());
}
map = map.get(propertyValue);
} // If an _ekm_value exists, there was already an equivalent key. Before
// overriding, ensure that the old key reference is removed from map to
// avoid memory leak of accumulating equivalent keys. This is, in a
// sense, a poor man's WeakMap, while still enabling iterability.
var previousValuePair = map.get('_ekm_value');
if (previousValuePair) {
this._map.delete(previousValuePair[0]);
}
map.set('_ekm_value', valuePair);
this._map.set(key, valuePair);
return this;
}
/**
* Returns a specified element.
*
* @param {*} key The key of the element to return.
*
* @return {?*} The element associated with the specified key or undefined
* if the key can't be found.
*/
}, {
key: "get",
value: function get(key) {
// Shortcut non-object-like to get from internal Map.
if (key === null || _typeof(key) !== 'object') {
return this._map.get(key);
}
var valuePair = getValuePair(this, key);
if (valuePair) {
return valuePair[1];
}
}
/**
* Returns a boolean indicating whether an element with the specified key
* exists or not.
*
* @param {*} key The key of the element to test for presence.
*
* @return {boolean} Whether an element with the specified key exists.
*/
}, {
key: "has",
value: function has(key) {
if (key === null || _typeof(key) !== 'object') {
return this._map.has(key);
} // Test on the _presence_ of the pair, not its value, as even undefined
// can be a valid member value for a key.
return getValuePair(this, key) !== undefined;
}
/**
* Removes the specified element.
*
* @param {*} key The key of the element to remove.
*
* @return {boolean} Returns true if an element existed and has been
* removed, or false if the element does not exist.
*/
}, {
key: "delete",
value: function _delete(key) {
if (!this.has(key)) {
return false;
} // This naive implementation will leave orphaned child trees. A better
// implementation should traverse and remove orphans.
this.set(key, undefined);
return true;
}
/**
* Executes a provided function once per each key/value pair, in insertion
* order.
*
* @param {Function} callback Function to execute for each element.
* @param {*} thisArg Value to use as `this` when executing
* `callback`.
*/
}, {
key: "forEach",
value: function forEach(callback) {
var _this = this;
var thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this;
this._map.forEach(function (value, key) {
// Unwrap value from object-like value pair.
if (key !== null && _typeof(key) === 'object') {
value = value[1];
}
callback.call(thisArg, value, key, _this);
});
}
/**
* Removes all elements.
*/
}, {
key: "clear",
value: function clear() {
this._map = new Map();
this._arrayTreeMap = new Map();
this._objectTreeMap = new Map();
}
}, {
key: "size",
get: function get() {
return this._map.size;
}
}]);
return EquivalentKeyMap;
}();
module.exports = EquivalentKeyMap;

54
node_modules/equivalent-key-map/package.json generated vendored Normal file
View File

@@ -0,0 +1,54 @@
{
"name": "equivalent-key-map",
"version": "0.2.2",
"description": "A Map variant which allows for equivalent (deeply equal) object and array keys",
"main": "equivalent-key-map.js",
"files": [
"equivalent-key-map.js",
"dist"
],
"scripts": {
"test:lint": "eslint .",
"pretest:unit": "rollup -c",
"test:unit": "mocha",
"test-watch": "chokidar 'src/*.js' 'test/*.js' --initial -c 'npm run test:unit'",
"test": "npm-run-all --parallel test:*",
"build": "NODE_ENV=production rollup -c",
"build-watch": "npm run build -- --watch",
"postbuild": "npm run minify",
"minify": "uglifyjs dist/equivalent-key-map.js -c -m > dist/equivalent-key-map.min.js",
"prepublishOnly": "npm run build",
"prebenchmark": "npm run build",
"benchmark": "node benchmark"
},
"repository": {
"type": "git",
"url": "https://github.com/aduth/equivalent-key-map.git"
},
"bugs": {
"url": "https://github.com/aduth/equivalent-key-map/issues"
},
"author": {
"name": "Andrew Duthie",
"email": "andrew@andrewduthie.com",
"url": "http://andrewduthie.com"
},
"license": "MIT",
"devDependencies": {
"@aduth/eslint-config": "^2.0.0",
"@babel/core": "^7.0.0-beta.54",
"@babel/preset-env": "^7.0.0-beta.54",
"benchmark": "^2.1.4",
"chai": "^4.1.2",
"chokidar": "^2.0.4",
"eslint": "^5.2.0",
"eslint-plugin-jsdoc": "^3.7.1",
"faster-stable-stringify": "^1.0.0",
"json-stable-stringify": "^1.0.1",
"mocha": "^5.2.0",
"npm-run-all": "^4.1.3",
"rollup": "^0.63.4",
"rollup-plugin-babel": "^4.0.0-beta.4",
"uglify-js": "^3.4.5"
}
}