How to use the iterall.isArrayLike function in iterall

To help you get started, we’ve selected a few iterall examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mobxjs / mobx / test / base / array.js View on Github external
test("array should support iterall / iterable ", () => {
    var a = observable([1, 2, 3])

    expect(iterall.isIterable(a)).toBe(true)
    expect(iterall.isArrayLike(a)).toBe(true)

    var values = []
    iterall.forEach(a, v => values.push(v))

    expect(values).toEqual([1, 2, 3])

    var iter = iterall.getIterator(a)
    expect(iter.next()).toEqual({ value: 1, done: false })
    expect(iter.next()).toEqual({ value: 2, done: false })
    expect(iter.next()).toEqual({ value: 3, done: false })
    expect(iter.next()).toEqual({ value: undefined, done: true })

    a.replace([])
    iter = iterall.getIterator(a)
    expect(iter.next()).toEqual({ value: undefined, done: true })
})