包详细信息

is-kindof

tunnckocore109MIT3.0.1

Check type of given javascript value. Support promises, generators, streams, and native types. Built on [kind-of][] lib.

check, functional, is, kind

自述文件

is-kindof npmjs.com The MIT License npm downloads

Check type of given javascript value. Support promises, generators, streams, and native types. Built on kind-of lib.

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

Install

Install with npm

$ npm i is-kindof --save

Usage

For more use-cases see the tests

var is = require('is-kindof')

is.array([1, 2]) // => true
is.boolean(true) // => true
is.buffer(new Buffer('foo')) // => true
is.date(new Date()) // => true
is.error(new Error('foo')) // => true
is.function(function noop () {}) // => true
is.generator((function * gen () { yield 42 })()) // => true
is.generatorfunction(function * genFn () {}) // => true
is.map(new Map()) // => true
is.null(null) // => true
is.number(123) // => true
is.object({ a: 'b' }) // => true
is.promise(Promise.resolve(123)) // => true
is.regexp(new RegExp('aa')) // => true
is.set(new Set()) // => true
is.stream(through2()) // => true
is.string('fooo') // => true
is.symbol(Symbol()) // => true
is.undefined(undefined) // => true
is.weakmap(new WeakMap()) // => true
is.weakset(new WeakSet()) // => true

Related

  • always-done: Handle completion and errors with elegance! Support for streams, callbacks, promises, child processes, async/await and sync functions. A drop-in replacement for async-done - pass 100… more | homepage
  • is-async-function: Is function really asynchronous function? Trying to guess that based on check if common-callback-names exists as function arguments names or you can pass your custom. | homepage
  • is-callback-function: Returns true if function is a callback. Checks its name is one of common-callback-names - callback, cb, cb, callback, next, done, they can be customized… more | homepage
  • kind-of-extra: Additional functionality to kind-of type check utility. Support promises, generators, streams, errors. | 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
  • kind-of: Get the native type of a value. | homepage
  • minibase: MiniBase is minimalist approach to Base - @node-base, the awesome framework. Foundation for building complex APIs with small units called plugins. Works well with most… more | homepage
  • mukla: Small, parallel and fast test framework with suppport for async/await, promises, callbacks, streams and observables. Targets and works at node.js v0.10 and above. | homepage
  • to-callback: Converts result-first callbacks to classic (node.js-style) error-first callbacks with 3 lines of code. Useful when you want to promisify result-first APIs (like emitter.on). Inspired by… more | 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

更新日志

Change Log

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

3.0.1 (2016-11-06)

Bug Fixes

  • package: update description (8917c62)

3.0.0 (2016-11-05)

Chores

  • drop support for Node.js 0.10 (723ce06)

Code Refactoring

  • simplify: update boilerplate and simplify (ef6a9d6)

BREAKING CHANGES

  • simplify: exports and module.exports only methods for types - is.string(val),

is.function(val), is.object(val) and etc. because before that it was too complex and needless. Now

it is clean and explicit.

  • This module no longer supports Node.js 0.10

2.1.1 - 2015-07-14

  • Release v2.1.1 / npm@v2.1.1
  • update .editorconfig
  • add tests for buffer type
  • add ref to kind-of and kind-of-types libs
  • switch to use kind-of-types
  • update readme

2.1.0 - 2015-06-30

  • Release v2.1.0 / npm@v2.1.0
  • update related
  • remove most generator function aliases (they are ugly)
  • move tests to test/, thanks @codeclimate for complexity report
  • fix date in changelog
  • pull out some logic to kind-of-extra and switch to use it

2.0.0 - 2015-06-29

  • Release v2.0.0 / npm@v2.0.0
  • add new tests that use plugin-error
  • add related
  • update readme
  • update keywords
  • add link for few aliases in readme
  • fix deps
  • update readme
  • add tests, update travis
  • refactor
    • bump kind-of@v2
    • drop support for arguments and isArguments, use is-arguments instead
    • add support for multiple check types, e.g. is(val, [type, type, type])
    • add support for promises, generators and other es6 features like Set, WeakMap and etc.
    • better api - four variants, e.g.
      • is(val, type) - where type can be array of types
      • is(val).number() - where will return true if val is number
      • is().number(val)
      • is.number(val)

1.0.0 - 2015-03-26

  • Release v1.0.0 / npm@v1.0.0
  • lint
  • add keywords
  • docs, add isError

0.0.0 - 2015-03-25

  • first commits / npm@v0.0.0