@rimbu/stream
Advanced tools
Comparing version 0.12.3 to 0.12.4
@@ -5,2 +5,17 @@ var _a; | ||
import { RimbuError } from '@rimbu/base'; | ||
function* yieldObjKeys(obj) { | ||
for (const key in obj) { | ||
yield key; | ||
} | ||
} | ||
function* yieldObjValues(obj) { | ||
for (const key in obj) { | ||
yield obj[key]; | ||
} | ||
} | ||
function* yieldObjEntries(obj) { | ||
for (const key in obj) { | ||
yield [key, obj[key]]; | ||
} | ||
} | ||
export class StreamBase { | ||
@@ -1386,9 +1401,9 @@ stream() { | ||
fromObjectKeys(obj) { | ||
return StreamConstructorsImpl.fromArray(Object.keys(obj)); | ||
return StreamConstructorsImpl.from(yieldObjKeys(obj)); | ||
}, | ||
fromObjectValues(obj) { | ||
return StreamConstructorsImpl.fromArray(Object.values(obj)); | ||
return StreamConstructorsImpl.from(yieldObjValues(obj)); | ||
}, | ||
fromObject(obj) { | ||
return StreamConstructorsImpl.fromArray(Object.entries(obj)); | ||
return StreamConstructorsImpl.from(yieldObjEntries(obj)); | ||
}, | ||
@@ -1395,0 +1410,0 @@ fromString(source, range, reversed = false) { |
@@ -9,3 +9,3 @@ import { Token } from '@rimbu/base'; | ||
abstract fastNext<O>(otherwise?: AsyncOptLazy<O>): MaybePromise<T | O>; | ||
return?: () => Promise<any>; | ||
return?: undefined | (() => Promise<any>); | ||
next(): Promise<IteratorResult<T>>; | ||
@@ -74,3 +74,3 @@ } | ||
constructor(iterator: Iterator<T>, close?: () => MaybePromise<void>); | ||
return?: () => MaybePromise<any>; | ||
return: undefined | (() => MaybePromise<any>); | ||
fastNext<O>(otherwise?: AsyncOptLazy<O>): Promise<T | O>; | ||
@@ -222,3 +222,3 @@ } | ||
iterator: AsyncFastIterator<T>; | ||
remain?: number; | ||
remain: number | undefined; | ||
constructor(source: AsyncStream<T>, amount?: number | undefined); | ||
@@ -225,0 +225,0 @@ isEmpty: boolean; |
@@ -647,7 +647,7 @@ import type { ArrayNonEmpty, AsyncCollectFun, AsyncOptLazy, AsyncReducer, Eq, MaybePromise, ToJSON, TraverseState } from '@rimbu/common'; | ||
join(options?: { | ||
sep?: string; | ||
start?: string; | ||
end?: string; | ||
valueToString?: (value: T) => MaybePromise<string>; | ||
ifEmpty?: string; | ||
sep?: string | undefined; | ||
start?: string | undefined; | ||
end?: string | undefined; | ||
valueToString?: ((value: T) => MaybePromise<string>) | undefined; | ||
ifEmpty?: string | undefined; | ||
}): Promise<string>; | ||
@@ -654,0 +654,0 @@ /** |
@@ -105,3 +105,3 @@ import { Token } from '@rimbu/base'; | ||
iterator: FastIterator<T>; | ||
remain?: number; | ||
remain: number | undefined; | ||
constructor(source: Stream<T>, amount?: number | undefined); | ||
@@ -108,0 +108,0 @@ isEmpty: boolean; |
@@ -647,7 +647,7 @@ import type { ArrayNonEmpty, CollectFun, Eq, OptLazy, Reducer, ToJSON, TraverseState } from '@rimbu/common'; | ||
join(options?: { | ||
sep?: string; | ||
start?: string; | ||
end?: string; | ||
valueToString?: (value: T) => string; | ||
ifEmpty?: string; | ||
sep?: string | undefined; | ||
start?: string | undefined; | ||
end?: string | undefined; | ||
valueToString?: ((value: T) => string) | undefined; | ||
ifEmpty?: string | undefined; | ||
}): string; | ||
@@ -654,0 +654,0 @@ /** |
{ | ||
"name": "@rimbu/stream", | ||
"version": "0.12.3", | ||
"version": "0.12.4", | ||
"description": "Efficient structure representing a sequence of elements, with powerful operations for TypeScript", | ||
@@ -70,4 +70,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@rimbu/base": "^0.9.4", | ||
"@rimbu/common": "^0.10.2", | ||
"@rimbu/base": "^0.9.5", | ||
"@rimbu/common": "^0.10.3", | ||
"tslib": "^2.4.0" | ||
@@ -89,3 +89,3 @@ }, | ||
}, | ||
"gitHead": "0d1677b4df9c1b0f1dc337eb38eea7a99ea7fc43" | ||
"gitHead": "c4009664c4e15f367e963d198cacd7c5fc182a4d" | ||
} |
@@ -50,3 +50,3 @@ import { Token } from '@rimbu/base'; | ||
abstract fastNext<O>(otherwise?: AsyncOptLazy<O>): MaybePromise<T | O>; | ||
return?: () => Promise<any>; | ||
return?: undefined | (() => Promise<any>); | ||
@@ -290,3 +290,3 @@ async next(): Promise<IteratorResult<T>> { | ||
return?: () => MaybePromise<any>; | ||
return: undefined | (() => MaybePromise<any>); | ||
@@ -912,3 +912,3 @@ async fastNext<O>(otherwise?: AsyncOptLazy<O>): Promise<T | O> { | ||
iterator: AsyncFastIterator<T>; | ||
remain?: number; | ||
remain: number | undefined; | ||
@@ -915,0 +915,0 @@ constructor(readonly source: AsyncStream<T>, readonly amount?: number) { |
@@ -733,7 +733,7 @@ import type { | ||
join(options?: { | ||
sep?: string; | ||
start?: string; | ||
end?: string; | ||
valueToString?: (value: T) => MaybePromise<string>; | ||
ifEmpty?: string; | ||
sep?: string | undefined; | ||
start?: string | undefined; | ||
end?: string | undefined; | ||
valueToString?: ((value: T) => MaybePromise<string>) | undefined; | ||
ifEmpty?: string | undefined; | ||
}): Promise<string>; | ||
@@ -740,0 +740,0 @@ /** |
@@ -387,3 +387,3 @@ import { Token } from '@rimbu/base'; | ||
iterator: FastIterator<T>; | ||
remain?: number; | ||
remain: number | undefined; | ||
@@ -390,0 +390,0 @@ constructor(readonly source: Stream<T>, readonly amount?: number) { |
@@ -63,2 +63,24 @@ import { | ||
function* yieldObjKeys<K extends string | number | symbol>( | ||
obj: Record<K, any> | ||
): Generator<K> { | ||
for (const key in obj) { | ||
yield key; | ||
} | ||
} | ||
function* yieldObjValues<V>(obj: Record<any, V>): Generator<V> { | ||
for (const key in obj) { | ||
yield (obj as any)[key]; | ||
} | ||
} | ||
function* yieldObjEntries<K extends string | number | symbol, V>( | ||
obj: Record<K, V> | ||
): Generator<[K, V]> { | ||
for (const key in obj) { | ||
yield [key, obj[key]]; | ||
} | ||
} | ||
export abstract class StreamBase<T> implements Stream<T> { | ||
@@ -1872,6 +1894,6 @@ abstract [Symbol.iterator](): FastIterator<T>; | ||
): Stream<K> { | ||
return StreamConstructorsImpl.fromArray(Object.keys(obj) as K[]); | ||
return StreamConstructorsImpl.from(yieldObjKeys(obj)); | ||
}, | ||
fromObjectValues<V>(obj: Record<any, V> | readonly V[]): Stream<V> { | ||
return StreamConstructorsImpl.fromArray(Object.values(obj)); | ||
fromObjectValues<V>(obj: Record<any, V>): Stream<V> { | ||
return StreamConstructorsImpl.from(yieldObjValues(obj)); | ||
}, | ||
@@ -1881,3 +1903,3 @@ fromObject<K extends string | number | symbol, V>( | ||
): Stream<[K, V]> { | ||
return StreamConstructorsImpl.fromArray(Object.entries(obj) as [K, V][]); | ||
return StreamConstructorsImpl.from(yieldObjEntries(obj)); | ||
}, | ||
@@ -1884,0 +1906,0 @@ fromString(source: string, range?: IndexRange, reversed = false) { |
@@ -697,7 +697,7 @@ import type { | ||
join(options?: { | ||
sep?: string; | ||
start?: string; | ||
end?: string; | ||
valueToString?: (value: T) => string; | ||
ifEmpty?: string; | ||
sep?: string | undefined; | ||
start?: string | undefined; | ||
end?: string | undefined; | ||
valueToString?: ((value: T) => string) | undefined; | ||
ifEmpty?: string | undefined; | ||
}): string; | ||
@@ -704,0 +704,0 @@ /** |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1243619
24471
Updated@rimbu/base@^0.9.5
Updated@rimbu/common@^0.10.3