array-type
The array type. See the type-info for type info collections.
Usage
require('array-type')
var TypeInfo = require('abstract-type')
var ArrayType = TypeInfo('array')
var LimitedArrayType = TypeInfo('array', min:1, max:3)
var arr = ArrayType.create([1,2,3])
console.log(arr)
console.log(arr.isValid())
console.log(arr.toJson()))
console.log(arr.toJson({withType:true})))
console.log(LimitedArrayType.isValid([]))
console.log(LimitedArrayType.isValid([1]))
var n = arr.clone();
n.assign('aaa')
API
- The ArrayType Class
- options:
- min: the minimum length of the array. null or undefined means unlimited.
- max: the maximum length of the array.
See abstract-type
TODO
of
option to limit the element's type.
- eg,
ArrayType of: 'String'
License
MIT