UNPKG

prray

Version:

'Promisified' Array, comes with async method supports(such as mapAsync). And it is compatible with normal array.

31 lines (23 loc) 641 B
import test from 'ava' import { prray } from '../src/prray' import { toPrrayPromise } from './test-utils' const arr = ['a', 'b', 'c', 'd'] test('prray shift', async t => { const p = prray(arr) t.is(p.shift(), 'a') t.is(p.shift(), 'b') t.is(p.shift(), 'c') t.is(p.shift(), 'd') t.is(p.shift(), undefined) t.deepEqual(p, prray([])) }) test('prraypromise shift', async t => { const prr = prray(arr) const pp = toPrrayPromise(prr) t.is(await pp.shift(), 'a') t.is(await pp.shift(), 'b') t.is(await pp.shift(), 'c') t.is(await pp.shift(), 'd') t.is(await pp.shift(), undefined) t.deepEqual(prr, prray([])) })