@injex/stdlib
Advanced tools
Comparing version 2.1.0 to 3.0.0-alpha.0
@@ -0,1 +1,2 @@ | ||
import "reflect-metadata"; | ||
export declare type MetadataHandlers<T> = { | ||
@@ -7,3 +8,4 @@ ensureMetadata: (target: any) => T; | ||
pushMetadata: (target: any, key: keyof T, value: any) => void; | ||
forEachProtoMetadata: (target: any, callback: (proto: object, metadata: T) => void) => void; | ||
}; | ||
export declare function createMetadataHandlers<T = any>(metadataKey: symbol): MetadataHandlers<T>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createMetadataHandlers = void 0; | ||
require("reflect-metadata"); | ||
function createMetadataHandlers(metadataKey) { | ||
function ensureMetadata(target) { | ||
target[metadataKey] = target[metadataKey] || {}; | ||
return target[metadataKey]; | ||
if (!hasMetadata(target)) { | ||
Reflect.defineMetadata(metadataKey, {}, target); | ||
} | ||
return getMetadata(target); | ||
} | ||
function setMetadata(target, key, value) { | ||
ensureMetadata(target); | ||
target[metadataKey][key] = value; | ||
var metadata = ensureMetadata(target); | ||
metadata[key] = value; | ||
} | ||
function getMetadata(target) { | ||
return target[metadataKey]; | ||
return Reflect.getOwnMetadata(metadataKey, target); | ||
} | ||
function hasMetadata(target) { | ||
return target && target instanceof Object && metadataKey in target; | ||
return Reflect.hasOwnMetadata(metadataKey, target); | ||
} | ||
@@ -26,2 +29,12 @@ function pushMetadata(target, key, value) { | ||
} | ||
function forEachProtoMetadata(target, callback) { | ||
var __proto__ = target === null || target === void 0 ? void 0 : target.__proto__; | ||
while (__proto__) { | ||
var meta = getMetadata(__proto__); | ||
if (meta) { | ||
callback(__proto__, meta); | ||
} | ||
__proto__ = __proto__.__proto__; | ||
} | ||
} | ||
return { | ||
@@ -33,2 +46,3 @@ ensureMetadata: ensureMetadata, | ||
pushMetadata: pushMetadata, | ||
forEachProtoMetadata: forEachProtoMetadata, | ||
}; | ||
@@ -35,0 +49,0 @@ } |
{ | ||
"name": "@injex/stdlib", | ||
"version": "2.1.0", | ||
"version": "3.0.0-alpha.0", | ||
"description": "", | ||
@@ -40,2 +40,3 @@ "keywords": [], | ||
"dependencies": { | ||
"reflect-metadata": "^0.1.13", | ||
"tslib": "^2.0.1" | ||
@@ -49,3 +50,3 @@ }, | ||
}, | ||
"gitHead": "1e2aaf520e73125f5108801bbc9c8c15550c5349" | ||
"gitHead": "c52d04648f8dbd81e09f5e09f7770e55eac2014f" | ||
} |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
19781
323
2
1
+ Addedreflect-metadata@^0.1.13
+ Addedreflect-metadata@0.1.14(transitive)