1.1.0 • Published 8 years ago
assert-easy v1.1.0
assert-easy
a library of deep data type test
Installing
$ npm install assert-easy --saveUsage
var assert = require('assert-easy')type test
assert.type({})
// 'Object'
assert.is([], 'Array')
// truebewteen Null and Undefined
assert.meaningless(null)
// true
assert.meaningless(undefined)
// trueAs long as there is one in line with expectations.
var data = []
assert.some(data, ['Array', 'Number', 'String'])
// true
assert.some(data, ['Number', 'String'])
// falseWhether 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')
// falseExpect the type of data chain.
assert.expect(data, 'a.b.c', 'String')
// true
assert.expect(data, 'a.b.c.d', 'String')
// falseData 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. |