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

tinysaga

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tinysaga - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

10

esm/effects.d.ts

@@ -39,2 +39,12 @@ import { IAction, IActionType, IEmitter } from "./types";

/**
* Returns a promise whose resolved value will be the next action of the given type
* emitted on the emitter. If the `maxWait` parameter is specified, then at most
* `maxWait` milliseconds will be waited before returning the default value `null`.
*
* @param emitter emitter to hook into
* @param type the action type to listen on
* @param maxWait the maximum time, in millis, to wait for the given action type
*/
export declare function take<T>(emitter: IEmitter, type: IActionType<T>, filter: (payload: T) => boolean, maxWait: number): Promise<T | null>;
/**
* Equivalent to `emitter.on()`, exported as an Effect for consistency.

@@ -41,0 +51,0 @@ *

23

esm/effects.js

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

const TRUE_PREDICATE = () => true;
/**

@@ -26,11 +27,21 @@ * Equivalent to `emitter.on()`, exported as an Effect for consistency.

}
export function take(emitter, type, maxWait) {
export function take(emitter, type, arg2, // tslint:disable-line:ban-types
arg3) {
const filter = typeof arg2 === "function" ? arg2 : TRUE_PREDICATE;
const maxWait = typeof arg2 === "number" ? arg2 : arg3;
return new Promise((resolve) => {
const unsubscribe = once(emitter, type, (value) => {
if (handle !== 0) {
clearTimeout(handle);
const unsubscribe = emitter.on(type, (value) => {
if (filter(value)) {
if (timeout !== 0) {
clearTimeout(timeout);
}
resolve(value);
}
resolve(value);
});
const handle = maxWait !== undefined ? setTimeout(unsubscribe, maxWait) : 0;
const timeout = maxWait !== undefined
? setTimeout(() => {
unsubscribe();
resolve(null);
}, maxWait)
: 0;
});

@@ -37,0 +48,0 @@ }

import { IAction, IStore } from "./types";
declare function noop(): void;
export declare class Store<S> implements IStore<S> {
state: S;
dispatch: (action: IAction) => void;
private afterFlush;
private chain;

@@ -12,3 +14,3 @@ /**

*/
constructor(state: S, dispatch: (action: IAction) => void);
constructor(state: S, dispatch?: (action: IAction) => void, afterFlush?: typeof noop);
getState(): S;

@@ -20,1 +22,2 @@ setState(nextState: S): void;

}
export {};
import { Chain } from "./utils/Chain";
import { defer } from "./utils/defer";
function noop() {
// noop
}
export class Store {

@@ -10,8 +13,10 @@ /**

*/
constructor(state, dispatch) {
constructor(state, dispatch = noop, afterFlush = noop) {
this.state = state;
this.dispatch = dispatch;
this.afterFlush = afterFlush;
this.chain = new Chain();
this.notifySubscribers = defer(() => {
this.chain.emit(undefined);
this.afterFlush();
});

@@ -18,0 +23,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.put = exports.takeEvery = exports.take = exports.once = exports.on = void 0;
const TRUE_PREDICATE = () => true;
/**

@@ -31,11 +32,21 @@ * Equivalent to `emitter.on()`, exported as an Effect for consistency.

exports.once = once;
function take(emitter, type, maxWait) {
function take(emitter, type, arg2, // tslint:disable-line:ban-types
arg3) {
const filter = typeof arg2 === "function" ? arg2 : TRUE_PREDICATE;
const maxWait = typeof arg2 === "number" ? arg2 : arg3;
return new Promise((resolve) => {
const unsubscribe = once(emitter, type, (value) => {
if (handle !== 0) {
clearTimeout(handle);
const unsubscribe = emitter.on(type, (value) => {
if (filter(value)) {
if (timeout !== 0) {
clearTimeout(timeout);
}
resolve(value);
}
resolve(value);
});
const handle = maxWait !== undefined ? setTimeout(unsubscribe, maxWait) : 0;
const timeout = maxWait !== undefined
? setTimeout(() => {
unsubscribe();
resolve(null);
}, maxWait)
: 0;
});

@@ -42,0 +53,0 @@ }

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

const defer_1 = require("./utils/defer");
function noop() {
// noop
}
class Store {

@@ -14,8 +17,10 @@ /**

*/
constructor(state, dispatch) {
constructor(state, dispatch = noop, afterFlush = noop) {
this.state = state;
this.dispatch = dispatch;
this.afterFlush = afterFlush;
this.chain = new Chain_1.Chain();
this.notifySubscribers = defer_1.defer(() => {
this.chain.emit(undefined);
this.afterFlush();
});

@@ -22,0 +27,0 @@ }

{
"name": "tinysaga",
"version": "1.3.0",
"version": "1.3.1",
"main": "lib/index.js",

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

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