@injex/stdlib
Advanced tools
Comparing version 4.0.0-alpha.0 to 4.0.0-alpha.1
@@ -1,2 +0,1 @@ | ||
import "reflect-metadata"; | ||
export declare type MetadataHandlers<T> = { | ||
@@ -3,0 +2,0 @@ ensureMetadata: (target: any) => T; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createMetadataHandlers = void 0; | ||
require("reflect-metadata"); | ||
const _metadata = new WeakMap(); | ||
function createMetadataHandlers(metadataKey) { | ||
function ensureMetadata(target) { | ||
if (!hasMetadata(target)) { | ||
Reflect.defineMetadata(metadataKey, {}, target); | ||
_metadata.set(target, { | ||
[metadataKey]: {} | ||
}); | ||
} | ||
@@ -17,6 +19,6 @@ return getMetadata(target); | ||
function getMetadata(target) { | ||
return Reflect.getOwnMetadata(metadataKey, target); | ||
return _metadata.get(target)?.[metadataKey]; | ||
} | ||
function hasMetadata(target) { | ||
return Reflect.hasOwnMetadata(metadataKey, target); | ||
return _metadata.has(target); | ||
} | ||
@@ -23,0 +25,0 @@ function pushMetadata(target, key, value) { |
{ | ||
"name": "@injex/stdlib", | ||
"version": "4.0.0-alpha.0", | ||
"version": "4.0.0-alpha.1", | ||
"description": "", | ||
@@ -40,5 +40,2 @@ "keywords": [], | ||
"homepage": "https://github.com/uditalias/injex#readme", | ||
"dependencies": { | ||
"reflect-metadata": "^0.1.13" | ||
}, | ||
"devDependencies": { | ||
@@ -51,3 +48,3 @@ "jest": "^26.4.2", | ||
}, | ||
"gitHead": "c573d14be7e2530d19be7ebd7a6d4a8faf45b507" | ||
"gitHead": "9cf3e7a273415b811e06f4c98b38bc87755872ca" | ||
} |
@@ -1,3 +0,1 @@ | ||
import "reflect-metadata"; | ||
export type MetadataHandlers<T> = { | ||
@@ -12,6 +10,10 @@ ensureMetadata: (target: any) => T; | ||
const _metadata = new WeakMap(); | ||
export function createMetadataHandlers<T = any>(metadataKey: symbol): MetadataHandlers<T> { | ||
function ensureMetadata(target): T { | ||
if (!hasMetadata(target)) { | ||
Reflect.defineMetadata(metadataKey, {}, target); | ||
_metadata.set(target, { | ||
[metadataKey]: {} | ||
}); | ||
} | ||
@@ -28,7 +30,7 @@ | ||
function getMetadata(target): T { | ||
return Reflect.getOwnMetadata(metadataKey, target); | ||
return _metadata.get(target)?.[metadataKey]; | ||
} | ||
function hasMetadata(target): boolean { | ||
return Reflect.hasOwnMetadata(metadataKey, target); | ||
return _metadata.has(target); | ||
} | ||
@@ -35,0 +37,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
0
591
27943
- Removedreflect-metadata@^0.1.13
- Removedreflect-metadata@0.1.14(transitive)