Awesome
abbrev-kindof
Use abbreviations for checking type of given value. Like
kindof(val, 'soa')
to check that value is string, object or array.
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 checktype
{String|Array}: list of single-letter (abbr) typesreturns
{Boolean}: iftrue
, soval
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
forarray
b
forboolean
f
forfunction
n
fornumber
o
forobject
r
forregexp
s
forstring
y
forsymbol
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. Likekindof(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.