Gathering detailed insights and metrics for assert-kindof
Gathering detailed insights and metrics for assert-kindof
Gathering detailed insights and metrics for assert-kindof
Gathering detailed insights and metrics for assert-kindof
npm install assert-kindof
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
4 Stars
42 Commits
3 Watching
16 Branches
1 Contributors
Updated on 13 Sept 2022
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-50%
1
Compared to previous day
Last week
50%
9
Compared to previous week
Last month
-67.6%
46
Compared to previous month
Last year
-24.3%
929
Compared to previous year
Check native type of value and throw AssertionError if not okey. Clean stack traces. Simplicity. Built on is-kindof.
You might also be interested in kind-of-extra.
is.not.array(val)
actual
, expected
, operator
and value
props(TOC generated by verb using markdown-toc)
Install with npm
$ npm install assert-kindof --save
or install using yarn
$ yarn add assert-kindof
For more use-cases see the tests
1const assertKindof = require('assert-kindof')
All methods from is-kindof are also exposed, so check its docs. That
.is
is object with methods with same names as in this package.
Example
1var assertKindof = require('assert-kindof') 2 3assertKindof.is.array(123) // => false 4assertKindof.is.array([11, 22, 33]) // => true 5 6assertKindof.array([11, 22, 33]) // => not throws 7 8try { 9 assertKindof.array(123) // => AssertionError: number !== array 10} catch (err) { 11 console.log(err.message) // => 'number !== array' 12}
Check
value
is array, if not throws AssertionError.
Params
value
{any}: value to be checkedmessage
{String|Function}: error message; if function gets fn(actual, expected, value)
signaturereturns
{Undefined}: nothing is returned, throws if not okeyExample
1var assert = require('assert-kindof') 2assert.array([1, 2, 3]) // => not throws 3assert.array(123) // => AssertionError: number !== array 4 5try { 6 assert.array({ foo: 'bar' }, 'expect `val` to be {expected}') 7} catch (err) { 8 console.log(err.message) // => 'expect `val` to be array' 9 console.log(err.actual) // => object 10 console.log(err.expected) // => array 11 console.log(err.value) // => { foo: 'bar' } 12}
Check
value
is boolean, if not throws AssertionError.
Params
value
{any}: value to be checkedmessage
{String|Function}: error message; if function gets fn(actual, expected, value)
signaturereturns
{Undefined}: nothing is returned, throws if not okeyExample
1var assert = require('assert-kindof') 2assert.boolean(true) // => not throws 3assert.boolean(false) // => not throws 4assert.boolean(123) // => AssertionError: number !== boolean 5assert.boolean(null) // => AssertionError: null !== boolean 6 7try { 8 assert.boolean([1, 2, 3], 'expect `val` to be {expected}') 9} catch (err) { 10 console.log(err.message) // => 'expect `val` to be boolean' 11 console.log(err.actual) // => array 12 console.log(err.expected) // => boolean 13 console.log(err.value) // => [1, 2, 3] 14}
Check
value
is buffer, if not throws AssertionError.
Params
value
{any}: value to be checkedmessage
{String|Function}: error message; if function gets fn(actual, expected, value)
signaturereturns
{Undefined}: nothing is returned, throws if not okeyExample
1var assert = require('assert-kindof') 2assert.buffer(new Buffer('foo')) // => not throws 3assert.buffer(123) // => AssertionError: number !== buffer 4 5try { 6 assert.buffer(true, 'expect `val` to be {expected}') 7} catch (err) { 8 console.log(err.message) // => 'expect `val` to be buffer' 9 console.log(err.actual) // => boolean 10 console.log(err.expected) // => buffer 11 console.log(err.value) // => true 12}
Check
value
is date, if not throws AssertionError.
Params
value
{any}: value to be checkedmessage
{String|Function}: error message; if function gets fn(actual, expected, value)
signaturereturns
{Undefined}: nothing is returned, throws if not okeyExample
1var assert = require('assert-kindof') 2assert.date(new Date()) // => not throws 3assert.date(123) // => AssertionError: number !== date 4 5try { 6 assert.date({ a: 'b' }, 'expect `val` to be {expected}') 7} catch (err) { 8 console.log(err.message) // => 'expect `val` to be date' 9 console.log(err.actual) // => object 10 console.log(err.expected) // => date 11 console.log(err.value) // => { a: 'b' } 12}
Check
value
is error, if not throws AssertionError.
Params
value
{any}: value to be checkedmessage
{String|Function}: error message; if function gets fn(actual, expected, value)
signaturereturns
{Undefined}: nothing is returned, throws if not okeyExample
1var assert = require('assert-kindof') 2assert.error(new Error()) // => not throws 3assert.error(new TypeError()) // => not throws 4assert.error(123) // => AssertionError: number !== error 5 6try { 7 assert.error({ a: 'b' }, 'expect `val` to be {expected}') 8} catch (err) { 9 console.log(err.message) // => 'expect `val` to be error' 10 console.log(err.actual) // => object 11 console.log(err.expected) // => error 12 console.log(err.value) // => { a: 'b' } 13}
Check
value
is function, if not throws AssertionError.
Params
value
{any}: value to be checkedmessage
{String|Function}: error message; if function gets fn(actual, expected, value)
signaturereturns
{Undefined}: nothing is returned, throws if not okeyExample
1var assert = require('assert-kindof') 2assert.function(function noop () {}) // => not throws 3assert.function((a, b) => {}) // => not throws 4assert.function(123) // => AssertionError: number !== error 5 6assert.function(function * noop () {}) 7// => AssertionError: generatorfunction !== function 8 9try { 10 assert.function({ a: 'b' }, 'expect `val` to be {expected}') 11} catch (err) { 12 console.log(err.message) // => 'expect `val` to be function' 13 console.log(err.actual) // => object 14 console.log(err.expected) // => function 15 console.log(err.value) // => { a: 'b' } 16}
Check
value
is generator, if not throws AssertionError.
Params
value
{any}: value to be checkedmessage
{String|Function}: error message; if function gets fn(actual, expected, value)
signaturereturns
{Undefined}: nothing is returned, throws if not okeyExample
1var generator = (function * gen () { yield 42 })() 2var genFn = function * genFn () {} 3var noop = () => { return 123 } 4 5assert.generator(generator) // => not throws 6assert.generator(genFn) // => AssertionError: generatorfunction !== generator 7assert.generator(noop) // => AssertionError: function !== generator 8assert.generator(123) // => AssertionError: number !== generator 9 10try { 11 assert.generator({ a: 'b' }, 'expect `val` to be {expected}') 12} catch (err) { 13 console.log(err.message) // => 'expect `val` to be generator' 14 console.log(err.actual) // => object 15 console.log(err.expected) // => generator 16 console.log(err.value) // => { a: 'b' } 17}
Check
value
is generator function, if not throws AssertionError.
Params
value
{any}: value to be checkedmessage
{String|Function}: error message; if function gets fn(actual, expected, value)
signaturereturns
{Undefined}: nothing is returned, throws if not okeyExample
1var generator = (function * gen () { yield 42 })() 2var genFn = function * genFn () {} 3var noop = () => { return 123 } 4 5assert.generatorfunction(genFn) // => not throws 6 7assert.generatorfunction(generator) // => AssertionError: generator !== generatorfunction 8assert.generatorfunction(noop) // => AssertionError: function !== generatorfunction 9assert.generatorfunction(123) // => AssertionError: number !== generatorfunction 10 11try { 12 assert.generatorfunction({ a: 'b' }, 'expect `val` to be {expected}') 13} catch (err) { 14 console.log(err.message) // => 'expect `val` to be generatorfunction' 15 console.log(err.actual) // => object 16 console.log(err.expected) // => generatorfunction 17 console.log(err.value) // => { a: 'b' } 18}
Check
value
is ES2015/ES6 Map, if not throws AssertionError.
Params
value
{any}: value to be checkedmessage
{String|Function}: error message; if function gets fn(actual, expected, value)
signaturereturns
{Undefined}: nothing is returned, throws if not okeyExample
1var assert = require('assert-kindof') 2assert.map(new Map()) // => not throws 3assert.map(new WeakMap()) // => AssertionError: weakmap !== map 4assert.map(123) // => AssertionError: number !== map 5 6try { 7 assert.map(123, 'expect `val` to be {expected}') 8} catch (err) { 9 console.log(err.message) // => 'expect `val` to be map' 10 console.log(err.actual) // => number 11 console.log(err.expected) // => map 12 console.log(err.value) // => { a: 'b' } 13}
Check
value
is null, if not throws AssertionError.
Params
value
{any}: value to be checkedmessage
{String|Function}: error message; if function gets fn(actual, expected, value)
signaturereturns
{Undefined}: nothing is returned, throws if not okeyExample
1var assert = require('assert-kindof') 2assert.null(null) // => not throws 3assert.null({ a: 'b' }) // => AssertionError: object !== null 4assert.null(123) // => AssertionError: number !== null 5 6try { 7 assert.null(123, 'expect `val` to be {expected}') 8} catch (err) { 9 console.log(err.message) // => 'expect `val` to be null' 10 console.log(err.actual) // => number 11 console.log(err.expected) // => null 12 console.log(err.value) // => 123 13}
Check
value
is number, if not throws AssertionError.
Params
value
{any}: value to be checkedmessage
{String|Function}: error message; if function gets fn(actual, expected, value)
signaturereturns
{Undefined}: nothing is returned, throws if not okeyExample
1var assert = require('assert-kindof') 2assert.number(123) // => not throws 3assert.number({ a: 'b' }) // => AssertionError: object !== number 4assert.number(null) // => AssertionError: null !== number 5 6try { 7 assert.number([111, 222], 'expect `val` to be {expected}') 8} catch (err) { 9 console.log(err.message) // => 'expect `val` to be number' 10 console.log(err.actual) // => array 11 console.log(err.expected) // => number 12 console.log(err.value) // => [111, 222] 13}
Check
value
is object, if not throws AssertionError.
Params
value
{any}: value to be checkedmessage
{String|Function}: error message; if function gets fn(actual, expected, value)
signaturereturns
{Undefined}: nothing is returned, throws if not okeyExample
1var assert = require('assert-kindof') 2assert.object({ aaa: 'bbb' }) // => not throws 3assert.object([1, 2, 3]) // => AssertionError: array !== object 4assert.object(null) // => AssertionError: null !== object 5 6try { 7 assert.object([111, 222], 'expect `val` to be {expected}') 8} catch (err) { 9 console.log(err.message) // => 'expect `val` to be object' 10 console.log(err.actual) // => array 11 console.log(err.expected) // => object 12 console.log(err.value) // => [111, 222] 13}
Check
value
is promise, if not throws AssertionError.
Params
value
{any}: value to be checkedmessage
{String|Function}: error message; if function gets fn(actual, expected, value)
signaturereturns
{Undefined}: nothing is returned, throws if not okeyExample
1var assert = require('assert-kindof')
2assert.promise(Promise.resolve(123)) // => not throws
3assert.promise(Promise.reject(new Error('foo'))) // => not throws
4
5assert.promise(new Map()) // => AssertionError: map !== promise
6assert.promise(123) // => AssertionError: number !== promise
7
8try {
9 assert.promise({ a: 1 }, 'expect `val` to be {expected}')
10} catch (err) {
11 console.log(err.message) // => 'expect `val` to be promise'
12 console.log(err.actual) // => object
13 console.log(err.expected) // => promise
14 console.log(err.value) // => { a: 1 }
15}
Check
value
is regexp, if not throws AssertionError.
Params
value
{any}: value to be checkedmessage
{String|Function}: error message; if function gets fn(actual, expected, value)
signaturereturns
{Undefined}: nothing is returned, throws if not okeyExample
1var assert = require('assert-kindof') 2assert.regexp(/foo ba?r abz/i) // => not throws 3assert.regexp(new RegExp('aa bb')) // => not throws 4 5assert.regexp(new Map()) // => AssertionError: map !== regexp 6assert.regexp(123) // => AssertionError: number !== regexp 7 8try { 9 assert.regexp({ a: 1 }, 'expect `val` to be {expected}') 10} catch (err) { 11 console.log(err.message) // => 'expect `val` to be regexp' 12 console.log(err.actual) // => object 13 console.log(err.expected) // => regexp 14 console.log(err.value) // => { a: 1 } 15}
Check
value
is ES2015/ES6 Set, if not throws AssertionError.
Params
value
{any}: value to be checkedmessage
{String|Function}: error message; if function gets fn(actual, expected, value)
signaturereturns
{Undefined}: nothing is returned, throws if not okeyExample
1var assert = require('assert-kindof') 2assert.set(new Set()) // => not throws 3assert.set(new Map()) // => AssertionError: map !== set 4assert.set(123) // => AssertionError: number !== set 5 6try { 7 assert.set({ a: 1 }, 'expect `val` to be {expected}') 8} catch (err) { 9 console.log(err.message) // => 'expect `val` to be set' 10 console.log(err.actual) // => object 11 console.log(err.expected) // => set 12 console.log(err.value) // => { a: 1 } 13}
Check
value
is stream, if not throws AssertionError.
Params
value
{any}: value to be checkedmessage
{String|Function}: error message; if function gets fn(actual, expected, value)
signaturereturns
{Undefined}: nothing is returned, throws if not okeyExample
1var through2 = require('through2') 2assert.stream(through2()) // => not throws 3assert.stream(through2.obj()) // => not throws 4 5assert.stream(new Map()) // => AssertionError: map !== stream 6assert.stream(123) // => AssertionError: number !== stream 7 8try { 9 assert.stream({ a: 1 }, 'expect `val` to be {expected}') 10} catch (err) { 11 console.log(err.message) // => 'expect `val` to be stream' 12 console.log(err.actual) // => object 13 console.log(err.expected) // => stream 14 console.log(err.value) // => { a: 1 } 15}
Check
value
is string, if not throws AssertionError.
Params
value
{any}: value to be checkedmessage
{String|Function}: error message; if function gets fn(actual, expected, value)
signaturereturns
{Undefined}: nothing is returned, throws if not okeyExample
1var fn = function aa () { return 123 } 2assert.string('foo bar baz') // => not throws 3assert.string(fn.toString()) // => not throws 4assert.string(new String('abc')) // => not throws 5 6assert.string(new Map()) // => AssertionError: map !== string 7assert.string(123) // => AssertionError: number !== string 8 9try { 10 assert.string({ a: 1 }, 'expect `val` to be {expected}') 11} catch (err) { 12 console.log(err.message) // => 'expect `val` to be string' 13 console.log(err.actual) // => object 14 console.log(err.expected) // => string 15 console.log(err.value) // => { a: 1 } 16}
Check
value
is Symbol, if not throws AssertionError.
var assert = require('assert-kindof')*
Params
value
{any}: value to be checkedmessage
{String|Function}: error message; if function gets fn(actual, expected, value)
signaturereturns
{Undefined}: nothing is returned, throws if not okeyExample
1assert.symbol(Symbol()) // => not throws 2 3assert.symbol(new Map()) // => AssertionError: map !== symbol 4assert.symbol(123) // => AssertionError: number !== symbol 5 6try { 7 assert.symbol({ a: 1 }, 'expect `val` to be {expected}') 8} catch (err) { 9 console.log(err.message) // => 'expect `val` to be symbol' 10 console.log(err.actual) // => object 11 console.log(err.expected) // => symbol 12 console.log(err.value) // => { a: 1 } 13}
Check
value
is undefined, if not throws AssertionError.
Params
value
{any}: value to be checkedmessage
{String|Function}: error message; if function gets fn(actual, expected, value)
signaturereturns
{Undefined}: nothing is returned, throws if not okeyExample
1var assert = require('assert-kindof') 2assert.undefined() // => not throws 3assert.undefined(undefined) // => not throws 4 5assert.undefined(new Map()) // => AssertionError: map !== undefined 6assert.undefined(123) // => AssertionError: number !== undefined 7 8try { 9 assert.undefined({ a: 1 }, 'expect `val` to be {expected}') 10} catch (err) { 11 console.log(err.message) // => 'expect `val` to be undefined' 12 console.log(err.actual) // => object 13 console.log(err.expected) // => undefined 14 console.log(err.value) // => { a: 1 } 15}
Check
value
is ES2015/ES6 WeakMap, if not throws AssertionError.
Params
value
{any}: value to be checkedmessage
{String|Function}: error message; if function gets fn(actual, expected, value)
signaturereturns
{Undefined}: nothing is returned, throws if not okeyExample
1var assert = require('assert-kindof') 2assert.weakmap(new WeakMap()) // => not throws 3 4assert.weakmap(new WeakSet()) // => AssertionError: weakset !== weakmap 5assert.weakmap(new Map()) // => AssertionError: map !== weakmap 6assert.weakmap(123) // => AssertionError: number !== weakmap 7 8try { 9 assert.weakmap({ a: 1 }, 'expect `val` to be {expected}') 10} catch (err) { 11 console.log(err.message) // => 'expect `val` to be weakmap' 12 console.log(err.actual) // => object 13 console.log(err.expected) // => weakmap 14 console.log(err.value) // => { a: 1 } 15}
Check
value
is ES2015/ES6 WeakSet, if not throws AssertionError.
Params
value
{any}: value to be checkedmessage
{String|Function}: error message; if function gets fn(actual, expected, value)
signaturereturns
{Undefined}: nothing is returned, throws if not okeyExample
1var assert = require('assert-kindof') 2assert.weakmap(new WeakSet()) // => not throws 3 4assert.weakset(new WeakMap()) // => AssertionError: weakmap !== weakset 5assert.weakset(new Map()) // => AssertionError: map !== weakset 6assert.weakset(123) // => AssertionError: number !== weakset 7 8try { 9 assert.weakset({ a: 1 }, 'expect `val` to be {expected}') 10} catch (err) { 11 console.log(err.message) // => 'expect `val` to be weakset' 12 console.log(err.actual) // => object 13 console.log(err.expected) // => weakset 14 console.log(err.value) // => { a: 1 } 15}
testit
framework, is-kindof
and assert
. | homepagePull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Please read the contributing guidelines for advice on opening issues, pull requests, and coding standards.
If you need some help and can spent some cash, feel free to contact me at CodeMentor.io too.
In short: If you want to contribute to that project, please follow these things
npm run commit
to commit changes instead of git commit
, because it is interactive and user-friendly. It uses commitizen behind the scenes, which follows Conventional Changelog idealogy.npm run release
, which is standard-version and follows Conventional Changelog idealogy.Thanks a lot! :)
Documentation and that readme is generated using verb-generate-readme, which is a verb generator, so you need to install both of them and then run verb
command like that
$ npm install verbose/verb#dev verb-generate-readme --global && verb
Please don't edit the README directly. Any changes to the readme must be made in .verb.md.
Clone repository and run the following in that cloned directory
$ npm install && npm test
Charlike Mike Reagent
Copyright © 2015, 2017, Charlike Mike Reagent. Released under the MIT License.
This file was generated by verb-generate-readme, v0.4.3, on March 10, 2017.
Project scaffolded using charlike cli.
No vulnerabilities found.
Reason
no vulnerabilities detected
Reason
no dangerous workflow patterns detected
Reason
tokens are read-only in GitHub workflows
Reason
all dependencies are pinned
Details
Reason
license file detected
Details
Reason
no binaries found in the repo
Reason
security policy file detected
Details
Reason
GitHub code reviews found for 2 commits out of the last 30 -- score normalized to 0
Details
Reason
0 commit(s) out of 30 and 0 issue activity out of 8 found in the last 90 days -- score normalized to 0
Reason
no badge detected
Reason
branch protection not enabled on development/release branches
Details
Reason
no update tool detected
Details
Reason
project is not fuzzed
Score
Last Scanned on 2022-08-15
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More