- Add GETTING_STARTED.md with quick start guide and development modes - Add INSTALL.sh automated installation script - Add INSTALLATION_CHECKLIST.md, INSTALLATION_SUCCESS.md, and INSTALLATION_SUMMARY.md - Add QUICK_REFERENCE.md for common commands - Add SETUP_GUIDE.md with detailed setup instructions - Update README.md with improved project overview - Add did-wallet app dependencies and node_modules
1016 B
1016 B
sparse-array
Sparse array implementation in JS with no dependencies
Install
$ npm install sparse-array --save
Use
Create:
const SparseArray = require('sparse-array')
const arr = new SparseArray()
Set, get and unset:
const index = 0
arr.set(index, 'value')
arr.get(index) // 'value'
arr.unset(index)
arr.get(index) // undefined
Iterate:
arr.forEach((elem, index) => {
console.log('elem: %j at %d', elem, index)
})
const mapped = arr.map((elem, index) => {
return elem + 1
})
const result = arr.reduce((acc, elem, index) => {
return acc + Number(elem)
}, 0)
Find:
const firstEven = arr.find((elem) => (elem % 2) === 0)
Internal representation:
Bit field:
const bitField = arr.bitField()
Compact array:
const compacted = arr.compactArray()
License
ISC