0.0.2 • Published 6 years ago
key-reflector v0.0.2
Installation
npm install key-reflector --saveor
yarn add key-reflectorCDN:
<script src="https://unpkg.com/key-reflector/dist/umd/key-reflector.min.js"></script>Usage
Basic
import KeyReflector from 'key-reflector'
KeyReflector.reflectKeys(['FOO', 'BAR', 'BAZ'])will returns:
{
FOO: 'FOO',
BAR: 'BAR',
BAZ: 'BAZ',
}Syntax
KeyReflector.reflectKeys(keys[, options])- keys
- Type:
[String] - Keys to be reflected. Returns an object with the same key and value for each key.
- If
keysis null, it will return an empty object{}.
- Type:
- options (optional)
- Type:
Object - The options for
reflectKeys. See more in Options.
- Type:
Options
valuePrefix
- Type:
String - Default:
''
Prefix to be added to each value.
Example:
KeyReflector.reflectKeys(['FOO', 'BAR', 'BAZ'], { valuePrefix: 'PREFIX_'})returns:
{
FOO: 'PREFIX_FOO',
BAR: 'PREFIX_BAR',
BAZ: 'PREFIX_BAZ',
}