Socket
Socket
Sign inDemoInstall

is-options

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

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
Created
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

Package last updated on 22 Nov 2021

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc