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

Dependencies (2)

Dev Dependencies (4)

Package Sidebar

Install

npm i normalize-options

Weekly Downloads

2

Version

1.0.0

License

ISC

Last publish

Collaborators

  • jameswomack