@rimbu/stream
Advanced tools
Comparing version 0.8.2 to 0.9.0
@@ -373,5 +373,7 @@ "use strict"; | ||
AsyncEmptyStream.prototype.join = function (_a) { | ||
var _b = _a === void 0 ? {} : _a, _c = _b.start, start = _c === void 0 ? '' : _c, _d = _b.end, end = _d === void 0 ? '' : _d; | ||
var _b = _a === void 0 ? {} : _a, _c = _b.start, start = _c === void 0 ? '' : _c, _d = _b.end, end = _d === void 0 ? '' : _d, _e = _b.ifEmpty, ifEmpty = _e === void 0 ? undefined : _e; | ||
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () { | ||
return (0, tslib_1.__generator)(this, function (_e) { | ||
return (0, tslib_1.__generator)(this, function (_f) { | ||
if (undefined !== ifEmpty) | ||
return [2 /*return*/, ifEmpty]; | ||
return [2 /*return*/, start.concat(end)]; | ||
@@ -378,0 +380,0 @@ }); |
@@ -135,3 +135,5 @@ "use strict"; | ||
EmptyStream.prototype.join = function (_a) { | ||
var _b = _a === void 0 ? {} : _a, _c = _b.start, start = _c === void 0 ? '' : _c, _d = _b.end, end = _d === void 0 ? '' : _d; | ||
var _b = _a === void 0 ? {} : _a, _c = _b.start, start = _c === void 0 ? '' : _c, _d = _b.end, end = _d === void 0 ? '' : _d, _e = _b.ifEmpty, ifEmpty = _e === void 0 ? undefined : _e; | ||
if (undefined !== ifEmpty) | ||
return ifEmpty; | ||
return start.concat(end); | ||
@@ -138,0 +140,0 @@ }; |
@@ -333,8 +333,11 @@ "use strict"; | ||
StreamBase.prototype.join = function (_a) { | ||
var _b = _a === void 0 ? {} : _a, _c = _b.sep, sep = _c === void 0 ? '' : _c, _d = _b.start, start = _d === void 0 ? '' : _d, _e = _b.end, end = _e === void 0 ? '' : _e, _f = _b.valueToString, valueToString = _f === void 0 ? String : _f; | ||
var _b = _a === void 0 ? {} : _a, _c = _b.sep, sep = _c === void 0 ? '' : _c, _d = _b.start, start = _d === void 0 ? '' : _d, _e = _b.end, end = _e === void 0 ? '' : _e, _f = _b.valueToString, valueToString = _f === void 0 ? String : _f, _g = _b.ifEmpty, ifEmpty = _g === void 0 ? undefined : _g; | ||
var done = Symbol('Done'); | ||
var iterator = this[Symbol.iterator](); | ||
var value = iterator.fastNext(done); | ||
if (done === value) | ||
if (done === value) { | ||
if (undefined !== ifEmpty) | ||
return ifEmpty; | ||
return start.concat(end); | ||
} | ||
var result = start.concat(valueToString(value)); | ||
@@ -341,0 +344,0 @@ while (done !== (value = iterator.fastNext(done))) { |
@@ -426,3 +426,3 @@ import { __awaiter } from "tslib"; | ||
} | ||
join({ sep = '', start = '', end = '', valueToString = String, } = {}) { | ||
join({ sep = '', start = '', end = '', valueToString = String, ifEmpty = undefined, } = {}) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -433,4 +433,7 @@ const done = Symbol('Done'); | ||
try { | ||
if (done === value) | ||
if (done === value) { | ||
if (undefined !== ifEmpty) | ||
return ifEmpty; | ||
return start.concat(end); | ||
} | ||
let result = start.concat(valueToString(value)); | ||
@@ -437,0 +440,0 @@ while (done !== (value = yield iterator.fastNext(done))) { |
@@ -294,4 +294,6 @@ import { __awaiter } from "tslib"; | ||
} | ||
join({ start = '', end = '' } = {}) { | ||
join({ start = '', end = '', ifEmpty = undefined, } = {}) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (undefined !== ifEmpty) | ||
return ifEmpty; | ||
return start.concat(end); | ||
@@ -298,0 +300,0 @@ }); |
@@ -122,3 +122,5 @@ import { RimbuError, Token } from '@rimbu/base'; | ||
} | ||
join({ start = '', end = '' } = {}) { | ||
join({ start = '', end = '', ifEmpty = undefined } = {}) { | ||
if (undefined !== ifEmpty) | ||
return ifEmpty; | ||
return start.concat(end); | ||
@@ -125,0 +127,0 @@ } |
@@ -290,8 +290,11 @@ import { CollectFun, Comp, Eq, OptLazy, Reducer, TraverseState, } from '@rimbu/common'; | ||
} | ||
join({ sep = '', start = '', end = '', valueToString = String, } = {}) { | ||
join({ sep = '', start = '', end = '', valueToString = String, ifEmpty = undefined, } = {}) { | ||
const done = Symbol('Done'); | ||
const iterator = this[Symbol.iterator](); | ||
let value = iterator.fastNext(done); | ||
if (done === value) | ||
if (done === value) { | ||
if (undefined !== ifEmpty) | ||
return ifEmpty; | ||
return start.concat(end); | ||
} | ||
let result = start.concat(valueToString(value)); | ||
@@ -298,0 +301,0 @@ while (done !== (value = iterator.fastNext(done))) { |
@@ -52,3 +52,3 @@ import { ArrayNonEmpty, AsyncCollectFun, AsyncOptLazy, AsyncReducer, Eq, MaybePromise, ToJSON, TraverseState } from '@rimbu/common'; | ||
intersperse(sep: AsyncStreamSource<T>): AsyncStream<T>; | ||
join({ sep, start, end, valueToString, }?: { | ||
join({ sep, start, end, valueToString, ifEmpty, }?: { | ||
sep?: string | undefined; | ||
@@ -58,2 +58,3 @@ start?: string | undefined; | ||
valueToString?: StringConstructor | undefined; | ||
ifEmpty?: undefined; | ||
}): Promise<string>; | ||
@@ -60,0 +61,0 @@ mkGroup({ sep, start, end, }?: { |
@@ -478,2 +478,3 @@ import type { ArrayNonEmpty, AsyncCollectFun, AsyncOptLazy, AsyncReducer, Eq, MaybePromise, ToJSON, TraverseState } from '@rimbu/common'; | ||
* * valueToString: (default: String) a potentially asynchronous function converting a Stream element to a string | ||
* * ifEmpty: (optional) a string to return instead of the start and end tag if the stream is empty | ||
* @example | ||
@@ -489,2 +490,3 @@ * await AsyncStream.of(1, 2, 3).join({ start: '<', sep: ', ', end: '>' }) | ||
valueToString?: (value: T) => MaybePromise<string>; | ||
ifEmpty?: string; | ||
}): Promise<string>; | ||
@@ -491,0 +493,0 @@ /** |
@@ -470,2 +470,3 @@ import type { ArrayNonEmpty, CollectFun, Eq, OptLazy, Reducer, ToJSON, TraverseState } from '@rimbu/common'; | ||
* * valueToString: (default: String) a function converting a Stream element to a string | ||
* * ifEmpty: (optional) a string to return instead of the start and end tag if the stream is empty | ||
* @example | ||
@@ -481,2 +482,3 @@ * Stream.of(1, 2, 3).join({ start: '<', sep: ', ', end: '>' }) | ||
valueToString?: (value: T) => string; | ||
ifEmpty?: string; | ||
}): string; | ||
@@ -483,0 +485,0 @@ /** |
@@ -55,3 +55,3 @@ import { ArrayNonEmpty, CollectFun, Eq, OptLazy, Reducer, ToJSON, TraverseState } from '@rimbu/common'; | ||
intersperse(sep: StreamSource<T>): Stream<T>; | ||
join({ sep, start, end, valueToString, }?: { | ||
join({ sep, start, end, valueToString, ifEmpty, }?: { | ||
sep?: string | undefined; | ||
@@ -61,2 +61,3 @@ start?: string | undefined; | ||
valueToString?: StringConstructor | undefined; | ||
ifEmpty?: undefined; | ||
}): string; | ||
@@ -63,0 +64,0 @@ mkGroup({ sep, start, end, }?: { |
{ | ||
"name": "@rimbu/stream", | ||
"version": "0.8.2", | ||
"version": "0.9.0", | ||
"description": "Efficient structure representing a sequence of elements, with powerful operations for TypeScript", | ||
@@ -71,3 +71,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "1594b907f4dbbd994a52f0e2e94ffd9217420ff5" | ||
"gitHead": "eb052e1db5f0f610f2e0a78cb283a278c868f7ec" | ||
} |
@@ -530,2 +530,3 @@ import { | ||
valueToString = String, | ||
ifEmpty = undefined, | ||
} = {}): Promise<string> { | ||
@@ -538,4 +539,8 @@ const done = Symbol('Done'); | ||
try { | ||
if (done === value) return start.concat(end); | ||
if (done === value) { | ||
if (undefined !== ifEmpty) return ifEmpty; | ||
return start.concat(end); | ||
} | ||
let result = start.concat(valueToString(value)); | ||
@@ -542,0 +547,0 @@ |
@@ -405,3 +405,9 @@ import { RimbuError, Token } from '@rimbu/base'; | ||
} | ||
async join({ start = '', end = '' } = {}): Promise<string> { | ||
async join({ | ||
start = '', | ||
end = '', | ||
ifEmpty = undefined, | ||
} = {}): Promise<string> { | ||
if (undefined !== ifEmpty) return ifEmpty; | ||
return start.concat(end); | ||
@@ -408,0 +414,0 @@ } |
@@ -553,2 +553,3 @@ import type { | ||
* * valueToString: (default: String) a potentially asynchronous function converting a Stream element to a string | ||
* * ifEmpty: (optional) a string to return instead of the start and end tag if the stream is empty | ||
* @example | ||
@@ -564,2 +565,3 @@ * await AsyncStream.of(1, 2, 3).join({ start: '<', sep: ', ', end: '>' }) | ||
valueToString?: (value: T) => MaybePromise<string>; | ||
ifEmpty?: string; | ||
}): Promise<string>; | ||
@@ -566,0 +568,0 @@ /** |
@@ -145,3 +145,4 @@ import { RimbuError, Token } from '@rimbu/base'; | ||
} | ||
join({ start = '', end = '' } = {}): string { | ||
join({ start = '', end = '', ifEmpty = undefined } = {}): string { | ||
if (undefined !== ifEmpty) return ifEmpty; | ||
return start.concat(end); | ||
@@ -148,0 +149,0 @@ } |
@@ -512,2 +512,3 @@ import type { | ||
* * valueToString: (default: String) a function converting a Stream element to a string | ||
* * ifEmpty: (optional) a string to return instead of the start and end tag if the stream is empty | ||
* @example | ||
@@ -523,2 +524,3 @@ * Stream.of(1, 2, 3).join({ start: '<', sep: ', ', end: '>' }) | ||
valueToString?: (value: T) => string; | ||
ifEmpty?: string; | ||
}): string; | ||
@@ -525,0 +527,0 @@ /** |
@@ -403,2 +403,3 @@ import { | ||
valueToString = String, | ||
ifEmpty = undefined, | ||
} = {}): string { | ||
@@ -409,3 +410,6 @@ const done = Symbol('Done'); | ||
if (done === value) return start.concat(end); | ||
if (done === value) { | ||
if (undefined !== ifEmpty) return ifEmpty; | ||
return start.concat(end); | ||
} | ||
@@ -412,0 +416,0 @@ let result = start.concat(valueToString(value)); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1054734
20267