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

@reactive-js/ix

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reactive-js/ix - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

dist/cjs/index.d.ts

15

dist/cjs/index.js

@@ -5,2 +5,3 @@ "use strict";

const observable_1 = require("@reactive-js/observable");
const pipe_1 = require("@reactive-js/pipe");
class AsyncIteratorResourceImpl {

@@ -36,14 +37,16 @@ constructor(subject, observable) {

exports.createEventEmitter = () => createAsyncIteratorResource(x => x);
exports.createStateStore = (initialState, scheduler, equals) => {
const operator = obs => observable_1.pipe(obs, observable_1.scan((acc, next) => next(acc), initialState), observable_1.startWith(initialState), observable_1.distinctUntilChanged(equals), observable_1.share(scheduler, 1));
exports.createReducerStore = (initialState, reducer, scheduler, equals) => {
const operator = obs => pipe_1.pipe(obs, observable_1.scan(reducer, () => initialState), observable_1.startWith(initialState), observable_1.distinctUntilChanged(equals), observable_1.share(scheduler, 1));
const store = createAsyncIteratorResource(operator);
store.add(rx_1.connect(store, scheduler));
pipe_1.pipe(store, rx_1.connect(scheduler), d => store.add(d));
return store;
};
const stateStoreReducer = (state, action) => action(state);
exports.createStateStore = (initialState, scheduler, equals) => exports.createReducerStore(initialState, stateStoreReducer, scheduler, equals);
exports.createPersistentStateStore = (persistentStore, initialState, scheduler, equals) => {
const dispatch = (req) => store.dispatch(req);
const operator = obs => {
const onPersistentStoreChangedStream = observable_1.pipe(persistentStore, observable_1.onNext(dispatch), observable_1.ignoreElements());
const stateObs = observable_1.pipe(obs, observable_1.scan((acc, next) => next(acc), initialState), observable_1.distinctUntilChanged(equals), observable_1.onNext(next => persistentStore.dispatch(next)));
return observable_1.pipe(observable_1.merge(onPersistentStoreChangedStream, stateObs), observable_1.share(scheduler, 1));
const onPersistentStoreChangedStream = pipe_1.pipe(persistentStore, observable_1.onNext(v => dispatch(_ => v)), observable_1.ignoreElements());
const stateObs = pipe_1.pipe(obs, observable_1.scan((acc, next) => next(acc), () => initialState), observable_1.distinctUntilChanged(equals), observable_1.onNext(next => persistentStore.dispatch(next)));
return pipe_1.pipe(observable_1.merge(onPersistentStoreChangedStream, stateObs), observable_1.share(scheduler, 1));
};

@@ -50,0 +53,0 @@ const store = createAsyncIteratorResource(operator);

import { connect, createSubject, } from "@reactive-js/rx";
import { distinctUntilChanged, ignoreElements, merge, onNext, pipe, scan, share, startWith, } from "@reactive-js/observable";
import { distinctUntilChanged, ignoreElements, merge, onNext, scan, share, startWith, } from "@reactive-js/observable";
import { pipe } from "@reactive-js/pipe";
class AsyncIteratorResourceImpl {

@@ -33,13 +34,15 @@ constructor(subject, observable) {

export const createEventEmitter = () => createAsyncIteratorResource(x => x);
export const createStateStore = (initialState, scheduler, equals) => {
const operator = obs => pipe(obs, scan((acc, next) => next(acc), initialState), startWith(initialState), distinctUntilChanged(equals), share(scheduler, 1));
export const createReducerStore = (initialState, reducer, scheduler, equals) => {
const operator = obs => pipe(obs, scan(reducer, () => initialState), startWith(initialState), distinctUntilChanged(equals), share(scheduler, 1));
const store = createAsyncIteratorResource(operator);
store.add(connect(store, scheduler));
pipe(store, connect(scheduler), d => store.add(d));
return store;
};
const stateStoreReducer = (state, action) => action(state);
export const createStateStore = (initialState, scheduler, equals) => createReducerStore(initialState, stateStoreReducer, scheduler, equals);
export const createPersistentStateStore = (persistentStore, initialState, scheduler, equals) => {
const dispatch = (req) => store.dispatch(req);
const operator = obs => {
const onPersistentStoreChangedStream = pipe(persistentStore, onNext(dispatch), ignoreElements());
const stateObs = pipe(obs, scan((acc, next) => next(acc), initialState), distinctUntilChanged(equals), onNext(next => persistentStore.dispatch(next)));
const onPersistentStoreChangedStream = pipe(persistentStore, onNext(v => dispatch(_ => v)), ignoreElements());
const stateObs = pipe(obs, scan((acc, next) => next(acc), () => initialState), distinctUntilChanged(equals), onNext(next => persistentStore.dispatch(next)));
return pipe(merge(onPersistentStoreChangedStream, stateObs), share(scheduler, 1));

@@ -46,0 +49,0 @@ };

3

dist/types/index.d.ts

@@ -18,4 +18,5 @@ import { ObservableLike, ObservableResourceLike } from "@reactive-js/rx";

export declare const createEventEmitter: <T>() => EventEmitterResourceLike<T>;
export declare const createReducerStore: <TAction, T>(initialState: T, reducer: (state: T, action: TAction) => T, scheduler: SchedulerLike, equals?: ((a: T, b: T) => boolean) | undefined) => AsyncIteratorResourceLike<TAction, T>;
export declare const createStateStore: <T>(initialState: T, scheduler: SchedulerLike, equals?: ((a: T, b: T) => boolean) | undefined) => StateStoreResourceLike<T>;
export declare const createPersistentStateStore: <T>(persistentStore: AsyncIteratorLike<T, StateUpdaterLike<T>>, initialState: T, scheduler: SchedulerLike, equals?: ((a: T, b: T) => boolean) | undefined) => StateStoreResourceLike<T>;
export declare const createPersistentStateStore: <T>(persistentStore: AsyncIteratorLike<T, T>, initialState: T, scheduler: SchedulerLike, equals?: ((a: T, b: T) => boolean) | undefined) => StateStoreResourceLike<T>;
//# sourceMappingURL=index.d.ts.map

@@ -24,2 +24,3 @@ [@reactive-js/ix](README.md)

* [createPersistentStateStore](README.md#const-createpersistentstatestore)
* [createReducerStore](README.md#const-createreducerstore)
* [createStateStore](README.md#const-createstatestore)

@@ -59,3 +60,3 @@

▸ **createPersistentStateStore**<**T**>(`persistentStore`: [AsyncIteratorLike](interfaces/asynciteratorlike.md)‹T, [StateUpdaterLike](interfaces/stateupdaterlike.md)‹T››, `initialState`: T, `scheduler`: SchedulerLike, `equals?`: undefined | function): *[StateStoreResourceLike](interfaces/statestoreresourcelike.md)‹T›*
▸ **createPersistentStateStore**<**T**>(`persistentStore`: [AsyncIteratorLike](interfaces/asynciteratorlike.md)‹T, T›, `initialState`: T, `scheduler`: SchedulerLike, `equals?`: undefined | function): *[StateStoreResourceLike](interfaces/statestoreresourcelike.md)‹T›*

@@ -70,3 +71,3 @@ **Type parameters:**

------ | ------ |
`persistentStore` | [AsyncIteratorLike](interfaces/asynciteratorlike.md)‹T, [StateUpdaterLike](interfaces/stateupdaterlike.md)‹T›› |
`persistentStore` | [AsyncIteratorLike](interfaces/asynciteratorlike.md)‹T, T› |
`initialState` | T |

@@ -80,2 +81,35 @@ `scheduler` | SchedulerLike |

### `Const` createReducerStore
▸ **createReducerStore**<**TAction**, **T**>(`initialState`: T, `reducer`: function, `scheduler`: SchedulerLike, `equals?`: undefined | function): *[AsyncIteratorResourceLike](interfaces/asynciteratorresourcelike.md)‹TAction, T›*
**Type parameters:**
▪ **TAction**
▪ **T**
**Parameters:**
▪ **initialState**: *T*
▪ **reducer**: *function*
▸ (`state`: T, `action`: TAction): *T*
**Parameters:**
Name | Type |
------ | ------ |
`state` | T |
`action` | TAction |
▪ **scheduler**: *SchedulerLike*
▪`Optional` **equals**: *undefined | function*
**Returns:** *[AsyncIteratorResourceLike](interfaces/asynciteratorresourcelike.md)‹TAction, T›*
___
### `Const` createStateStore

@@ -82,0 +116,0 @@

{
"name": "@reactive-js/ix",
"version": "0.0.6",
"version": "0.0.7",
"main": "dist/cjs/index.js",

@@ -41,6 +41,7 @@ "module": "dist/esm5/index.js",

"dependencies": {
"@reactive-js/disposable": "^0.0.6",
"@reactive-js/observable": "^0.0.6",
"@reactive-js/rx": "^0.0.6",
"@reactive-js/scheduler": "^0.0.6"
"@reactive-js/disposable": "^0.0.7",
"@reactive-js/observable": "^0.0.7",
"@reactive-js/pipe": "^0.0.7",
"@reactive-js/rx": "^0.0.7",
"@reactive-js/scheduler": "^0.0.7"
},

@@ -57,3 +58,3 @@ "scripts": {

},
"gitHead": "de556526ea932ae090f61f71eae15604770ef0a9"
"gitHead": "6a380ab10970ac5ef46b6e8599e7ca0f7051c158"
}

@@ -15,3 +15,2 @@ import {

onNext,
pipe,
scan,

@@ -23,2 +22,4 @@ share,

import { pipe } from "@reactive-js/pipe";
import { SchedulerLike } from "@reactive-js/scheduler";

@@ -113,11 +114,12 @@

export const createStateStore = <T>(
export const createReducerStore = <TAction, T>(
initialState: T,
reducer: (state: T, action: TAction) => T,
scheduler: SchedulerLike,
equals?: (a: T, b: T) => boolean,
): StateStoreResourceLike<T> => {
const operator: ObservableOperatorLike<StateUpdaterLike<T>, T> = obs =>
): AsyncIteratorResourceLike<TAction, T> => {
const operator: ObservableOperatorLike<TAction, T> = obs =>
pipe(
obs,
scan((acc: T, next: StateUpdaterLike<T>) => next(acc), initialState),
scan(reducer, () => initialState),
startWith(initialState),

@@ -128,8 +130,17 @@ distinctUntilChanged(equals),

const store = createAsyncIteratorResource(operator);
store.add(connect(store, scheduler));
pipe(store, connect(scheduler), d => store.add(d));
return store;
};
const stateStoreReducer = <T>(state: T, action: StateUpdaterLike<T>) =>
action(state);
export const createStateStore = <T>(
initialState: T,
scheduler: SchedulerLike,
equals?: (a: T, b: T) => boolean,
): StateStoreResourceLike<T> =>
createReducerStore(initialState, stateStoreReducer, scheduler, equals);
export const createPersistentStateStore = <T>(
persistentStore: AsyncIteratorLike<T, StateUpdaterLike<T>>,
persistentStore: AsyncIteratorLike<T, T>,
initialState: T,

@@ -144,3 +155,3 @@ scheduler: SchedulerLike,

persistentStore,
onNext(dispatch),
onNext(v => dispatch(_ => v)),
ignoreElements(),

@@ -151,3 +162,6 @@ );

obs,
scan((acc: T, next: StateUpdaterLike<T>) => next(acc), initialState),
scan(
(acc: T, next: StateUpdaterLike<T>) => next(acc),
() => initialState,
),
distinctUntilChanged(equals),

@@ -154,0 +168,0 @@ onNext(next => persistentStore.dispatch(next)),

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

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