prray
Version:
'Promisified' Array, comes with async method supports(such as mapAsync). And it is compatible with normal array.
26 lines (20 loc) • 532 B
text/typescript
import test from 'ava'
import { prray } from '../src/prray'
import { toPrrayPromise } from './test-utils'
const arr = ['a', 'b', 'c', 'd']
test('prray pop', async t => {
const p = prray(arr)
t.is(p.pop(), 'd')
t.is(p.pop(), 'c')
t.is(p.pop(), 'b')
t.is(p.pop(), 'a')
t.is(p.pop(), undefined)
})
test('prraypromise pop', async t => {
const pp = toPrrayPromise(arr)
t.is(await pp.pop(), 'd')
t.is(await pp.pop(), 'c')
t.is(await pp.pop(), 'b')
t.is(await pp.pop(), 'a')
t.is(await pp.pop(), undefined)
})