is-options

1.0.2 • Public • Published

is-options

Easily check if input is an options map

npm install is-options

Build Status

Usage

var isOptions = require('is-options')

thing('', {foo: true}) // key='', opts={foo: true}
thing({foo: true}) // key=undefined, opts={foo: true}
thing(Buffer.from('buf'), {foo: true}) // key=Buffer('buf'), opts={foo: true}

function thing (optionalKey, opts) {
  if (isOptions(optionalKey)) {
    opts = optionalKey
    optionalKey = undefined
  }

  console.log('key', optionalKey)
  console.log('options', opts)
}

API

bool = isOptions(obj)

Returns true is obj is an object and not a buffer

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i is-options

Weekly Downloads

7,008

Version

1.0.2

License

MIT

Unpacked Size

2.94 kB

Total Files

6

Last publish

Collaborators

  • mafintosh