New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rnjs

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rnjs - npm Package Compare versions

Comparing version 1.0.22 to 1.0.23

dev/src/internal/operators/terminateBy.ts

1

dev/src/internal/mod.ts

@@ -19,4 +19,5 @@ // This file is created to avoid circular reference between RN and operators.

export * from './operators/take';
export * from './operators/terminateBy';
export * from './operators/throttle';
export * from './operators/withInitialValue';
export * from './operators/withLatest';

6

dev/src/internal/operators/scan.ts

@@ -8,3 +8,3 @@ /* removed in prod */ import { RN } from '../mod';

initialValue: U,
fn: (state: U, srcValue: T, srcIndex: number, index: number) => U
fn: (state: Readonly<U>, srcValue: T, srcIndex: number, index: number) => U
): Operator<T, U> =>

@@ -16,3 +16,3 @@ (( src: RN<T> ) => new ScanRN<T, U>( initialValue, src, fn ));

private scanState: U;
private readonly fn: (state: U, srcValue: T, srcIndex: number, index: number) => U;
private readonly fn: (state: Readonly<U>, srcValue: T, srcIndex: number, index: number) => U;

@@ -22,3 +22,3 @@ constructor(

src: RN<T>,
fn: (state: U, srcValue: T, srcIndex: number, index: number) => U
fn: (state: Readonly<U>, srcValue: T, srcIndex: number, index: number) => U
) {

@@ -25,0 +25,0 @@ super( initialValue, [src] );

@@ -30,2 +30,3 @@ import { RNId } from './types/RNId';

/* removed in prod */ takeWhile,
/* removed in prod */ terminateBy,
/* removed in prod */ throttle,

@@ -380,4 +381,4 @@ /* removed in prod */ withInitialValue,

listenWhile(
predicate: (srcValue: T, srcIndex: number, index: number) => boolean,
listenUntil(
terminator: RN<void>,
runWithFirstValue: boolean = true,

@@ -388,3 +389,3 @@ onFire: (v: T) => void,

): Subscription {
return this.takeWhile( predicate )
return this.terminateBy( terminator )
.listen( runWithFirstValue, onFire, onError, onComplete );

@@ -545,3 +546,3 @@ }

initialValue: U,
fn: (state: U, srcValue: T, srcIndex: number, index: number) => U
fn: (state: Readonly<U>, srcValue: T, srcIndex: number, index: number) => U
): RN<U> {

@@ -590,2 +591,6 @@ return scan<T, U>( initialValue, fn )( this );

terminateBy(terminator: RN<void>): RN<T> {
return terminateBy<T>( terminator )( this );
}
throttle( time: number ): RN<T> {

@@ -592,0 +597,0 @@ return throttle<T>( time )( this );

@@ -11,26 +11,1 @@ import { RN } from '../RN';

}
export function applyMixins( derivedCtor: any, baseCtors: any[] ) {
baseCtors.forEach( baseCtor => {
Object.getOwnPropertyNames( baseCtor.prototype ).forEach( name => {
derivedCtor.prototype[name] = baseCtor.prototype[name];
});
});
}
// export function cancelableSleep( time: number ): [Promise<void>, () => void] {
// let timerId: any;
// let reject: () => void;
// const promise = new Promise<void>( (res, rej) => {
// timerId = setTimeout( res, time );
// reject = rej;
// } );
// const cancel = () => {
// clearTimeout( timerId );
// reject();
// };
// return [promise, cancel];
// }

@@ -23,2 +23,3 @@ export {

takeWhile,
terminateBy,
throttle,

@@ -25,0 +26,0 @@ withLatest,

@@ -7,3 +7,3 @@ import {

combine,
// manual,
manual,
// merge,

@@ -21,7 +21,31 @@ // fromObservable,

const counter = interval( 500, true );
const a = counter.map( x => x % 2 === 0 );
const b = counter.map( x => x % 3 === 0 );
counter.listen( true, console.log );
some(a, b).listen( true, console.log );
const intv = interval( 300, true );
const terminator = manual<void>(undefined);
setTimeout(() => { terminator.terminate(); }, 2000);
intv.listenUntil(terminator, true, v => console.log(v), undefined, () => console.log('end') );
// Mutation is not
// foo.bar = 456;
// const values = [3, 3, 3, 1, 4, 1, 5, 9, 9, 9, 2, 6];
// const a = interval(100, true);
// const b = a.takeWhile( i => 0 <= i && i < 10 )
// .scan( { v: 0 }, (s: { v: number }, curr: number) => {
// s.v += curr;
// return s;
// });
// // .skipUnchanged();
// b.listen( false, console.log );
/////////////////
// const counter = interval( 500, true );
// const a = counter.map( x => x % 2 === 0 );
// const b = counter.map( x => x % 3 === 0 );
// counter.listen( true, console.log );
// some(a, b).listen( true, console.log );
/////////////////
// const b = a.startWith(999);

@@ -28,0 +52,0 @@ // const c = a.withInitialValue(888);

@@ -16,4 +16,5 @@ export * from './RN';

export * from './operators/take';
export * from './operators/terminateBy';
export * from './operators/throttle';
export * from './operators/withInitialValue';
export * from './operators/withLatest';

@@ -22,4 +22,5 @@ "use strict";

__export(require("./operators/take"));
__export(require("./operators/terminateBy"));
__export(require("./operators/throttle"));
__export(require("./operators/withInitialValue"));
__export(require("./operators/withLatest"));
import { RN } from '../mod';
export declare const scan: <T, U>(initialValue: U, fn: (state: U, srcValue: T, srcIndex: number, index: number) => U) => (src: RN<T>) => RN<U>;
export declare const scan: <T, U>(initialValue: U, fn: (state: Readonly<U>, srcValue: T, srcIndex: number, index: number) => U) => (src: RN<T>) => RN<U>;

@@ -40,3 +40,3 @@ import { Subscriber } from './types/Subscriber';

subscribe(subscriber: Subscriber<T>): Subscription;
listenWhile(predicate: (srcValue: T, srcIndex: number, index: number) => boolean, runWithFirstValue: boolean | undefined, onFire: (v: T) => void, onError?: (e?: any) => void, onComplete?: (v: T) => void): Subscription;
listenUntil(terminator: RN<void>, runWithFirstValue: boolean | undefined, onFire: (v: T) => void, onError?: (e?: any) => void, onComplete?: (v: T) => void): Subscription;
once(): Promise<T>;

@@ -66,3 +66,3 @@ toPromise(): Promise<T>;

pairwise(initialPrevValue?: T): RN<[T, T]>;
scan<U>(initialValue: U, fn: (state: U, srcValue: T, srcIndex: number, index: number) => U): RN<U>;
scan<U>(initialValue: U, fn: (state: Readonly<U>, srcValue: T, srcIndex: number, index: number) => U): RN<U>;
skip(initialValue: T, skipNum: number): RN<T>;

@@ -76,2 +76,3 @@ skipWhile(initialValue: T, predicate: (srcValue: T, srcIndex: number, index: number) => boolean): RN<T>;

takeWhile(predicate: (srcValue: T, srcIndex: number, index: number) => boolean): RN<T>;
terminateBy(terminator: RN<void>): RN<T>;
throttle(time: number): RN<T>;

@@ -78,0 +79,0 @@ withInitialValue(initialValue: T): RN<T>;

@@ -228,4 +228,4 @@ "use strict";

}
listenWhile(predicate, runWithFirstValue = true, onFire, onError, onComplete) {
return this.takeWhile(predicate)
listenUntil(terminator, runWithFirstValue = true, onFire, onError, onComplete) {
return this.terminateBy(terminator)
.listen(runWithFirstValue, onFire, onError, onComplete);

@@ -320,2 +320,5 @@ }

}
terminateBy(terminator) {
return mod_1.terminateBy(terminator)(this);
}
throttle(time) {

@@ -322,0 +325,0 @@ return mod_1.throttle(time)(this);

@@ -8,2 +8,1 @@ import { RN } from '../RN';

export declare function unwrapCurr<T extends RN<any>[]>(...rns: T): Unwrap<T>;
export declare function applyMixins(derivedCtor: any, baseCtors: any[]): void;

@@ -7,22 +7,1 @@ "use strict";

exports.unwrapCurr = unwrapCurr;
function applyMixins(derivedCtor, baseCtors) {
baseCtors.forEach(baseCtor => {
Object.getOwnPropertyNames(baseCtor.prototype).forEach(name => {
derivedCtor.prototype[name] = baseCtor.prototype[name];
});
});
}
exports.applyMixins = applyMixins;
// export function cancelableSleep( time: number ): [Promise<void>, () => void] {
// let timerId: any;
// let reject: () => void;
// const promise = new Promise<void>( (res, rej) => {
// timerId = setTimeout( res, time );
// reject = rej;
// } );
// const cancel = () => {
// clearTimeout( timerId );
// reject();
// };
// return [promise, cancel];
// }

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

export { auditTime, debounce, delay, filter, flatMap, map, mapTo, valueIs, valueIsNot, withTimestamp, pluck, pairwise, scan, skipAlreadyAppeared, skipUnchanged, skip, skipWhile, startWith, switchMap, take, takeWhile, throttle, withLatest, withInitialValue, } from './internal/mod';
export { auditTime, debounce, delay, filter, flatMap, map, mapTo, valueIs, valueIsNot, withTimestamp, pluck, pairwise, scan, skipAlreadyAppeared, skipUnchanged, skip, skipWhile, startWith, switchMap, take, takeWhile, terminateBy, throttle, withLatest, withInitialValue, } from './internal/mod';

@@ -25,4 +25,5 @@ "use strict";

exports.takeWhile = mod_1.takeWhile;
exports.terminateBy = mod_1.terminateBy;
exports.throttle = mod_1.throttle;
exports.withLatest = mod_1.withLatest;
exports.withInitialValue = mod_1.withInitialValue;

@@ -11,7 +11,24 @@ "use strict";

// } from './operators';
const counter = RN_1.interval(500, true);
const a = counter.map(x => x % 2 === 0);
const b = counter.map(x => x % 3 === 0);
counter.listen(true, console.log);
RN_1.some(a, b).listen(true, console.log);
const intv = RN_1.interval(300, true);
const terminator = RN_1.manual(undefined);
setTimeout(() => { terminator.terminate(); }, 2000);
intv.listenUntil(terminator, true, v => console.log(v), undefined, () => console.log('end'));
// Mutation is not
// foo.bar = 456;
// const values = [3, 3, 3, 1, 4, 1, 5, 9, 9, 9, 2, 6];
// const a = interval(100, true);
// const b = a.takeWhile( i => 0 <= i && i < 10 )
// .scan( { v: 0 }, (s: { v: number }, curr: number) => {
// s.v += curr;
// return s;
// });
// // .skipUnchanged();
// b.listen( false, console.log );
/////////////////
// const counter = interval( 500, true );
// const a = counter.map( x => x % 2 === 0 );
// const b = counter.map( x => x % 3 === 0 );
// counter.listen( true, console.log );
// some(a, b).listen( true, console.log );
/////////////////
// const b = a.startWith(999);

@@ -18,0 +35,0 @@ // const c = a.withInitialValue(888);

@@ -40,3 +40,3 @@ import { Subscriber } from './types/Subscriber';

subscribe(subscriber: Subscriber<T>): Subscription;
listenWhile(predicate: (srcValue: T, srcIndex: number, index: number) => boolean, runWithFirstValue: boolean | undefined, onFire: (v: T) => void, onError?: (e?: any) => void, onComplete?: (v: T) => void): Subscription;
listenUntil(terminator: RN<void>, runWithFirstValue: boolean | undefined, onFire: (v: T) => void, onError?: (e?: any) => void, onComplete?: (v: T) => void): Subscription;
once(): Promise<T>;

@@ -66,3 +66,3 @@ toPromise(): Promise<T>;

pairwise(initialPrevValue?: T): RN<[T, T]>;
scan<U>(initialValue: U, fn: (state: U, srcValue: T, srcIndex: number, index: number) => U): RN<U>;
scan<U>(initialValue: U, fn: (state: Readonly<U>, srcValue: T, srcIndex: number, index: number) => U): RN<U>;
skip(initialValue: T, skipNum: number): RN<T>;

@@ -76,2 +76,3 @@ skipWhile(initialValue: T, predicate: (srcValue: T, srcIndex: number, index: number) => boolean): RN<T>;

takeWhile(predicate: (srcValue: T, srcIndex: number, index: number) => boolean): RN<T>;
terminateBy(terminator: RN<void>): RN<T>;
throttle(time: number): RN<T>;

@@ -93,3 +94,3 @@ withInitialValue(initialValue: T): RN<T>;

export declare const pairwise: <T>(initialPrevValue?: T | undefined) => (src: RN<T>) => RN<[T, T]>;
export declare const scan: <T, U>(initialValue: U, fn: (state: U, srcValue: T, srcIndex: number, index: number) => U) => (src: RN<T>) => RN<U>;
export declare const scan: <T, U>(initialValue: U, fn: (state: Readonly<U>, srcValue: T, srcIndex: number, index: number) => U) => (src: RN<T>) => RN<U>;
export declare const skip: <T>(initialValue: T, skipNum: number) => (src: RN<T>) => RN<T>;

@@ -103,4 +104,6 @@ export declare const skipWhile: <T>(initialValue: T, predicate: (srcValue: T, srcIndex: number, index: number) => boolean) => (src: RN<T>) => RN<T>;

export declare const takeWhile: <T>(predicate: (srcValue: T, srcIndex: number, index: number) => boolean) => (src: RN<T>) => RN<T>;
export declare const terminateBy: <T>(terminator: RN<void>) => (src: RN<T>) => RN<T>;
export declare const takeUntil: <T>(terminator: RN<void>) => (src: RN<T>) => RN<T>;
export declare const throttle: <T>(time: number) => (src: RN<T>) => RN<T>;
export declare const withInitialValue: <T>(initialValue: T) => (src: RN<T>) => RN<T>;
export declare const withLatest: <T, U>(src2: RN<U>) => (src: RN<T>) => RN<[T, U]>;

@@ -227,4 +227,4 @@ "use strict";

}
listenWhile(predicate, runWithFirstValue = true, onFire, onError, onComplete) {
return this.takeWhile(predicate)
listenUntil(terminator, runWithFirstValue = true, onFire, onError, onComplete) {
return this.terminateBy(terminator)
.listen(runWithFirstValue, onFire, onError, onComplete);

@@ -319,2 +319,5 @@ }

}
terminateBy(terminator) {
return exports.terminateBy(terminator)(this);
}
throttle(time) {

@@ -568,2 +571,18 @@ return exports.throttle(time)(this);

}
exports.terminateBy = (terminator) => ((src) => new TerminateByRN(src, terminator));
exports.takeUntil = (terminator) => ((src) => new TerminateByRN(src, terminator));
class TerminateByRN extends RN {
constructor(src, terminator) {
super(src.value, [src]);
this.subscription = terminator.listen(false, () => { }, () => { }, () => this.terminate());
}
fire() {
const src = this.parents[0];
this.fireWith(src.value);
}
complete() {
super.complete();
this.subscription.unsubscribe();
}
}
exports.throttle = (time) => ((src) => new ThrottleRN(src, time));

@@ -570,0 +589,0 @@ class ThrottleRN extends RN {

@@ -8,2 +8,1 @@ import { RN } from '../RN';

export declare function unwrapCurr<T extends RN<any>[]>(...rns: T): Unwrap<T>;
export declare function applyMixins(derivedCtor: any, baseCtors: any[]): void;

@@ -7,22 +7,1 @@ "use strict";

exports.unwrapCurr = unwrapCurr;
function applyMixins(derivedCtor, baseCtors) {
baseCtors.forEach(baseCtor => {
Object.getOwnPropertyNames(baseCtor.prototype).forEach(name => {
derivedCtor.prototype[name] = baseCtor.prototype[name];
});
});
}
exports.applyMixins = applyMixins;
// export function cancelableSleep( time: number ): [Promise<void>, () => void] {
// let timerId: any;
// let reject: () => void;
// const promise = new Promise<void>( (res, rej) => {
// timerId = setTimeout( res, time );
// reject = rej;
// } );
// const cancel = () => {
// clearTimeout( timerId );
// reject();
// };
// return [promise, cancel];
// }

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

export { auditTime, debounce, delay, filter, flatMap, map, mapTo, valueIs, valueIsNot, withTimestamp, pluck, pairwise, scan, skipAlreadyAppeared, skipUnchanged, skip, skipWhile, startWith, switchMap, take, takeWhile, throttle, withLatest, withInitialValue, } from './internal/RN';
export { auditTime, debounce, delay, filter, flatMap, map, mapTo, valueIs, valueIsNot, withTimestamp, pluck, pairwise, scan, skipAlreadyAppeared, skipUnchanged, skip, skipWhile, startWith, switchMap, take, takeWhile, terminateBy, throttle, withLatest, withInitialValue, } from './internal/RN';

@@ -25,4 +25,5 @@ "use strict";

exports.takeWhile = RN_1.takeWhile;
exports.terminateBy = RN_1.terminateBy;
exports.throttle = RN_1.throttle;
exports.withLatest = RN_1.withLatest;
exports.withInitialValue = RN_1.withInitialValue;

@@ -11,7 +11,24 @@ "use strict";

// } from './operators';
const counter = RN_1.interval(500, true);
const a = counter.map(x => x % 2 === 0);
const b = counter.map(x => x % 3 === 0);
counter.listen(true, console.log);
RN_1.some(a, b).listen(true, console.log);
const intv = RN_1.interval(300, true);
const terminator = RN_1.manual(undefined);
setTimeout(() => { terminator.terminate(); }, 2000);
intv.listenUntil(terminator, true, v => console.log(v), undefined, () => console.log('end'));
// Mutation is not
// foo.bar = 456;
// const values = [3, 3, 3, 1, 4, 1, 5, 9, 9, 9, 2, 6];
// const a = interval(100, true);
// const b = a.takeWhile( i => 0 <= i && i < 10 )
// .scan( { v: 0 }, (s: { v: number }, curr: number) => {
// s.v += curr;
// return s;
// });
// // .skipUnchanged();
// b.listen( false, console.log );
/////////////////
// const counter = interval( 500, true );
// const a = counter.map( x => x % 2 === 0 );
// const b = counter.map( x => x % 3 === 0 );
// counter.listen( true, console.log );
// some(a, b).listen( true, console.log );
/////////////////
// const b = a.startWith(999);

@@ -18,0 +35,0 @@ // const c = a.withInitialValue(888);

@@ -6,3 +6,3 @@ {

"name": "rnjs",
"version": "1.0.22",
"version": "1.0.23",
"description": "Reactive Programming Library for TypeScript/JavaScript",

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

@@ -353,4 +353,4 @@ import { RNId } from './types/RNId';

listenWhile(
predicate: (srcValue: T, srcIndex: number, index: number) => boolean,
listenUntil(
terminator: RN<void>,
runWithFirstValue: boolean = true,

@@ -361,3 +361,3 @@ onFire: (v: T) => void,

): Subscription {
return this.takeWhile( predicate )
return this.terminateBy( terminator )
.listen( runWithFirstValue, onFire, onError, onComplete );

@@ -518,3 +518,3 @@ }

initialValue: U,
fn: (state: U, srcValue: T, srcIndex: number, index: number) => U
fn: (state: Readonly<U>, srcValue: T, srcIndex: number, index: number) => U
): RN<U> {

@@ -563,2 +563,6 @@ return scan<T, U>( initialValue, fn )( this );

terminateBy(terminator: RN<void>): RN<T> {
return terminateBy<T>( terminator )( this );
}
throttle( time: number ): RN<T> {

@@ -795,3 +799,3 @@ return throttle<T>( time )( this );

initialValue: U,
fn: (state: U, srcValue: T, srcIndex: number, index: number) => U
fn: (state: Readonly<U>, srcValue: T, srcIndex: number, index: number) => U
): Operator<T, U> =>

@@ -803,3 +807,3 @@ (( src: RN<T> ) => new ScanRN<T, U>( initialValue, src, fn ));

private scanState: U;
private readonly fn: (state: U, srcValue: T, srcIndex: number, index: number) => U;
private readonly fn: (state: Readonly<U>, srcValue: T, srcIndex: number, index: number) => U;

@@ -809,3 +813,3 @@ constructor(

src: RN<T>,
fn: (state: U, srcValue: T, srcIndex: number, index: number) => U
fn: (state: Readonly<U>, srcValue: T, srcIndex: number, index: number) => U
) {

@@ -1017,2 +1021,34 @@ super( initialValue, [src] );

export const terminateBy = <T>(terminator: RN<void>): Operator<T, T> =>
(( src: RN<T> ) => new TerminateByRN<T>(src, terminator));
export const takeUntil = <T>(terminator: RN<void>): Operator<T, T> =>
(( src: RN<T> ) => new TerminateByRN<T>(src, terminator));
class TerminateByRN<T> extends RN<T> {
private readonly subscription: Subscription;
constructor(
src: RN<T>,
terminator: RN<void>,
) {
super( src.value, [src] );
this.subscription = terminator.listen( false, () => {}, () => {}, () => this.terminate() );
}
protected fire() {
const src = this.parents[0];
this.fireWith( src.value );
}
complete() {
super.complete();
this.subscription.unsubscribe();
}
}
export const throttle = <T>( time: number ): Operator<T, T> =>

@@ -1019,0 +1055,0 @@ (( src: RN<T> ) => new ThrottleRN<T>( src, time ));

@@ -11,26 +11,1 @@ import { RN } from '../RN';

}
export function applyMixins( derivedCtor: any, baseCtors: any[] ) {
baseCtors.forEach( baseCtor => {
Object.getOwnPropertyNames( baseCtor.prototype ).forEach( name => {
derivedCtor.prototype[name] = baseCtor.prototype[name];
});
});
}
// export function cancelableSleep( time: number ): [Promise<void>, () => void] {
// let timerId: any;
// let reject: () => void;
// const promise = new Promise<void>( (res, rej) => {
// timerId = setTimeout( res, time );
// reject = rej;
// } );
// const cancel = () => {
// clearTimeout( timerId );
// reject();
// };
// return [promise, cancel];
// }

@@ -23,2 +23,3 @@ export {

takeWhile,
terminateBy,
throttle,

@@ -25,0 +26,0 @@ withLatest,

@@ -7,3 +7,3 @@ import {

combine,
// manual,
manual,
// merge,

@@ -21,7 +21,31 @@ // fromObservable,

const counter = interval( 500, true );
const a = counter.map( x => x % 2 === 0 );
const b = counter.map( x => x % 3 === 0 );
counter.listen( true, console.log );
some(a, b).listen( true, console.log );
const intv = interval( 300, true );
const terminator = manual<void>(undefined);
setTimeout(() => { terminator.terminate(); }, 2000);
intv.listenUntil(terminator, true, v => console.log(v), undefined, () => console.log('end') );
// Mutation is not
// foo.bar = 456;
// const values = [3, 3, 3, 1, 4, 1, 5, 9, 9, 9, 2, 6];
// const a = interval(100, true);
// const b = a.takeWhile( i => 0 <= i && i < 10 )
// .scan( { v: 0 }, (s: { v: number }, curr: number) => {
// s.v += curr;
// return s;
// });
// // .skipUnchanged();
// b.listen( false, console.log );
/////////////////
// const counter = interval( 500, true );
// const a = counter.map( x => x % 2 === 0 );
// const b = counter.map( x => x % 3 === 0 );
// counter.listen( true, console.log );
// some(a, b).listen( true, console.log );
/////////////////
// const b = a.startWith(999);

@@ -28,0 +52,0 @@ // const c = a.withInitialValue(888);

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