npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

abbrev-kindof

1.0.5 • Public • Published

abbrev-kindof npmjs.com The MIT License

Use abbreviations for checking type of given value. Like kindof(val, 'soa') to check that value is string, object or array.

code climate standard code style travis build status coverage status dependency status

Install

npm i abbrev-kindof --save

Usage

For more use-cases see the tests

const abbrevKindof = require('abbrev-kindof')

abbrevKindof

Check type of a val with abbreviations.

Params

  • val {Mixed}: value to check
  • type {String|Array}: list of single-letter (abbr) types
  • returns {Boolean}: if true, so val match one of the abbreviated types

Example

// `soa` here means - string, object or array
abbrevKindof(123, 'soa')          //=> false
abbrevKindof('foo bar', 'soa')    //=> true
abbrevKindof({a: 123}, 'soa')     //=> true
abbrevKindof(['c', 'd'], 'soa')   //=> true

Available abbreviations

Using map-types

  • a for array
  • b for boolean
  • f for function
  • n for number
  • o for object
  • r for regexp
  • s for string
  • y for symbol

Related Libs

  • assert-kindof: Check native type of the given value and throw TypeError if not okey. Expressive, elegant, behavior-driven API, good descriptive default error messages, simple and clean syntax. | homepage
  • is-kindof: Check type of given javascript value. Support promises, generators, streams, and native types. Thin wrapper around kind-of module. | homepage
  • kind-error: Base class for easily creating meaningful and quiet by default Error classes with sane defaults and assertion in mind. | homepage
  • kind-of: Get the native type of a value. | homepage
  • kind-of-extra: Extends kind-of type check utility with support for promises, generators, streams and errors. Like kindof(Promise.resolve(1)) === 'promise' and etc. | homepage
  • kind-of-types: List of all javascript types. Used and useful for checking, validation, sanitizing and testing. Like isStream, isPromise, isWeakset and etc. | homepage

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckocore.tk keybase tunnckocore tunnckoCore npm tunnckoCore twitter tunnckoCore github

install

npm i abbrev-kindof

Downloadsweekly downloads

21

version

1.0.5

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
Report a vulnerability