@ts-common/iterator
Advanced tools
Comparing version 0.1.5 to 0.2.0
@@ -46,3 +46,3 @@ import { Tuple2 } from "@ts-common/tuple"; | ||
export declare const drop: <T>(input: Iterable<T> | undefined, n?: number) => IterableEx<T>; | ||
export declare const flatten: <T>(input: Iterable<Iterable<T> | undefined> | undefined) => IterableEx<T>; | ||
export declare const flat: <T>(input: Iterable<Iterable<T> | undefined> | undefined) => IterableEx<T>; | ||
export declare const concat: <T>(...input: (Iterable<T> | undefined)[]) => IterableEx<T>; | ||
@@ -49,0 +49,0 @@ export declare const takeWhile: <T>(input: Iterable<T> | undefined, func: (v: T, i: number) => boolean) => IterableEx<T>; |
@@ -61,3 +61,3 @@ "use strict"; | ||
exports.drop = (input, n = 1) => exports.filter(input, (_, i) => n <= i); | ||
exports.flatten = (input) => exports.iterable(function* () { | ||
exports.flat = (input) => exports.iterable(function* () { | ||
// tslint:disable-next-line:no-if-statement | ||
@@ -76,3 +76,3 @@ if (input === undefined) { | ||
// tslint:disable-next-line:readonly-array | ||
exports.concat = (...input) => exports.flatten(input); | ||
exports.concat = (...input) => exports.flat(input); | ||
exports.takeWhile = (input, func) => exports.iterable(function* () { | ||
@@ -103,3 +103,3 @@ /* tslint:disable-next-line:no-loop-statement */ | ||
}; | ||
exports.flatMap = (input, func) => exports.flatten(exports.map(input, func)); | ||
exports.flatMap = (input, func) => exports.flat(exports.map(input, func)); | ||
exports.optionalToArray = (v) => v === undefined ? [] : [v]; | ||
@@ -106,0 +106,0 @@ exports.filterMap = (input, func) => exports.flatMap(input, (v, i) => exports.optionalToArray(func(v, i))); |
{ | ||
"name": "@ts-common/iterator", | ||
"version": "0.1.5", | ||
"version": "0.2.0", | ||
"description": "Iterator library for JavaScript and TypeScript", | ||
@@ -56,4 +56,4 @@ "main": "dist/index.js", | ||
"tslint": "^5.14.0", | ||
"tslint-immutable": "^5.4.0", | ||
"typescript": "^3.3.3333" | ||
"tslint-immutable": "^5.5.1", | ||
"typescript": "^3.3.4000" | ||
}, | ||
@@ -60,0 +60,0 @@ "dependencies": { |
@@ -119,3 +119,3 @@ import { Tuple2, tuple2 } from "@ts-common/tuple" | ||
export const flatten = <T>(input: Iterable<Iterable<T>|undefined>|undefined): IterableEx<T> => | ||
export const flat = <T>(input: Iterable<Iterable<T>|undefined>|undefined): IterableEx<T> => | ||
iterable(function *(): Iterator<T> { | ||
@@ -137,3 +137,3 @@ // tslint:disable-next-line:no-if-statement | ||
export const concat = <T>(...input: Array<Iterable<T>|undefined>): IterableEx<T> => | ||
flatten(input) | ||
flat(input) | ||
@@ -184,3 +184,3 @@ export const takeWhile = <T>( | ||
): IterableEx<T> => | ||
flatten(map(input, func)) | ||
flat(map(input, func)) | ||
@@ -187,0 +187,0 @@ export const optionalToArray = <T>(v: T|undefined): ReadonlyArray<T> => |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
54941