Dorian 0d073fa89e Add comprehensive installation and setup documentation
- 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
2026-01-27 17:18:21 +00:00

71 lines
1.2 KiB
JavaScript

'use strict'
const test = require('tape')
const SparseArray = require('../')
const max = 100
let arr
test('allows creation', (t) => {
arr = new SparseArray()
t.end()
})
test('allows pushing', (t) => {
for(let i = 0; i < max; i++) {
const pos = arr.push(i.toString())
t.equal(pos, i + 1)
}
t.end()
})
test('has length', (t) => {
t.equal(arr.length, 100)
t.end()
})
test('can iterate', (t) => {
let next = 0
arr.forEach((elem, index, arr) => {
t.equal(elem, next.toString())
t.equal(index, next)
t.equal(arr, arr)
next ++
})
t.equal(next, max)
t.end()
})
test('can map', (t) => {
let next = 0
const result = arr.map((elem, index, arr) => {
t.equal(elem, next.toString())
t.equal(index, next)
t.equal(arr, arr)
next ++
return Number(elem) + 1
})
t.equal(next, max)
t.equal(result.length, arr.length)
next = 0
result.forEach((elem) => {
t.equal(elem, next + 1)
next ++
})
t.equal(next, max)
t.end()
})
test('can reduce', (t) => {
let next = 0
arr.reduce((acc, elem, index) => {
t.equal(elem, next.toString())
t.equal(index, next)
next ++
return acc + Number(elem)
}, 0)
t.equal(next, max)
t.end()
})