0.0.2 • Published 5 years ago

key-reflector v0.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

Installation

npm install key-reflector --save

or

yarn add key-reflector

CDN:

<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 keys is null, it will return an empty object {}.
  • options (optional)
    • Type: Object
    • The options for reflectKeys. See more in Options.

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',
}

License

MIT