a library of deep data type test
$ npm install assert-easy --save
var assert = require('assert-easy')
assert.type({})
// 'Object'
assert.is([], 'Array')
// true
assert.meaningless(null)
// true
assert.meaningless(undefined)
// true
var data = []
assert.some(data, ['Array', 'Number', 'String'])
// true
assert.some(data, ['Number', 'String'])
// false
var data = {
a: {
b: {
c: 'hello'
}
}
}
assert.expect(data, 'a.b.c')
// true
assert.expect(data, 'a.b.c.d')
// false
assert.expect(data, 'a.b.c', 'String')
// true
assert.expect(data, 'a.b.c.d', 'String')
// false
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. |