nuǝW pǝuoᴉʇᴉsoԀ ʎlǝʌᴉʇɐƃǝN
Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

normalize-options

1.0.0 • Public • Published

normalize-options

Helper for string or object methods

Installation

> npm i normalize-options -SE

Usage

var normalizeOptions = require('normalize-options'),
    Restify = require('restify')

function loadServer(options) {
  options = normalizeOptions(options, 'server')
  
  doSomething(options.server)
}

var server = Restify.createServer()
loadServer(server)

Docs

  • It will convert a string to an object at the passed key

    • normalizeOptions('foo', 'bar') == { bar: 'foo' }
  • It will return an object unmodified if the key is present

    • normalizeOptions({ bar: 'foo' }, 'bar') == { bar: 'foo' }
  • It will throw if the desired key is not present

    • normalizeOptions({ bar: 'foo' }, 'baz') == ReferenceError

Install

npm i normalize-options

DownloadsWeekly Downloads

6

Version

1.0.0

License

ISC

Last publish

Collaborators

  • avatar