metadata-utils
Convenience utils for reflected metadata.
Installation
-
Run
npm i @keenondrums/metadata-utils reflect-metadata
-
Add import 'reflect-metadata'
to the root of your application
API
getMetadataAndCache
Gets metadata from the prototype (using Relect.getMetadata) and sets it as own metadata. Useful to enhance performance for retrieving metadata from ancestors. Has the same signature as Relect.getMetadata.
import 'reflect-metadata'
import { getMetadataAndCache } from '@keenondrums/metadata-utils'
class Parent {}
Reflect.defineMetadata('key', 'value', Parent)
Reflect.getOwnMetadata('key', Parent)
getMetadataAndCache('key', Parent)
class Child extends Parent {}
Reflect.getOwnMetadata('key', Child)
getMetadataAndCache('key', Child)
Reflect.getOwnMetadata('key', Child)