Socket
Socket
Sign inDemoInstall

reflect-metadata

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reflect-metadata - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

5

package.json
{
"name": "reflect-metadata",
"version": "0.1.5",
"version": "0.1.6",
"description": "Polyfill for Metadata Reflection API",

@@ -11,5 +11,6 @@ "main": "Reflect.js",

"scripts": {
"prepublish": "npm run test",
"build": "tsc",
"build-test": "tsc --project ./test/",
"test": "npm run build-test & node ./temp/test/run.js"
"test": "npm run build & npm run build-test & node ./temp/test/run.js"
},

@@ -16,0 +17,0 @@ "repository": {

440

Reflect.js

@@ -29,2 +29,3 @@ /*! *****************************************************************************

})();
// create an object in dictionary mode (a.k.a. "slow" mode in v8)
var createDictionary = supportsCreate ? function () { return MakeDictionary(Object.create(null)); } :

@@ -49,3 +50,3 @@ supportsProto ? function () { return MakeDictionary({ __proto__: null }); } :

// [[Metadata]] internal slot
var __Metadata__ = new _WeakMap();
var Metadata = new _WeakMap();
/**

@@ -92,14 +93,10 @@ * Applies a set of decorators to a property of a target object.

if (!IsUndefined(targetDescriptor)) {
if (!IsArray(decorators)) {
if (!IsArray(decorators))
throw new TypeError();
}
else if (!IsObject(target)) {
if (!IsObject(target))
throw new TypeError();
}
else if (IsUndefined(targetKey)) {
if (IsUndefined(targetKey))
throw new TypeError();
}
else if (!IsObject(targetDescriptor)) {
if (!IsObject(targetDescriptor))
throw new TypeError();
}
targetKey = ToPropertyKey(targetKey);

@@ -109,8 +106,6 @@ return DecoratePropertyWithDescriptor(decorators, target, targetKey, targetDescriptor);

else if (!IsUndefined(targetKey)) {
if (!IsArray(decorators)) {
if (!IsArray(decorators))
throw new TypeError();
}
else if (!IsObject(target)) {
if (!IsObject(target))
throw new TypeError();
}
targetKey = ToPropertyKey(targetKey);

@@ -120,8 +115,6 @@ return DecoratePropertyWithoutDescriptor(decorators, target, targetKey);

else {
if (!IsArray(decorators)) {
if (!IsArray(decorators))
throw new TypeError();
}
else if (!IsConstructor(target)) {
if (!IsConstructor(target))
throw new TypeError();
}
return DecorateConstructor(decorators, target);

@@ -174,5 +167,4 @@ }

if (!IsUndefined(targetKey)) {
if (!IsObject(target)) {
if (!IsObject(target))
throw new TypeError();
}
targetKey = ToPropertyKey(targetKey);

@@ -182,5 +174,4 @@ OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, targetKey);

else {
if (!IsConstructor(target)) {
if (!IsConstructor(target))
throw new TypeError();
}
OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, /*targetKey*/ undefined);

@@ -232,8 +223,6 @@ }

function defineMetadata(metadataKey, metadataValue, target, targetKey) {
if (!IsObject(target)) {
if (!IsObject(target))
throw new TypeError();
}
else if (!IsUndefined(targetKey)) {
if (!IsUndefined(targetKey))
targetKey = ToPropertyKey(targetKey);
}
return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, targetKey);

@@ -277,8 +266,6 @@ }

function hasMetadata(metadataKey, target, targetKey) {
if (!IsObject(target)) {
if (!IsObject(target))
throw new TypeError();
}
else if (!IsUndefined(targetKey)) {
if (!IsUndefined(targetKey))
targetKey = ToPropertyKey(targetKey);
}
return OrdinaryHasMetadata(metadataKey, target, targetKey);

@@ -322,8 +309,6 @@ }

function hasOwnMetadata(metadataKey, target, targetKey) {
if (!IsObject(target)) {
if (!IsObject(target))
throw new TypeError();
}
else if (!IsUndefined(targetKey)) {
if (!IsUndefined(targetKey))
targetKey = ToPropertyKey(targetKey);
}
return OrdinaryHasOwnMetadata(metadataKey, target, targetKey);

@@ -367,8 +352,6 @@ }

function getMetadata(metadataKey, target, targetKey) {
if (!IsObject(target)) {
if (!IsObject(target))
throw new TypeError();
}
else if (!IsUndefined(targetKey)) {
if (!IsUndefined(targetKey))
targetKey = ToPropertyKey(targetKey);
}
return OrdinaryGetMetadata(metadataKey, target, targetKey);

@@ -412,8 +395,6 @@ }

function getOwnMetadata(metadataKey, target, targetKey) {
if (!IsObject(target)) {
if (!IsObject(target))
throw new TypeError();
}
else if (!IsUndefined(targetKey)) {
if (!IsUndefined(targetKey))
targetKey = ToPropertyKey(targetKey);
}
return OrdinaryGetOwnMetadata(metadataKey, target, targetKey);

@@ -456,8 +437,6 @@ }

function getMetadataKeys(target, targetKey) {
if (!IsObject(target)) {
if (!IsObject(target))
throw new TypeError();
}
else if (!IsUndefined(targetKey)) {
if (!IsUndefined(targetKey))
targetKey = ToPropertyKey(targetKey);
}
return OrdinaryMetadataKeys(target, targetKey);

@@ -500,8 +479,6 @@ }

function getOwnMetadataKeys(target, targetKey) {
if (!IsObject(target)) {
if (!IsObject(target))
throw new TypeError();
}
else if (!IsUndefined(targetKey)) {
if (!IsUndefined(targetKey))
targetKey = ToPropertyKey(targetKey);
}
return OrdinaryOwnMetadataKeys(target, targetKey);

@@ -545,25 +522,19 @@ }

function deleteMetadata(metadataKey, target, targetKey) {
if (!IsObject(target)) {
// https://github.com/rbuckton/ReflectDecorators/blob/master/spec/metadata.md#deletemetadata-metadatakey-p-
if (!IsObject(target))
throw new TypeError();
}
else if (!IsUndefined(targetKey)) {
if (!IsUndefined(targetKey))
targetKey = ToPropertyKey(targetKey);
}
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#deletemetadata-metadatakey-p-
var metadataMap = GetOrCreateMetadataMap(target, targetKey, /*create*/ false);
if (IsUndefined(metadataMap)) {
if (IsUndefined(metadataMap))
return false;
}
if (!metadataMap.delete(metadataKey)) {
if (!metadataMap.delete(metadataKey))
return false;
}
if (metadataMap.size > 0) {
if (metadataMap.size > 0)
return true;
}
var targetMetadata = __Metadata__.get(target);
var targetMetadata = Metadata.get(target);
targetMetadata.delete(targetKey);
if (targetMetadata.size > 0) {
if (targetMetadata.size > 0)
return true;
}
__Metadata__.delete(target);
Metadata.delete(target);
return true;

@@ -577,5 +548,4 @@ }

if (!IsUndefined(decorated)) {
if (!IsConstructor(decorated)) {
if (!IsConstructor(decorated))
throw new TypeError();
}
target = decorated;

@@ -591,5 +561,4 @@ }

if (!IsUndefined(decorated)) {
if (!IsObject(decorated)) {
if (!IsObject(decorated))
throw new TypeError();
}
descriptor = decorated;

@@ -606,17 +575,15 @@ }

}
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#getorcreatemetadatamap--o-p-create-
// https://github.com/rbuckton/ReflectDecorators/blob/master/spec/metadata.md#getorcreatemetadatamap--o-p-create-
function GetOrCreateMetadataMap(target, targetKey, create) {
var targetMetadata = __Metadata__.get(target);
var targetMetadata = Metadata.get(target);
if (!targetMetadata) {
if (!create) {
if (!create)
return undefined;
}
targetMetadata = new _Map();
__Metadata__.set(target, targetMetadata);
Metadata.set(target, targetMetadata);
}
var keyMetadata = targetMetadata.get(targetKey);
if (!keyMetadata) {
if (!create) {
if (!create)
return undefined;
}
keyMetadata = new _Map();

@@ -627,43 +594,29 @@ targetMetadata.set(targetKey, keyMetadata);

}
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinaryhasmetadata--metadatakey-o-p-
// https://github.com/rbuckton/ReflectDecorators/blob/master/spec/metadata.md#ordinaryhasmetadata--metadatakey-o-p-
function OrdinaryHasMetadata(MetadataKey, O, P) {
var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P);
if (hasOwn) {
if (hasOwn)
return true;
}
var parent = GetPrototypeOf(O);
if (parent !== null) {
return OrdinaryHasMetadata(MetadataKey, parent, P);
}
return false;
return parent !== null ? OrdinaryHasMetadata(MetadataKey, parent, P) : false;
}
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinaryhasownmetadata--metadatakey-o-p-
// https://github.com/rbuckton/ReflectDecorators/blob/master/spec/metadata.md#ordinaryhasownmetadata--metadatakey-o-p-
function OrdinaryHasOwnMetadata(MetadataKey, O, P) {
var metadataMap = GetOrCreateMetadataMap(O, P, /*create*/ false);
if (metadataMap === undefined) {
return false;
}
return Boolean(metadataMap.has(MetadataKey));
return metadataMap !== undefined && Boolean(metadataMap.has(MetadataKey));
}
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinarygetmetadata--metadatakey-o-p-
// https://github.com/rbuckton/ReflectDecorators/blob/master/spec/metadata.md#ordinarygetmetadata--metadatakey-o-p-
function OrdinaryGetMetadata(MetadataKey, O, P) {
var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P);
if (hasOwn) {
if (hasOwn)
return OrdinaryGetOwnMetadata(MetadataKey, O, P);
}
var parent = GetPrototypeOf(O);
if (parent !== null) {
return OrdinaryGetMetadata(MetadataKey, parent, P);
}
return undefined;
return parent !== null ? OrdinaryGetMetadata(MetadataKey, parent, P) : undefined;
}
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinarygetownmetadata--metadatakey-o-p-
// https://github.com/rbuckton/ReflectDecorators/blob/master/spec/metadata.md#ordinarygetownmetadata--metadatakey-o-p-
function OrdinaryGetOwnMetadata(MetadataKey, O, P) {
var metadataMap = GetOrCreateMetadataMap(O, P, /*create*/ false);
if (metadataMap === undefined) {
return undefined;
}
return metadataMap.get(MetadataKey);
return metadataMap === undefined ? undefined : metadataMap.get(MetadataKey);
}
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinarydefineownmetadata--metadatakey-metadatavalue-o-p-
// https://github.com/rbuckton/ReflectDecorators/blob/master/spec/metadata.md#ordinarydefineownmetadata--metadatakey-metadatavalue-o-p-
function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) {

@@ -673,43 +626,30 @@ var metadataMap = GetOrCreateMetadataMap(O, P, /*create*/ true);

}
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinarymetadatakeys--o-p-
// https://github.com/rbuckton/ReflectDecorators/blob/master/spec/metadata.md#ordinarymetadatakeys--o-p-
function OrdinaryMetadataKeys(O, P) {
var ownKeys = OrdinaryOwnMetadataKeys(O, P);
var parent = GetPrototypeOf(O);
if (parent === null) {
if (parent === null)
return ownKeys;
}
var parentKeys = OrdinaryMetadataKeys(parent, P);
if (parentKeys.length <= 0) {
if (parentKeys.length <= 0)
return ownKeys;
}
if (ownKeys.length <= 0) {
if (ownKeys.length <= 0)
return parentKeys;
}
var set = new _Set();
var keys = [];
var keys = new _Set();
for (var _i = 0; _i < ownKeys.length; _i++) {
var key = ownKeys[_i];
var hasKey = set.has(key);
if (!hasKey) {
set.add(key);
keys.push(key);
}
keys.add(key);
}
for (var _a = 0; _a < parentKeys.length; _a++) {
var key = parentKeys[_a];
var hasKey = set.has(key);
if (!hasKey) {
set.add(key);
keys.push(key);
}
keys.add(key);
}
return keys;
return getKeys(keys);
}
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinaryownmetadatakeys--o-p-
// https://github.com/rbuckton/ReflectDecorators/blob/master/spec/metadata.md#ordinaryownmetadatakeys--o-p-
function OrdinaryOwnMetadataKeys(target, targetKey) {
var metadataMap = GetOrCreateMetadataMap(target, targetKey, /*create*/ false);
var keys = [];
if (metadataMap) {
metadataMap.forEach(function (_, key) { return keys.push(key); });
}
if (metadataMap)
forEach(metadataMap, function (_, key) { return keys.push(key); });
return keys;

@@ -723,3 +663,3 @@ }

function IsArray(x) {
return Array.isArray(x);
return Array.isArray ? Array.isArray(x) : x instanceof Array || Object.prototype.toString.call(x) === "[object Array]";
}

@@ -740,12 +680,8 @@ // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object-type

function ToPropertyKey(value) {
if (IsSymbol(value)) {
return value;
}
return String(value);
return IsSymbol(value) ? value : String(value);
}
function GetPrototypeOf(O) {
var proto = Object.getPrototypeOf(O);
if (typeof O !== "function" || O === functionPrototype) {
if (typeof O !== "function" || O === functionPrototype)
return proto;
}
// TypeScript doesn't set __proto__ in ES5, as it's non-standard.

@@ -758,23 +694,89 @@ // Try to determine the superclass constructor. Compatible implementations

// This is the case when in ES6 or when using __proto__ in a compatible browser.
if (proto !== functionPrototype) {
if (proto !== functionPrototype)
return proto;
}
// If the super prototype is Object.prototype, null, or undefined, then we cannot determine the heritage.
var prototype = O.prototype;
var prototypeProto = prototype && Object.getPrototypeOf(prototype);
if (prototypeProto == null || prototypeProto === Object.prototype) {
if (prototypeProto == null || prototypeProto === Object.prototype)
return proto;
}
// if the constructor was not a function, then we cannot determine the heritage.
// If the constructor was not a function, then we cannot determine the heritage.
var constructor = prototypeProto.constructor;
if (typeof constructor !== "function") {
if (typeof constructor !== "function")
return proto;
}
// if we have some kind of self-reference, then we cannot determine the heritage.
if (constructor === O) {
// If we have some kind of self-reference, then we cannot determine the heritage.
if (constructor === O)
return proto;
}
// we have a pretty good guess at the heritage.
return constructor;
}
function IteratorStep(iterator) {
var result = iterator.next();
return result.done ? undefined : result;
}
function IteratorClose(iterator) {
var f = iterator["return"];
if (f)
f.call(iterator);
}
function forEach(source, callback, thisArg) {
var entries = source.entries;
if (typeof entries === "function") {
var iterator = entries.call(source);
var result;
try {
while (result = IteratorStep(iterator)) {
var _a = result.value, key = _a[0], value = _a[1];
callback.call(thisArg, value, key, source);
}
}
finally {
if (result)
IteratorClose(iterator);
}
}
else {
var forEach_1 = source.forEach;
if (typeof forEach_1 === "function") {
forEach_1.call(source, callback, thisArg);
}
}
}
function getKeys(source) {
var keys = [];
forEach(source, function (_, key) { keys.push(key); });
return keys;
}
// naive MapIterator shim
function CreateMapIterator(keys, values, kind) {
var index = 0;
return {
next: function () {
if ((keys || values) && index < (keys || values).length) {
var current = index++;
switch (kind) {
case "key": return { value: keys[current], done: false };
case "value": return { value: values[current], done: false };
case "key+value": return { value: [keys[current], values[current]], done: false };
}
}
keys = undefined;
values = undefined;
return { value: undefined, done: true };
},
"throw": function (error) {
if (keys || values) {
keys = undefined;
values = undefined;
}
throw error;
},
"return": function (value) {
if (keys || values) {
keys = undefined;
values = undefined;
}
return { value: value, done: true };
}
};
}
// naive Map shim

@@ -787,41 +789,18 @@ function CreateMapPolyfill() {

this._values = [];
this._cache = cacheSentinel;
this._cacheKey = cacheSentinel;
this._cacheIndex = -2;
this.size = 0;
}
Object.defineProperty(Map.prototype, "size", {
get: function () {
return this._keys.length;
},
enumerable: true,
configurable: true
});
Map.prototype.has = function (key) {
if (this._find(key) >= 0) {
return true;
}
return false;
};
Map.prototype.has = function (key) { return this._find(key, /*insert*/ false) >= 0; };
Map.prototype.get = function (key) {
var index = this._find(key);
if (index >= 0) {
return this._values[index];
}
return undefined;
var index = this._find(key, /*insert*/ false);
return index >= 0 ? this._values[index] : undefined;
};
Map.prototype.set = function (key, value) {
var index = this._find(key);
if (index >= 0) {
this._keys[index] = key;
this._values[index] = value;
}
else {
this._keys.push(key);
this._values.push(value);
this._cache = key;
this._cacheIndex = this._keys.length - 1;
}
var index = this._find(key, /*insert*/ true);
this._values[index] = value;
return this;
};
Map.prototype.delete = function (key) {
var index = this._find(key);
var index = this._find(key, /*insert*/ false);
if (index >= 0) {

@@ -833,5 +812,6 @@ var size = this._keys.length;

}
this.size--;
this._keys.length--;
this._values.length--;
this._cache = cacheSentinel;
this._cacheKey = cacheSentinel;
this._cacheIndex = -2;

@@ -843,27 +823,22 @@ return true;

Map.prototype.clear = function () {
this.size = 0;
this._keys.length = 0;
this._values.length = 0;
this._cache = cacheSentinel;
this._cacheKey = cacheSentinel;
this._cacheIndex = -2;
};
Map.prototype.forEach = function (callback, thisArg) {
var size = this.size;
for (var i = 0; i < size; ++i) {
var key = this._keys[i];
var value = this._values[i];
callback.call(thisArg, value, key, this);
}
};
Map.prototype._find = function (key) {
if (this._cache === key) {
Map.prototype.keys = function () { return CreateMapIterator(this._keys, /*values*/ undefined, "key"); };
Map.prototype.values = function () { return CreateMapIterator(/*keys*/ undefined, this._values, "value"); };
Map.prototype.entries = function () { return CreateMapIterator(this._keys, this._values, "key+value"); };
Map.prototype._find = function (key, insert) {
if (this._cacheKey === key)
return this._cacheIndex;
var index = this._keys.indexOf(key);
if (index < 0 && insert) {
index = this._keys.length;
this._keys.push(key);
this._values.push(undefined);
this.size++;
}
var keys = this._keys;
var size = keys.length;
for (var i = 0; i < size; ++i) {
if (keys[i] === key) {
return this._cache = key, this._cacheIndex = i;
}
}
return this._cache = key, this._cacheIndex = -1;
return this._cacheKey = key, this._cacheIndex = index;
};

@@ -878,10 +853,4 @@ return Map;

this._map = new _Map();
this.size = 0;
}
Object.defineProperty(Set.prototype, "size", {
get: function () {
return this._map.size;
},
enumerable: true,
configurable: true
});
Set.prototype.has = function (value) {

@@ -892,13 +861,19 @@ return this._map.has(value);

this._map.set(value, value);
this.size = this._map.size;
return this;
};
Set.prototype.delete = function (value) {
return this._map.delete(value);
if (this._map.delete(value)) {
this.size--;
return true;
}
return false;
};
Set.prototype.clear = function () {
this.size = 0;
this._map.clear();
};
Set.prototype.forEach = function (callback, thisArg) {
this._map.forEach(callback, thisArg);
};
Set.prototype.keys = function () { return this._map.keys(); };
Set.prototype.values = function () { return this._map.values(); };
Set.prototype.entries = function () { return this._map.entries(); };
return Set;

@@ -918,13 +893,7 @@ })();

var table = GetOrCreateWeakMapTable(target, /*create*/ false);
if (table) {
return HashMap.has(table, this._key);
}
return false;
return table !== undefined ? HashMap.has(table, this._key) : false;
};
WeakMap.prototype.get = function (target) {
var table = GetOrCreateWeakMapTable(target, /*create*/ false);
if (table) {
return HashMap.get(table, this._key);
}
return undefined;
return table !== undefined ? HashMap.get(table, this._key) : undefined;
};

@@ -938,6 +907,3 @@ WeakMap.prototype.set = function (target, value) {

var table = GetOrCreateWeakMapTable(target, /*create*/ false);
if (table && HashMap.has(table, this._key)) {
return delete table[this._key];
}
return false;
return table !== undefined ? delete table[this._key] : false;
};

@@ -951,25 +917,15 @@ WeakMap.prototype.clear = function () {

function FillRandomBytes(buffer, size) {
for (var i = 0; i < size; ++i) {
buffer[i] = Math.random() * 255 | 0;
}
for (var i = 0; i < size; ++i)
buffer[i] = Math.random() * 0xff | 0;
return buffer;
}
function GenRandomBytes(size) {
if (typeof Uint8Array === "function") {
var data = new Uint8Array(size);
if (typeof crypto !== "undefined") {
crypto.getRandomValues(data);
}
else if (typeof msCrypto !== "undefined") {
msCrypto.getRandomValues(data);
}
else {
FillRandomBytes(data, size);
}
return data;
if (typeof crypto !== "undefined")
return crypto.getRandomValues(new Uint8Array(size));
if (typeof msCrypto !== "undefined")
return msCrypto.getRandomValues(new Uint8Array(size));
return FillRandomBytes(new Uint8Array(size), size);
}
else {
var data = new Array(size);
FillRandomBytes(data, size);
return data;
}
return FillRandomBytes(new Array(size), size);
}

@@ -984,8 +940,6 @@ function CreateUUID() {

var byte = data[offset];
if (offset === 4 || offset === 6 || offset === 8) {
if (offset === 4 || offset === 6 || offset === 8)
result += "-";
}
if (byte < 16) {
if (byte < 16)
result += "0";
}
result += byte.toString(16).toLowerCase();

@@ -997,5 +951,5 @@ }

var key;
do {
do
key = "@@WeakMap@@" + CreateUUID();
} while (HashMap.has(keys, key));
while (HashMap.has(keys, key));
keys[key] = true;

@@ -1006,5 +960,4 @@ return key;

if (!hasOwn.call(target, rootKey)) {
if (!create) {
if (!create)
return undefined;
}
Object.defineProperty(target, rootKey, { value: createDictionary() });

@@ -1015,2 +968,3 @@ }

}
// uses a heuristic used by v8 and chakra to force an object into dictionary mode.
function MakeDictionary(obj) {

@@ -1021,3 +975,3 @@ obj.__DICTIONARY_MODE__ = 1;

}
// hook global Reflect
// patch global Reflect
(function (__global) {

@@ -1024,0 +978,0 @@ if (typeof __global.Reflect !== "undefined") {

@@ -1277,3 +1277,3 @@ /*! *****************************************************************************

private _cacheIndex = -2;
get size() { return this._keys.length; }
size = 0;
has(key: K): boolean { return this._find(key, /*insert*/ false) >= 0; }

@@ -1297,2 +1297,3 @@ get(key: K): V {

}
this.size--;
this._keys.length--;

@@ -1307,2 +1308,3 @@ this._values.length--;

clear(): void {
this.size = 0;
this._keys.length = 0;

@@ -1323,2 +1325,3 @@ this._values.length = 0;

this._values.push(undefined);
this.size++;
}

@@ -1334,7 +1337,22 @@ return this._cacheKey = key, this._cacheIndex = index;

private _map = new _Map<any, any>();
get size() { return this._map.size; }
has(value: T): boolean { return this._map.has(value); }
add(value: T): Set<T> { return this._map.set(value, value), this; }
delete(value: T): boolean { return this._map.delete(value); }
clear(): void { this._map.clear(); }
size = 0;
has(value: T): boolean {
return this._map.has(value);
}
add(value: T): Set<T> {
this._map.set(value, value);
this.size = this._map.size;
return this;
}
delete(value: T): boolean {
if (this._map.delete(value)) {
this.size--;
return true;
}
return false;
}
clear(): void {
this.size = 0;
this._map.clear();
}
keys() { return this._map.keys(); }

@@ -1341,0 +1359,0 @@ values() { return this._map.values(); }

@@ -508,3 +508,3 @@ /*! *****************************************************************************

function deleteMetadata(metadataKey, target, targetKey) {
// https://github.com/rbuckton/ReflectDecorators/blob/master/specs/metadata.md#deletemetadata-metadatakey-p-
// https://github.com/rbuckton/ReflectDecorators/blob/master/spec/metadata.md#deletemetadata-metadatakey-p-
if (!IsObject(target))

@@ -559,3 +559,3 @@ throw new TypeError();

}
// https://github.com/rbuckton/ReflectDecorators/blob/master/specs/metadata.md#getorcreatemetadatamap--o-p-create-
// https://github.com/rbuckton/ReflectDecorators/blob/master/spec/metadata.md#getorcreatemetadatamap--o-p-create-
function GetOrCreateMetadataMap(target, targetKey, create) {

@@ -578,3 +578,3 @@ var targetMetadata = Metadata.get(target);

}
// https://github.com/rbuckton/ReflectDecorators/blob/master/specs/metadata.md#ordinaryhasmetadata--metadatakey-o-p-
// https://github.com/rbuckton/ReflectDecorators/blob/master/spec/metadata.md#ordinaryhasmetadata--metadatakey-o-p-
function OrdinaryHasMetadata(MetadataKey, O, P) {

@@ -587,3 +587,3 @@ var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P);

}
// https://github.com/rbuckton/ReflectDecorators/blob/master/specs/metadata.md#ordinaryhasownmetadata--metadatakey-o-p-
// https://github.com/rbuckton/ReflectDecorators/blob/master/spec/metadata.md#ordinaryhasownmetadata--metadatakey-o-p-
function OrdinaryHasOwnMetadata(MetadataKey, O, P) {

@@ -593,3 +593,3 @@ var metadataMap = GetOrCreateMetadataMap(O, P, /*create*/ false);

}
// https://github.com/rbuckton/ReflectDecorators/blob/master/specs/metadata.md#ordinarygetmetadata--metadatakey-o-p-
// https://github.com/rbuckton/ReflectDecorators/blob/master/spec/metadata.md#ordinarygetmetadata--metadatakey-o-p-
function OrdinaryGetMetadata(MetadataKey, O, P) {

@@ -602,3 +602,3 @@ var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P);

}
// https://github.com/rbuckton/ReflectDecorators/blob/master/specs/metadata.md#ordinarygetownmetadata--metadatakey-o-p-
// https://github.com/rbuckton/ReflectDecorators/blob/master/spec/metadata.md#ordinarygetownmetadata--metadatakey-o-p-
function OrdinaryGetOwnMetadata(MetadataKey, O, P) {

@@ -608,3 +608,3 @@ var metadataMap = GetOrCreateMetadataMap(O, P, /*create*/ false);

}
// https://github.com/rbuckton/ReflectDecorators/blob/master/specs/metadata.md#ordinarydefineownmetadata--metadatakey-metadatavalue-o-p-
// https://github.com/rbuckton/ReflectDecorators/blob/master/spec/metadata.md#ordinarydefineownmetadata--metadatakey-metadatavalue-o-p-
function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) {

@@ -614,3 +614,3 @@ var metadataMap = GetOrCreateMetadataMap(O, P, /*create*/ true);

}
// https://github.com/rbuckton/ReflectDecorators/blob/master/specs/metadata.md#ordinarymetadatakeys--o-p-
// https://github.com/rbuckton/ReflectDecorators/blob/master/spec/metadata.md#ordinarymetadatakeys--o-p-
function OrdinaryMetadataKeys(O, P) {

@@ -637,3 +637,3 @@ var ownKeys = OrdinaryOwnMetadataKeys(O, P);

}
// https://github.com/rbuckton/ReflectDecorators/blob/master/specs/metadata.md#ordinaryownmetadatakeys--o-p-
// https://github.com/rbuckton/ReflectDecorators/blob/master/spec/metadata.md#ordinaryownmetadatakeys--o-p-
function OrdinaryOwnMetadataKeys(target, targetKey) {

@@ -777,8 +777,4 @@ var metadataMap = GetOrCreateMetadataMap(target, targetKey, /*create*/ false);

this._cacheIndex = -2;
this.size = 0;
}
Object.defineProperty(Map.prototype, "size", {
get: function () { return this._keys.length; },
enumerable: true,
configurable: true
});
Map.prototype.has = function (key) { return this._find(key, /*insert*/ false) >= 0; };

@@ -802,2 +798,3 @@ Map.prototype.get = function (key) {

}
this.size--;
this._keys.length--;

@@ -812,2 +809,3 @@ this._values.length--;

Map.prototype.clear = function () {
this.size = 0;
this._keys.length = 0;

@@ -829,2 +827,3 @@ this._values.length = 0;

this._values.push(undefined);
this.size++;
}

@@ -841,12 +840,23 @@ return this._cacheKey = key, this._cacheIndex = index;

this._map = new _Map();
this.size = 0;
}
Object.defineProperty(Set.prototype, "size", {
get: function () { return this._map.size; },
enumerable: true,
configurable: true
});
Set.prototype.has = function (value) { return this._map.has(value); };
Set.prototype.add = function (value) { return this._map.set(value, value), this; };
Set.prototype.delete = function (value) { return this._map.delete(value); };
Set.prototype.clear = function () { this._map.clear(); };
Set.prototype.has = function (value) {
return this._map.has(value);
};
Set.prototype.add = function (value) {
this._map.set(value, value);
this.size = this._map.size;
return this;
};
Set.prototype.delete = function (value) {
if (this._map.delete(value)) {
this.size--;
return true;
}
return false;
};
Set.prototype.clear = function () {
this.size = 0;
this._map.clear();
};
Set.prototype.keys = function () { return this._map.keys(); };

@@ -853,0 +863,0 @@ Set.prototype.values = function () { return this._map.values(); };

{
"compilerOptions": {
"target": "es5",
"target": "es3",
"noImplicitAny": true,

@@ -5,0 +5,0 @@ "sourceMap": true,

{
"compilerOptions": {
"target": "es5",
"target": "es3",
"noImplicitAny": true,

@@ -5,0 +5,0 @@ "sourceMap": true

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc