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

spica

Package Overview
Dependencies
Maintainers
1
Versions
804
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spica - npm Package Compare versions

Comparing version 0.0.742 to 0.0.743

6

cancellation.ts
import { AtomicPromise, Internal, internal } from './promise';
import { Maybe, Just, Nothing } from './maybe';
import { Either, Left, Right } from './either';
import { Maybe, Just, Nothing } from './monad/maybe';
import { Either, Left, Right } from './monad/either';
import { noop } from './function';

@@ -104,3 +104,3 @@ import { causeAsyncException } from './exception';

return value =>
Right<L, typeof value>(value)
Right(value)
.bind(value =>

@@ -107,0 +107,0 @@ this.isCancelled()

@@ -11,7 +11,7 @@ import { AtomicPromise } from './promise';

ap<b, c, d, e, f, z>(this: Either<a, (b: b, c: c, d: d, e: e, f: f) => z>, b: Either<a, b>): Either<a, (c: c, d: d, e: e, f: f) => z>;
bind<c>(f: (b: b) => Either<a, c>): Either<a, c>;
bind<c>(f: (b: b) => Either<a, c> | Left<a> | Right<c>): Either<a, c>;
join<c>(this: Either<a, Either<a, c>>): Either<a, c>;
extract(): b;
extract<c>(left: (a: a) => c): b | c;
extract<c>(left: (a: a) => c, right: (b: b) => c): c;
extract<c, d>(left: (a: a) => c, right: (b: b) => d): c | d;
}

@@ -35,5 +35,6 @@

}
public bind<c, a = never>(f: (b: b) => Left<a>): Left<a>;
public bind<c, a = never>(f: (b: b) => Right<c>): Right<c>;
public bind<c, a>(f: (b: b) => Either<a, c>): Either<a, c>;
public bind<c, a>(f: (b: b) => Either<a, c>): Either<a, c> {
public bind<c, a>(f: (b: b) => Either<a, c> | Left<a> | Right<c>): Either<a, c>;
public bind<c, a>(f: (b: b) => Either<a, c> | Left<a> | Right<c>): Either<a, c> {
return f(this.extract());

@@ -45,4 +46,4 @@ }

public extract(): b;
public extract<c>(transform: (a: never) => c): b;
public extract<c>(left: (a: never) => c, right: (b: b) => c): c;
public extract<c>(left: (a: any) => c): b | c;
public extract<c, d>(left: (a: any) => c, right: (b: b) => d): c | d;
public extract<c>(left?: (a: never) => c, right?: (b: b) => c): b | c {

@@ -72,3 +73,3 @@ if (right !== undefined) return right(this.value);

}
public bind<b>(f: (b: never) => Either<a, b>): Left<a> {
public bind<c, _ = a>(f: (b: never) => Either<a, c> | Left<a> | Right<c>): Left<a> {
return this;

@@ -81,4 +82,4 @@ assert(f);

public extract(): never;
public extract<c>(transform: (a: a) => c): c;
public extract<c>(left: (a: a) => c, right: (b: never) => c): c;
public extract<c>(left: (a: a) => c): c;
public extract<c, d>(left: (a: a) => c, right: (b: any) => d): c | d;
public extract<c>(left?: (a: a) => c): c {

@@ -123,4 +124,4 @@ if (left !== undefined) return left(this.value);

export const Return = pure;
export function bind<a, b, c>(m: Either<a, b>, f: (b: b) => Either<a, c>): Either<a, c>;
export function bind<a, b>(m: Either<a, b>): <c>(f: (b: b) => Either<a, c>) => Either<a, c>;
export function bind<a, b, c>(m: Either<a, b>, f: (b: b) => Either<a, c> | Left<a> | Right<c>): Either<a, c>;
export function bind<a, b>(m: Either<a, b>): <c>(f: (b: b) => Either<a, c> | Left<a> | Right<c>) => Either<a, c>;
export function bind<a, b, c>(m: Either<a, b>, f?: (b: b) => Either<a, c>): Either<a, c> | (<c>(f: (b: b) => Either<a, c>) => Either<a, c>) {

@@ -136,8 +137,8 @@ return f

? fm.reduce((acc, m) =>
acc.bind(as =>
m.fmap(a =>
[...as, a]))
, Return([]))
acc.bind(as =>
m.fmap(a =>
[...as, a]))
, Return([]))
: fm.extract(b => AtomicPromise.resolve(new Left(b)), a => AtomicPromise.resolve(a).then<Either<a, b>>(Return));
}
}

@@ -15,3 +15,2 @@ import { AtomicPromise } from './promise';

extract(): a;
extract(nothing: () => a): a;
extract<b>(nothing: () => b): a | b;

@@ -38,2 +37,3 @@ extract<b>(nothing: () => b, just: (a: a) => b): b;

public bind<b>(f: (a: a) => Just<b>): Just<b>;
public bind<b>(f: (a: a) => Nothing): Nothing;
public bind<b>(f: (a: a) => Maybe<b>): Maybe<b>;

@@ -52,3 +52,2 @@ public bind<b>(f: (a: a) => Maybe<b>): Maybe<b> {

public extract(): a;
public extract(nothing: () => a): a;
public extract<b>(nothing: () => b): a | b;

@@ -88,3 +87,3 @@ public extract<b>(nothing: () => b, just: (a: a) => b): b;

public extract(): never;
public extract<b>(transform: () => b): b;
public extract<b>(nothing: () => b): b;
public extract<b>(nothing: () => b, just: (a: never) => b): b;

@@ -143,3 +142,3 @@ public extract<b>(nothing?: () => b): b {

, Return([]))
: fm.extract(() => AtomicPromise.resolve(Maybe.mzero), a => AtomicPromise.resolve(a).then(Return))
: fm.extract(() => AtomicPromise.resolve(Maybe.mzero), a => AtomicPromise.resolve(a).then(Return));
}

@@ -146,0 +145,0 @@ export const mzero: Maybe<never> = nothing;

@@ -20,3 +20,3 @@ import { Monad } from './monad';

}
public bind<c>(f: (b: b) => Either<a, c>): Either<a, c> {
public bind<c>(f: (b: b) => Either<a, c> | Left<a> | Right<c>): Either<a, c> {
return new Either<a, c>(() => {

@@ -68,4 +68,4 @@ const m: Either<a, b> = this.evaluate();

export const Return = pure;
export declare function bind<a, b, c>(m: Either<a, b>, f: (b: b) => Either<a, c>): Either<a, c>;
export declare function bind<a, b>(m: Either<a, b>): <c>(f: (b: b) => Either<a, c>) => Either<a, c>;
export declare function bind<a, b, c>(m: Either<a, b>, f: (b: b) => Either<a, c> | Left<a> | Right<c>): Either<a, c>;
export declare function bind<a, b>(m: Either<a, b>): <c>(f: (b: b) => Either<a, c> | Left<a> | Right<c>) => Either<a, c>;
export function sequence<a, b>(fm: Either<a, b>[]): Either<a, b[]>;

@@ -88,3 +88,3 @@ export function sequence<a, b>(fm: Either<a, PromiseLike<b>>): AtomicPromise<Either<a, b>>;

}
public override bind<b>(f: (b: never) => Either<a, b>): Left<a> {
public override bind<c>(f: (b: never) => Either<a, c> | Left<a> | Right<c>): Left<a> {
return this;

@@ -107,3 +107,4 @@ assert(f);

public override bind<c, a = never>(f: (b: b) => Right<c>): Right<c>;
public override bind<c, a>(f: (b: b) => Either<a, c>): Either<a, c>;
public override bind<c, a = never>(f: (b: b) => Left<a>): Left<a>;
public override bind<c, a>(f: (b: b) => Either<a, c> | Left<a> | Right<c>): Either<a, c>;
public override bind<c, a>(f: (b: b) => Either<a, c>): Either<a, c> {

@@ -110,0 +111,0 @@ return new Either(() => f(this.extract()));

@@ -88,2 +88,3 @@ import { MonadPlus } from './monadplus';

public override bind<b>(f: (a: a) => Just<b>): Just<b>;
public override bind<b>(f: (a: a) => Nothing): Nothing;
public override bind<b>(f: (a: a) => Maybe<b>): Maybe<b>;

@@ -94,3 +95,3 @@ public override bind<b>(f: (a: a) => Maybe<b>): Maybe<b> {

public override extract(): a;
public override extract<b>(transform: () => b): a;
public override extract<b>(nothing: () => b): a;
public override extract<b>(nothing: () => b, just: (a: a) => b): b;

@@ -113,3 +114,3 @@ public override extract<b>(nothing?: () => b, just?: (a: a) => b): a | b {

public override extract(): never;
public override extract<b>(transform: () => b): b;
public override extract<b>(nothing: () => b): b;
public override extract<b>(nothing: () => b, just: (a: never) => b): b;

@@ -116,0 +117,0 @@ public override extract<b>(nothing?: () => b): b {

{
"name": "spica",
"version": "0.0.742",
"version": "0.0.743",
"description": "Supervisor, Coroutine, Channel, select, AtomicPromise, Cancellation, Cache, List, Queue, Stack, and some utils.",

@@ -5,0 +5,0 @@ "private": false,

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