Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@thi.ng/rstream

Package Overview
Dependencies
Maintainers
0
Versions
395
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/rstream - npm Package Compare versions

Comparing version 8.5.0 to 8.5.1

12

atom.d.ts

@@ -35,10 +35,12 @@ import type { Predicate2 } from "@thi.ng/api";

* @example
* ```ts
* ```ts tangle:../export/from-atom.ts
* import { defAtom, defCursor } from "@thi.ng/atom";
* import { fromCursor } from "@thi.ng/rstream";
* import { fromAtom, trace } from "@thi.ng/rstream";
*
* db = defAtom({ a: 23, b: 88 });
* cursor = defCursor(db, "a")
* type DB = { a: number; b?: number };
*
* rs.fromAtom(cursor).subscribe(rs.trace("cursor val:"))
* const db = defAtom<DB>({ a: 23, b: 88 });
* const cursor = defCursor(db, ["a"])
*
* fromAtom(cursor).subscribe(trace("cursor val:"))
* // cursor val: 23

@@ -45,0 +47,0 @@ *

@@ -15,3 +15,3 @@ import type { Predicate } from "@thi.ng/api";

* @example
* ```ts
* ```ts tangle:../export/bisect.ts
* import { bisect, fromIterable, trace } from "@thi.ng/rstream";

@@ -35,10 +35,10 @@ *

* @example
* ```ts
* import { bisect, subscription, trace } from "@thi.ng/rstream";
* ```ts tangle:../export/bisect-2.ts
* import { bisect, fromIterable, subscription, trace } from "@thi.ng/rstream";
* import { map } from "@thi.ng/transducers";
*
* const odd = subscription();
* const even = subscription();
* const odd = subscription<number, number>();
* const even = subscription<number, number>();
* odd.subscribe(trace("odd"));
* odd.subscribe(trace("odd x10"), { xform: map((x) => x * 10) });
* odd.subscribe(trace("odd x10"), { xform: map((x: number) => x * 10) });
* even.subscribe(trace("even"));

@@ -49,2 +49,11 @@ *

* );
* // odd x10 10
* // odd 1
* // even 2
* // odd x10 30
* // odd 3
* // even 4
* // odd x10 done
* // odd done
* // even done
* ```

@@ -51,0 +60,0 @@ *

# Change Log
- **Last updated**: 2024-05-08T18:24:31Z
- **Last updated**: 2024-06-21T19:34:38Z
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)

@@ -5,0 +5,0 @@

@@ -8,8 +8,9 @@ import { type MetaStreamOpts } from "./metastream.js";

* @example
* ```ts
* import { debounce, fromIterable } from "@thi.ng/rstream";
* ```ts tangle:../export/debounce.ts
* import { debounce, fromIterable, trace } from "@thi.ng/rstream";
*
* const src = fromIterable([1, 2, 3], { delay: 10 })
* src.subscribe(debounce(20)).subscribe({ next: console.log });
* src.subscribe(debounce(20)).subscribe(trace());
* // 3
* // done
* ```

@@ -16,0 +17,0 @@ *

@@ -35,4 +35,2 @@ import type { CommonOpts } from "./api.js";

*
* Also see: {@link fromEvent}
*
* @param src -

@@ -39,0 +37,0 @@ * @param name -

@@ -20,3 +20,3 @@ import { type ISubscribable, type ISubscription, type TransformableOpts } from "./api.js";

* @example
* ```ts
* ```ts tangle:../export/merge.ts
* import { fromIterable, merge, trace } from "@thi.ng/rstream";

@@ -41,2 +41,3 @@ *

* // 30
* // done
* ```

@@ -51,9 +52,10 @@ *

* @example
* ```ts
* import { fromIterable, merge } from "@thi.ng/rstream";
* ```ts tangle:../export/merge-2.ts
* import { fromIterable, merge, trace } from "@thi.ng/rstream";
* import { labeled } from "@thi.ng/transducers";
*
* merge({
* src: [
* fromIterable([1, 2, 3]).transform(tx.labeled("a")),
* fromIterable([10, 20, 30]).transform(tx.labeled("b")),
* fromIterable([1, 2, 3]).transform(labeled("a")),
* fromIterable([10, 20, 30]).transform(labeled("b")),
* ]

@@ -67,2 +69,3 @@ * }).subscribe(trace());

* // ["b", 30]
* // done
* ```

@@ -69,0 +72,0 @@ *

@@ -39,3 +39,3 @@ import type { Fn, Nullable } from "@thi.ng/api";

* @example
* ```ts
* ```ts tangle:../export/metastream.ts
* import { fromIterable, metaStream, trace } from "@thi.ng/rstream";

@@ -47,3 +47,3 @@ * import { repeat } from "@thi.ng/transducers";

* // even numbers are ignored
* a = metaStream(
* const a = metaStream<number, number>(
* (x) => (x & 1)

@@ -61,5 +61,5 @@ * ? fromIterable(repeat(x, 3), { delay: 100 })

*
* a.next(42) // ignored by factory fn
* setTimeout(() => a.next(42), 500); // value 42 ignored by metastream
*
* a.next(43)
* setTimeout(() => a.next(43), 1000);
* // 43

@@ -71,28 +71,38 @@ * // 43

* @example
* ```ts
* import { fromIterable, metaStream, trace, CloseMode } from "@thi.ng/rstream";
* import { repeat } from "@thi.ng/transducers";
* ```ts tangle:../export/metastream-2.ts
* import { CloseMode, fromIterable, metaStream, trace } from "@thi.ng/rstream";
* import { cycle, repeat } from "@thi.ng/transducers";
*
* // infinite inputs
* a = fromIterable(
* // infinite inputs (important: closeOut mode = never!)
* const a = fromIterable(
* repeat("a"),
* { delay: 1000, closeOut: CloseMode.NEVER }
* { delay: 100, closeOut: CloseMode.NEVER }
* );
* b = fromIterable(
* const b = fromIterable(
* repeat("b"),
* { delay: 1000, closeOut: CloseMode.NEVER }
* { delay: 100, closeOut: CloseMode.NEVER }
* );
*
* // stream selector / switch
* m = metaStream((x) => x ? a : b);
* const m = metaStream<boolean, string>((x) => (x ? a : b));
* m.subscribe(trace("meta from: "));
*
* m.next(true);
* // meta from: a
* // create infinite stream of true/false and pipe into
* // the metastream and switch which source to use
* fromIterable(cycle([true, false]), { delay: 500 })
* .subscribe({ next(x) { m.next(x); } });
*
* m.next(false);
* // meta from: b
*
* m.next(true);
* // meta from: a
* // a
* // a
* // a
* // a
* // a
* // b
* // b
* // b
* // b
* // b
* // a
* // a
* // ...
* ```

@@ -99,0 +109,0 @@ *

@@ -1,2 +0,1 @@

/// <reference types="node" />
import type { Readable } from "node:stream";

@@ -26,5 +25,5 @@ import { type Stream } from "./stream.js";

* @example
* ```ts
* ```ts tangle:../export/lines-from-nodejs.ts
* import { linesFromNodeJS, trace } from "@thi.ng/rstream";
* import { spawn } from "node:child_process"
* import { linesFromNodeJS, trace } from "@thi.ng/rstream";
*

@@ -31,0 +30,0 @@ * const cmd = spawn("ls", ["-la"]);

@@ -93,15 +93,16 @@ import type { Keys, Predicate2 } from "@thi.ng/api";

* @example
* ```ts
* import { fromObject } from "@thi.ng/rstream";
* ```ts tangle:../export/from-object.ts
* import { fromObject, trace } from "@thi.ng/rstream";
*
* type Foo = { a?: number; b: string; };
*
* const obj = fromObject(<Foo>{ a: 1, b: "foo" })
* const obj = fromObject(<Foo>{ a: 1, b: "foo" });
*
* obj.streams.a.subscribe(trace("a"))
* obj.streams.a.subscribe(trace("a"));
* // a 1
* obj.streams.b.subscribe(trace("b"))
*
* obj.streams.b.subscribe(trace("b"));
* // b foo
*
* obj.next({ b: "bar" })
* obj.next({ b: "bar" });
* // a undefined

@@ -112,6 +113,8 @@ * // b bar

* @example
* ```ts
* import { fromObject, trace } from "@thi.ng/rstream";
* ```ts tangle:../export/from-object-2.ts
* import { fromObject, subscription, trace } from "@thi.ng/rstream";
*
* const obj = fromObject(<Foo>{}, ["a", "b"], { initial: false });
* type Foo = { a?: number; b: string; };
*
* const obj = fromObject(<Foo>{}, { keys: ["a", "b"], initial: false });
* obj.streams.a.subscribe(trace("a"));

@@ -132,3 +135,3 @@ * obj.streams.b.subscribe(trace("b"));

*/
export declare const fromObject: <T extends object, K extends keyof T>(src: T, opts?: Partial<StreamObjOpts<T, K>>) => StreamObj<T, K>;
export declare const fromObject: <T extends object, K extends Keys<T>>(src: T, opts?: Partial<StreamObjOpts<T, K>>) => StreamObj<T, K>;
//# sourceMappingURL=object.d.ts.map
{
"name": "@thi.ng/rstream",
"version": "8.5.0",
"version": "8.5.1",
"description": "Reactive streams & subscription primitives for constructing dataflow graphs / pipelines",

@@ -13,3 +13,3 @@ "type": "module",

},
"homepage": "https://github.com/thi-ng/umbrella/tree/develop/packages/rstream#readme",
"homepage": "https://thi.ng/rstream",
"funding": [

@@ -44,16 +44,16 @@ {

"dependencies": {
"@thi.ng/api": "^8.11.2",
"@thi.ng/arrays": "^2.9.6",
"@thi.ng/associative": "^6.3.60",
"@thi.ng/atom": "^5.3.0",
"@thi.ng/checks": "^3.6.4",
"@thi.ng/errors": "^2.5.7",
"@thi.ng/logger": "^3.0.12",
"@thi.ng/transducers": "^9.0.5"
"@thi.ng/api": "^8.11.3",
"@thi.ng/arrays": "^2.9.7",
"@thi.ng/associative": "^6.3.61",
"@thi.ng/atom": "^5.3.1",
"@thi.ng/checks": "^3.6.5",
"@thi.ng/errors": "^2.5.8",
"@thi.ng/logger": "^3.0.13",
"@thi.ng/transducers": "^9.0.6"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.43.2",
"esbuild": "^0.21.1",
"@microsoft/api-extractor": "^7.47.0",
"esbuild": "^0.21.5",
"typedoc": "^0.25.13",
"typescript": "^5.4.5"
"typescript": "^5.5.2"
},

@@ -223,3 +223,3 @@ "keywords": [

},
"gitHead": "df34b4a9e650cc7323575356de207d78933bdcf3\n"
"gitHead": "154c95cf9d6bab32174498ec3b5b5d87e42be7f9\n"
}

@@ -19,11 +19,11 @@ import type { ISubscriber } from "./api.js";

* @example
* ```ts
* ```ts tangle:../export/post-worker.ts
* import { postWorker, stream } from "@thi.ng/rstream";
*
* // worker source code
* src = `self.onmessage = (e) => console.log("worker", e.data);`;
* const src = `self.onmessage = (e) => console.log("worker", e.data);`;
*
* a = stream();
* const a = stream<any>();
* a.subscribe(
* postWorker(src, { type: "application/javascript" }))
* postWorker(new Blob([src], { type: "application/javascript" }))
* );

@@ -30,0 +30,0 @@ *

@@ -13,4 +13,4 @@ import type { ISubscription, WithErrorHandlerOpts } from "./api.js";

* @example
* ```ts
* import { fromPromises } from "@thi.ng/rstream";
* ```ts tangle:../export/from-promises.ts
* import { fromPromises, trace } from "@thi.ng/rstream";
*

@@ -28,16 +28,2 @@ * fromPromises([

*
* @example
* If individual error handling is required, an alternative is below
* (however this approach provides no ordering guarantees):
*
* ```ts
* import { fromIterable, resolve, trace } from "@thi.ng/rstream";
*
* fromIterable([
* Promise.resolve(1),
* new Promise(() => setTimeout(() => { throw new Error("eeek"); }, 10)),
* Promise.resolve(3)
* ]).subscribe(resolve()).subscribe(trace())
* ```
*
* @param promises -

@@ -44,0 +30,0 @@ * @param opts -

@@ -10,3 +10,3 @@ <!-- This file is generated - DO NOT EDIT! -->

> [!NOTE]
> This is one of 192 standalone projects, maintained as part
> This is one of 193 standalone projects, maintained as part
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo

@@ -13,0 +13,0 @@ > and anti-framework.

@@ -20,10 +20,10 @@ import type { Fn, IID } from "@thi.ng/api";

* @example
* ```ts
* ```ts tangle:../export/resolve.ts
* import { fromIterable, resolve, trace } from "@thi.ng/rstream";
* import { delayed } from "@thi.ng/transducers";
*
* fromIterable([1, 2, 3], 100)
* fromIterable([1, 2, 3], 500)
* .transform(delayed(1000))
* .subscribe(resolve())
* .subscribe(trace("result"))
* .subscribe(trace("result"));
* // result 1

@@ -30,0 +30,0 @@ * // result 2

@@ -20,11 +20,13 @@ import type { Predicate } from "@thi.ng/api";

* @example
* ```ts
* ```ts tangle:../export/sidechain-partition.ts
* import { fromEvent, fromRAF, merge, sidechainPartition, trace } from "@thi.ng/rstream";
*
* // merge various event streams
* events = merge([
* const events = merge({
* src: [
* fromEvent(document,"mousemove"),
* fromEvent(document,"mousedown"),
* fromEvent(document,"mouseup")
* ]);
* ]
* });
*

@@ -55,5 +57,5 @@ * // queue event processing to only execute during the

* @example
* ```ts
* ```ts tangle:../export/sidechain-partition-raf.ts
* import { defAtom } from "@thi.ng/atom";
* import { sideChainPartitionRAF } from "@thi.ng/rstream";
* import { fromAtom, sidechainPartitionRAF } from "@thi.ng/rstream";
*

@@ -63,4 +65,4 @@ * const atom = defAtom("alice");

* // any change to the atom will only be applied during next RAF update
* sideChainPartitionRAF(fromAtom(atom)).subscribe({
* next({ name }) { document.body.innerText = name; }
* sidechainPartitionRAF(fromAtom(atom)).subscribe({
* next(name) { document.body.innerText = name; }
* });

@@ -67,0 +69,0 @@ *

@@ -20,13 +20,19 @@ import type { Predicate } from "@thi.ng/api";

* @example
* ```ts
* ```ts tangle:../export/sidechain-toggle.ts
* import { fromInterval, sidechainToggle, trace } from "@thi.ng/rstream";
*
* const src = fromInterval(500);
*
* // close stream after 5 secs
* setTimeout(() => src.done(), 5000);
*
* // use slower interval stream to toggle faster main stream on/off
* sidechainToggle(fromInterval(500), fromInterval(1000)).subscribe(trace());
* sidechainToggle(src, fromInterval(1000)).subscribe(trace());
* // 0
* // 3
* // 1
* // 4
* // 7
* // 5
* // 8
* ...
* // 9
* // done
* ```

@@ -33,0 +39,0 @@ *

@@ -21,3 +21,3 @@ import type { Predicate } from "@thi.ng/api";

* @example
* ```ts
* ```ts tangle:../export/sidechain-trigger.ts
* import { reactive, stream, sidechainTrigger, trace } from "@thi.ng/rstream";

@@ -44,3 +44,2 @@ *

* // data: update #2
* ...
* ```

@@ -47,0 +46,0 @@ *

@@ -30,6 +30,6 @@ import type { Maybe } from "@thi.ng/api";

* @example
* ```ts
* ```ts tangle:../export/stream.ts
* import { stream, subscription, trace } from "@thi.ng/rstream";
*
* a = stream((s) => {
* const a = stream((s) => {
* s.next(1);

@@ -45,3 +45,3 @@ * s.next(2);

* // as reactive value mechanism
* b = stream();
* const b = stream();
* // or alternatively

@@ -48,0 +48,0 @@ * // b = subscription();

@@ -35,3 +35,3 @@ import type { Fn, Maybe } from "@thi.ng/api";

* @example
* ```ts
* ```ts tangle:../export/subscription.ts
* import { subscription, trace } from "@thi.ng/rstream";

@@ -41,5 +41,8 @@ * import { filter } from "@thi.ng/transducers";

* // as reactive value mechanism (same as with stream() above)
* s = subscription();
* const s = subscription<number, number>();
*
* // attach child subscriptions
* s.subscribe(trace("s1"));
* s.subscribe(trace("s2"), { xform: filter((x) => x > 25) });
* // this child sub will receive filtered values only
* s.subscribe(trace("s2"), { xform: filter((x: number) => x > 25) });
*

@@ -46,0 +49,0 @@ * // external trigger

@@ -1,2 +0,1 @@

/// <reference types="node" />
import { type CommonOpts, type ISubscribable } from "./api.js";

@@ -16,3 +15,3 @@ import { Subscription } from "./subscription.js";

* @example
* ```ts
* ```ts tangle:../export/sync-raf.ts
* import { defAtom } from "@thi.ng/atom";

@@ -19,0 +18,0 @@ * import { fromAtom, syncRAF } from "@thi.ng/rstream";

@@ -95,11 +95,21 @@ import type { Always, Derefed, IObjectOf } from "@thi.ng/api";

* @example
* ```ts
* ```ts tangle:../export/sync.ts
* import { stream, sync, trace } from "@thi.ng/rstream";
*
* const a = stream();
* const b = stream();
* s = sync({ src: { a, b } }).subscribe(trace("result: "));
* const a = stream<number>();
* const b = stream<number>();
*
* const main = sync({ src: { a, b } }).subscribe(trace("result: "));
*
* a.next(1);
* // main received value, but does not yet emit...
*
* b.next(2);
* // now that `b` has delivered a value, `main` will produce its 1st result tuple
* // result: { a: 1, b: 2 }
*
* // any further input changes will trigger new results
* // (with cached values from other inputs)
* b.next(3);
* // result: { a: 1, b: 3 }
* ```

@@ -106,0 +116,0 @@ *

@@ -9,3 +9,3 @@ import type { CommonOpts } from "./api.js";

* @examples
* ```ts
* ```ts tangle:../export/toggle.ts
* import { toggle, trace } from "@thi.ng/rstream";

@@ -12,0 +12,0 @@ *

@@ -12,3 +12,3 @@ import type { Reducer, Transducer } from "@thi.ng/transducers";

* @example
* ```ts
* ```ts tangle:../export/transduce.ts
* import { fromIterable, transduce } from "@thi.ng/rstream";

@@ -15,0 +15,0 @@ * import { add, map, range } from "@thi.ng/transducers";

@@ -24,6 +24,6 @@ import type { Fn2 } from "@thi.ng/api";

* @example
* ```ts
* import { stream, tween } from "@thi.ng/rstream";
* ```ts tangle:../export/tween.ts
* import { stream, tween, trace } from "@thi.ng/rstream";
*
* val = stream();
* const val = stream<number>();
*

@@ -41,3 +41,3 @@ * tween(

*
* a.next(10)
* val.next(10)
* // 5

@@ -48,3 +48,3 @@ * // 7.5

*
* a.next(100)
* val.next(100)
* // 55

@@ -54,2 +54,5 @@ * // 77.5

* // 99.989013671875
*
* // terminate after 1sec
* setTimeout(() => val.done(), 1000);
* ```

@@ -56,0 +59,0 @@ *

@@ -16,3 +16,3 @@ import type { DeepPath, Fn, OptPathVal, Path, Path0, Path1, Path2, Path3, Path4, Path5, Path6, Path7, Path8, Predicate2 } from "@thi.ng/api";

* @example
* ```ts
* ```ts tangle:../export/from-view-unsafe.ts
* import { defAtom } from "@thi.ng/atom";

@@ -73,12 +73,17 @@ * import { fromViewUnsafe, trace } from "@thi.ng/rstream";

* @example
* ```ts
* ```ts tangle:../export/from-view.ts
* import { defAtom } from "@thi.ng/atom";
* import { fromView, trace } from "@thi.ng/rstream";
*
* const db = defAtom<any>({ a: 1, b: { c: 2 }});
* interface DB {
* a: number;
* b?: { c: number; }
* }
*
* const db = defAtom<DB>({ a: 1, b: { c: 2 }});
*
* fromView(
* db,
* {
* path: ["b,"c"],
* path: ["b", "c"],
* tx: (x) => x != null ? String(x) : "n/a"

@@ -89,3 +94,3 @@ * }

*
* db.swapIn(["b","c"], (x) => x + 1);
* db.swapIn(["b","c"], (x) => x! + 1);
* // view: 3

@@ -92,0 +97,0 @@ *

@@ -26,7 +26,2 @@ import type { WithErrorHandlerOpts, WorkerSource } from "./api.js";

*
* @example
* ```ts
*
* ```
*
* @param worker -

@@ -33,0 +28,0 @@ * @param opts -

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc