0.0.2
Lightweight metadata reflection for deno
Repository
Current version released
4 years ago
Versions
Reflection
Lightweight metadata reflection api
This module is a extended version of @abraham/reflection.
Usage :
import "https://deno.land/x/reflection/mod.ts"; // extend Reflect Object
const target = {};
Reflect.defineMetadata("key", "value", target);
Reflect.getMetadata("key", target); // Result => "value"
Extended Methods :
Reflect.getOwnMetadataKeys
const target = { property: "propValue" };
Reflect.defineMetadata("firstKey", "firstValue", target);
Reflect.defineMetadata("secondKey", "secondValue", target);
Reflect.defineMetadata("firstPropKey", "firstPropValue", target, "property");
Reflect.defineMetadata("secondPropKey", "secondPropValue", target, "property");
Reflect.getOwnMetadataKeys(target);
// Result => ["firstKey", "secondKey" ]
console.log(Reflect.getOwnMetadataKeys(target));
// Result => ["firstKey", "secondKey" ]
console.log(Reflect.getOwnMetadataKeys(target, "property"));
// Result => ["firstPropKey", "secondPropKey" ]
Reflect.getMetaDataKey
class Parent {}
class Child extends Parent {}
Reflect.defineMetadata("key", "value", Parent);
Reflect.defineMetadata("propKey", "propValue", Parent, "property");
console.log(Reflect.getMetadataKeys(Child));
//Result => ["key" ]
console.log(Reflect.getMetadataKeys(Child, "property"));
//Result => ["propKey" ]