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

@thi.ng/rstream

Package Overview
Dependencies
Maintainers
1
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 0.2.2 to 0.3.0

10

from/raf.d.ts
import { Stream } from "../stream";
/**
* Yields a stream of monotonically increasing counter,
* triggered by a `requestAnimationFrame()` loop.
* Only available in browser environments. In NodeJS,
* this function falls back to `fromInterval(16)`, yielding
* a similar (approximately 60fps) stream.
*
* Subscribers to this stream will be processed during
* that same loop iteration.
*/
export declare function fromRAF(): Stream<number>;

30

from/raf.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const is_node_1 = require("@thi.ng/checks/is-node");
const stream_1 = require("../stream");
const interval_1 = require("./interval");
/**
* Yields a stream of monotonically increasing counter,
* triggered by a `requestAnimationFrame()` loop.
* Only available in browser environments. In NodeJS,
* this function falls back to `fromInterval(16)`, yielding
* a similar (approximately 60fps) stream.
*
* Subscribers to this stream will be processed during
* that same loop iteration.
*/
function fromRAF() {
return new stream_1.Stream((o) => {
let i = 0, id, isActive = true, loop = () => {
isActive && o.next(i++);
isActive && (id = requestAnimationFrame(loop));
};
id = requestAnimationFrame(loop);
return () => (isActive = false, cancelAnimationFrame(id));
}, `raf-${stream_1.Stream.NEXT_ID++}`);
return is_node_1.isNode() ?
interval_1.fromInterval(16) :
new stream_1.Stream((o) => {
let i = 0, id, isActive = true, loop = () => {
isActive && o.next(i++);
isActive && (id = requestAnimationFrame(loop));
};
id = requestAnimationFrame(loop);
return () => (isActive = false, cancelAnimationFrame(id));
}, `raf-${stream_1.Stream.NEXT_ID++}`);
}
exports.fromRAF = fromRAF;
{
"name": "@thi.ng/rstream",
"version": "0.2.2",
"version": "0.3.0",
"description": "Reactive multi-tap streams & transformation pipeline constructs",

@@ -5,0 +5,0 @@ "main": "./index.js",

@@ -9,6 +9,5 @@ import { Transducer } from "@thi.ng/transducers/api";

constructor(src: StreamSource<T>, id?: string);
subscribe(sub: ISubscriber<T>, id?: string): Subscription<T, T>;
subscribe<C>(xform: Transducer<T, C>, id?: string): Subscription<T, C>;
subscribe<C>(sub: ISubscriber<T>, xform: Transducer<T, C>, id?: string): Subscription<T, C>;
subscribe(sub: ISubscriber<T>, id?: string): Subscription<T, T>;
transform<B>(xform: Transducer<T, B>, id?: string): Subscription<T, B>;
subscribe<C>(sub: ISubscriber<C>, xform: Transducer<T, C>, id?: string): Subscription<T, C>;
unsubscribe(sub?: Subscription<T, any>): boolean;

@@ -15,0 +14,0 @@ done(): void;

@@ -16,9 +16,2 @@ "use strict";

}
transform(xform, id) {
const wrapped = super.subscribe(xform, id);
if (this.subs.length === 1) {
this._cancel = (this.src && this.src(this)) || (() => void 0);
}
return wrapped;
}
unsubscribe(sub) {

@@ -25,0 +18,0 @@ const res = super.unsubscribe(sub);

@@ -20,3 +20,3 @@ "use strict";

else {
throw new Error(`resolved value in ${api_1.State[this.state]} state (${x})`);
console.log(`resolved value in ${api_1.State[this.state]} state (${x})`);
}

@@ -23,0 +23,0 @@ }).catch((e) => this.error(this, e));

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

subscribe<C>(xform: Transducer<B, C>, id?: string): Subscription<B, C>;
subscribe<C>(sub: ISubscriber<B>, xform: Transducer<B, C>, id?: string): Subscription<B, C>;
subscribe<C>(sub: ISubscriber<C>, xform: Transducer<B, C>, id?: string): Subscription<B, C>;
subscribeAll(...subs: ISubscriber<B>[]): Subscription<B, B>[];

@@ -17,0 +17,0 @@ unsubscribe(sub?: Subscription<B, any>): boolean;

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