Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('Iterable#from from generator', () => {
const xs = getData();
const res = from(xs);
const it = res[Symbol.iterator]();
hasNext(it, 1);
hasNext(it, 2);
hasNext(it, 3);
noNext(it);
});
test(`yields Objects`, async () => {
const expected = from(expectedObjects);
const actual = objectsItr().pipe(toDOMStream());
await expect(actual).toEqualStream(expected, compare);
});
});
test('Iterable#from from iterator', () => {
const xs = getData();
const res = from({ next: () => xs.next() });
const it = res[Symbol.iterator]();
hasNext(it, 1);
hasNext(it, 2);
hasNext(it, 3);
noNext(it);
});
test(`yields Buffers`, async () => {
const expected = from(expectedBuffers);
const actual = buffersItr().pipe(toDOMStream());
await expect(actual).toEqualStream(expected, compare);
});
test(`yields Objects`, async () => {
test(`yields Strings`, async () => {
const expected = from(expectedStrings);
const actual = stringsItr().pipe(toDOMStream());
await expect(actual).toEqualStream(expected, compare);
});
test(`yields Buffers`, async () => {
test('Iterable#from from empty array/iterable', () => {
const xs: number[] = [];
const res = from(xs);
const it = res[Symbol.iterator]();
noNext(it);
});
test('Iterable#from from array-like', () => {
const xs = { length: 3 };
const res = from(xs);
const it = res[Symbol.iterator]();
hasNext(it, undefined);
hasNext(it, undefined);
hasNext(it, undefined);
noNext(it);
});
const stringsItr = () => from([1, 2, 3]).pipe(map(i => `${i}`));
const buffersItr = () => stringsItr().pipe(map(val => Buffer.from(val)));