assert-easy
v1.1.0
Published
Deep data type test
Downloads
4
Readme
assert-easy
a library of deep data type test
Installing
$ npm install assert-easy --save
Usage
var assert = require('assert-easy')
type test
assert.type({})
// 'Object'
assert.is([], 'Array')
// true
bewteen Null and Undefined
assert.meaningless(null)
// true
assert.meaningless(undefined)
// true
As long as there is one in line with expectations.
var data = []
assert.some(data, ['Array', 'Number', 'String'])
// true
assert.some(data, ['Number', 'String'])
// false
Whether the chain of data exists.
var data = {
a: {
b: {
c: 'hello'
}
}
}
assert.expect(data, 'a.b.c')
// true
assert.expect(data, 'a.b.c.d')
// false
Expect the type of data chain.
assert.expect(data, 'a.b.c', 'String')
// true
assert.expect(data, 'a.b.c.d', 'String')
// false
Data chain information.
assert.chain(data, 'a.b.c')
/* {
breakPoint: undefined,
breakPointType: undefined,
breakPointValue: undefined,
done: true,
type: 'String',
value: 'hello'
} */
assert.chain(data, 'a.b.c.d')
/* {
breakPoint: 'c',
breakPointType: 'String',
breakPointValue: 'hello',
done: false,
type: undefined,
value: undefined
} */
| prop | type | detail | ---|---|--- | done | {boolean} | Whether the last attribute exists. | value| {any} | the last attribute value. | breakPoint | {string} | Interrupt the attribute name of the chain. | breakPointType | {string} | Interrupt the attribute type of the chain. | breakPointValue | {any} | Interrupt the attribute value of the chain.