Socket
Socket
Sign inDemoInstall

is-options

Package Overview
Dependencies
1
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    is-options

Easily check if input is an options map


Version published
Maintainers
1
Install size
35.3 kB
Created

Readme

Source

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

FAQs

Last updated on 22 Nov 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc