0.1.1 • Published 5 years ago
@ganuz/get-metadata v0.1.1
@ganuz/get-metadata
Get Metadata is package from Ganuz library
Install
$ yarn add @ganuz/get-metadata
Or
$ npm install --save @ganuz/get-metadata
Use
Module
import {
default as getMetadata
} from '@ganuz/get-metadata';
Browser
<script src="https://unpkg.com/@ganuz/get-metadata/bundle.umd.min.js"></script>
let {
getMetadata
} = G;
Examples
getMetadata('foo', NaN, 'some'); // throw TypeError
getMetadata(Symbol('foo'), {}, Symbol('some')); // => undefined
getMetadata('foo', class {}); // => undefined
let some = Object.create(null);
let other = Object.create(some);
defineMetadata(Symbol.for('colors'), {red: true}, some);
defineMetadata(String, 'cool', other, Symbol.for('prop'));
getMetadata(Symbol.for('colors'), some); // => {red: true}
getMetadata(String, some, Symbol.for('prop')); // => undefined
getMetadata(Symbol.for('colors'), other); // => {red: true}
getMetadata(String, other, Symbol.for('prop')); // => 'cool'
defineMetadata(String, 'fun', some, Symbol.for('prop'));
getMetadata(String, some, Symbol.for('prop')); // => 'fun'
getMetadata(String, other, Symbol.for('prop')); // => 'cool'
Note: It is based on es6 WeakMap
and Map
no need for polyfill (built-in library support).
License
Copyright © Yisrael Eliev, Licensed under the MIT license.