$ gnpm install is-options
Easily check if input is an options map
npm install is-options
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)
}
bool = isOptions(obj)
Returns true is obj
is an object and not a buffer
MIT
Copyright 2013 - present © cnpmjs.org | Home |