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

conclure

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

conclure - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

5

conclude.d.ts

@@ -37,3 +37,6 @@ type Continuation<TResult> = (error: unknown | null, result?: TResult) => void

export function isPromise(obj: any): obj is Promise<unknown>;
export function isEffect(effect: any): effect is Effect<unknown, EffectType>;
export function isFlow(flow: any): flow is Flow<unknown>;
export function inProgress<TResult>(it: Flow<TResult>): boolean;

@@ -49,4 +52,2 @@ export function finished<TResult>(it: Flow<TResult>): boolean;

declare module 'conclure/effects' {
export function isEffect(effect: any): effect is Effect<unknown, EffectType>;
export function cps<TResult>(fn: CallableTarget<CPSFunction<TResult>>, ...args: unknown[]): Effect<TResult, 'CPS'>

@@ -53,0 +54,0 @@ export function cps_no_cancel<TResult>(fn: CallableTarget<CPSFunctionNoCancel<TResult>>, ...args: unknown[]): Effect<TResult, 'CPS_NO_CANCEL'>

2

package.json
{
"name": "conclure",
"version": "1.0.1",
"version": "1.1.0",
"description": "Generator runner",

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

# ⤕ Conclure JS
Brings cancellation and testability to your async flows.
It is a tiny (core is < 200 LOC), zero dependencies generator runner.
It is a tiny (core is < 200 lines of code), zero dependencies generator runner.

@@ -60,3 +60,3 @@ Just grep and replace:

The return value of the generator function - an iterator - becomes the flow's *parent*.
The return value of the generator function yielding the flow - an iterator - becomes the flow's *parent*.

@@ -73,4 +73,8 @@ A flow may have multiple parents - different generators yielding the same flow. Conclure ensures that in this case the flow only runs once, but the results are delivered to all parents once concluded.

You can also attach *weak* watchers to a flow using `whenFinished(flow, callback)`. The callback will be called with `{ cancelled, error, result }` when the flow has finished. Check out some examples in the Recipes section below.
You can also attach *weak* watchers to a flow using `whenFinished(flow, callback)`. The callback will be called with `{ cancelled, error, result }` when the flow has finished.
In case the flow concludes with a result or an error, the weak watchers are called *before* the result is delivered to the flow's parents, so the callback passed to `whenFinished` is roughly equivalent to the `finally` block of a redux-saga generator. However, it can be attached to promises and effects as well, and enables perfectly valid edge cases, when a flow is cancelled synchronously while the generator is running.
Check out some examples in the Recipes section below.
### Effects

@@ -150,5 +154,5 @@ ```js

whenFinished(it, ({ cancelled, error, result }) => {
if (cancelled || error || !expiry) cache.delete(key));
if (cancelled || error || !expiry) cache.delete(key);
else setTimeout(() => cache.delete(key), expiry);
})
});

@@ -155,0 +159,0 @@ return it;

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

import { isEffect, TYPE } from './effects';
import { TYPE } from './effects';

@@ -11,4 +11,6 @@ export function isIterator(obj) {

const isFlow = it => [isPromise, isEffect, isIterator].find(is => is(it));
export const isEffect = effect => Boolean(effect && effect[TYPE]);
export const isFlow = it => [isPromise, isEffect, isIterator].find(is => is(it));
const runners = new Map([

@@ -15,0 +17,0 @@ [isPromise, runPromise],

export const TYPE = '@@conclude-effect';
export const isEffect = effect => Boolean(effect && effect[TYPE]);

@@ -4,0 +3,0 @@ const makeEffect = (type, fn, ...args) => {

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