Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

typed-reflector

nanahira201MIT1.0.11TypeScript support: included

Metadata reflector with typing support.

reflect, reflector, reflect-metadata

readme

typed-reflector

Metadata reflector with typing support.

API

Type Map

Either Reflector or Metadata Setter accepts 2 type arguments. The first one is the type map of common types, while the second one is the type map of arrays.

Reflector

  • Reflector.get(metadataKey, instance, key) Fetches the metadata of instance.

  • Reflector.getArray(metadataKey, instance, key) Fetches the array metadata of instance. Will return empty array if not exists.

  • Reflector.getProperty(metadataKey, instance, key, alternate = instance) Fetches the array metadata of instance from both class and property. The last parameter is an alternate source object for fetching metadata from class.

Metadata Setter

  • MetadataSetter.set(metadataKey, value) Sets and overrides the MetadataSetter.

  • MetadataSetter.append(metadataKey, value) Append to the the metadata array. The array would be created if not exists.

  • MetadataSetter.appendUnique(metadataKey, value) Same as above but no duplicate values.

  • MetadataSetter.concat(metadataKey, value) The value must be an array, and the metadata array would be joined together.