This library includes generic layer for javascript collections. Currently supported generic types are depicted below:
ArrayT
- Generic version of Array type
npm install --save generic-collections-js
npm run test
const { ArrayT } = require('generic-collections-js')
// Primitive type example //
const numArray = new ArrayT('number')
numArray.push(2, 3)
try {
numArray.push('4')
} catch (err) {
console.log(err.toString()) // Error: ERR_INVALID_VALUE_TYPE
}
console.log(numArray.toArray()) // [ 2, 3 ]
- vigan-abd (vigan.abd@gmail.com)