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

@thi.ng/compose

Package Overview
Dependencies
Maintainers
1
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/compose - npm Package Compare versions

Comparing version 2.1.71 to 3.0.0

19

CHANGELOG.md
# Change Log
- **Last updated**: 2024-03-27T09:53:45Z
- **Last updated**: 2024-04-08T14:59:29Z
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)

@@ -12,2 +12,19 @@

# [3.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/compose@3.0.0) (2024-04-08)
#### 🛑 Breaking changes
- remove/migrate delay() to different pkg ([745abbb](https://github.com/thi-ng/umbrella/commit/745abbb))
- BREAKING CHANGE: migrate delay() & Delay class to [@thi.ng/memoize](https://github.com/thi-ng/umbrella/tree/main/packages/memoize)
- see [d8f4733c05e724c38195f209337d0a015e049ac4](https://github.com/thi-ng/umbrella/commit/d8f4733c05e724c38195f209337d0a015e049ac4) for details
#### 🚀 Features
- add async composition helpers ([168ea42](https://github.com/thi-ng/umbrella/commit/168ea42))
- add async functions:
- compAsync()
- juxtAsync()
- threadFirstAsync()/threadLastAsync()
- trampolineAsync()
### [2.1.35](https://github.com/thi-ng/umbrella/tree/@thi.ng/compose@2.1.35) (2023-08-04)

@@ -14,0 +31,0 @@

42

comp.d.ts

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

import type { Fn, FnAny } from "@thi.ng/api";
import type { Fn, FnA, FnAny, FnAnyA } from "@thi.ng/api";
/**

@@ -23,17 +23,31 @@ * Returns the right-to-left composition of given functions. I.e. when

*/
export declare function compL<A>(a: FnAny<A>): FnAny<A>;
export declare function compL<A, B>(a: FnAny<A>, b: Fn<A, B>): FnAny<B>;
export declare function compL<A, B, C>(a: FnAny<A>, b: Fn<A, B>, c: Fn<B, C>): FnAny<C>;
export declare function compL<A, B, C, D>(a: FnAny<A>, b: Fn<A, B>, c: Fn<B, C>, d: Fn<C, D>): FnAny<D>;
export declare function compL<A, B, C, D, E>(a: FnAny<A>, b: Fn<A, B>, c: Fn<B, C>, d: Fn<C, D>, e: Fn<D, E>): FnAny<E>;
export declare function compL<A, B, C, D, E, F>(a: FnAny<A>, b: Fn<A, B>, c: Fn<B, C>, d: Fn<C, D>, e: Fn<D, E>, f: Fn<E, F>): FnAny<F>;
export declare function compL<A, B, C, D, E, F, G>(a: FnAny<A>, b: Fn<A, B>, c: Fn<B, C>, d: Fn<C, D>, e: Fn<D, E>, f: Fn<E, F>, g: Fn<F, G>): FnAny<G>;
export declare function compL<A, B, C, D, E, F, G, H>(a: FnAny<A>, b: Fn<A, B>, c: Fn<B, C>, d: Fn<C, D>, e: Fn<D, E>, f: Fn<E, F>, g: Fn<F, G>, h: Fn<G, H>): FnAny<H>;
export declare function compL<A, B, C, D, E, F, G, H, I>(a: FnAny<A>, b: Fn<A, B>, c: Fn<B, C>, d: Fn<C, D>, e: Fn<D, E>, f: Fn<E, F>, g: Fn<F, G>, h: Fn<G, H>, i: Fn<H, I>): FnAny<I>;
export declare function compL<A, B, C, D, E, F, G, H, I, J>(a: FnAny<A>, b: Fn<A, B>, c: Fn<B, C>, d: Fn<C, D>, e: Fn<D, E>, f: Fn<E, F>, g: Fn<F, G>, h: Fn<G, H>, i: Fn<H, I>, j: Fn<I, J>): FnAny<J>;
export declare function compL<A, B, C, D, E, F, G, H, I, J>(a: FnAny<A>, b: Fn<A, B>, c: Fn<B, C>, d: Fn<C, D>, e: Fn<D, E>, f: Fn<E, F>, g: Fn<F, G>, h: Fn<G, H>, i: Fn<H, I>, j: Fn<I, J>, ...xs: Fn<any, any>[]): FnAny<any>;
export declare function compLeft<A>(a: FnAny<A>): FnAny<A>;
export declare function compLeft<A, B>(a: FnAny<A>, b: Fn<A, B>): FnAny<B>;
export declare function compLeft<A, B, C>(a: FnAny<A>, b: Fn<A, B>, c: Fn<B, C>): FnAny<C>;
export declare function compLeft<A, B, C, D>(a: FnAny<A>, b: Fn<A, B>, c: Fn<B, C>, d: Fn<C, D>): FnAny<D>;
export declare function compLeft<A, B, C, D, E>(a: FnAny<A>, b: Fn<A, B>, c: Fn<B, C>, d: Fn<C, D>, e: Fn<D, E>): FnAny<E>;
export declare function compLeft<A, B, C, D, E, F>(a: FnAny<A>, b: Fn<A, B>, c: Fn<B, C>, d: Fn<C, D>, e: Fn<D, E>, f: Fn<E, F>): FnAny<F>;
export declare function compLeft<A, B, C, D, E, F, G>(a: FnAny<A>, b: Fn<A, B>, c: Fn<B, C>, d: Fn<C, D>, e: Fn<D, E>, f: Fn<E, F>, g: Fn<F, G>): FnAny<G>;
export declare function compLeft<A, B, C, D, E, F, G, H>(a: FnAny<A>, b: Fn<A, B>, c: Fn<B, C>, d: Fn<C, D>, e: Fn<D, E>, f: Fn<E, F>, g: Fn<F, G>, h: Fn<G, H>): FnAny<H>;
export declare function compLeft<A, B, C, D, E, F, G, H, I>(a: FnAny<A>, b: Fn<A, B>, c: Fn<B, C>, d: Fn<C, D>, e: Fn<D, E>, f: Fn<E, F>, g: Fn<F, G>, h: Fn<G, H>, i: Fn<H, I>): FnAny<I>;
export declare function compLeft<A, B, C, D, E, F, G, H, I, J>(a: FnAny<A>, b: Fn<A, B>, c: Fn<B, C>, d: Fn<C, D>, e: Fn<D, E>, f: Fn<E, F>, g: Fn<F, G>, h: Fn<G, H>, i: Fn<H, I>, j: Fn<I, J>): FnAny<J>;
export declare function compLeft<A, B, C, D, E, F, G, H, I, J>(a: FnAny<A>, b: Fn<A, B>, c: Fn<B, C>, d: Fn<C, D>, e: Fn<D, E>, f: Fn<E, F>, g: Fn<F, G>, h: Fn<G, H>, i: Fn<H, I>, j: Fn<I, J>, ...xs: Fn<any, any>[]): FnAny<any>;
/**
* @deprecated renamed to {@link compL}
* @deprecated renamed to {@link compLeft}.
*/
export declare const compI: typeof compL;
export declare const compL: typeof compLeft;
/**
* Async version of {@link comp}.
*/
export declare function compAsync<A, B>(a: FnAnyA<A>): FnAnyA<A>;
export declare function compAsync<A, B>(a: FnA<B, A>, b: FnAnyA<B>): FnAnyA<A>;
export declare function compAsync<A, B, C>(a: FnA<B, A>, b: FnA<C, B>, c: FnAnyA<C>): FnAnyA<A>;
export declare function compAsync<A, B, C, D>(a: FnA<B, A>, b: FnA<C, B>, c: FnA<D, C>, d: FnAnyA<D>): FnAnyA<A>;
export declare function compAsync<A, B, C, D, E>(a: FnA<B, A>, b: FnA<C, B>, c: FnA<D, C>, d: FnA<E, D>, e: FnAnyA<D>): FnAnyA<A>;
export declare function compAsync<A, B, C, D, E, F>(a: FnA<B, A>, b: FnA<C, B>, c: FnA<D, C>, d: FnA<E, D>, e: FnA<F, E>, f: FnAnyA<F>): FnAnyA<A>;
export declare function compAsync<A, B, C, D, E, F, G>(a: FnA<B, A>, b: FnA<C, B>, c: FnA<D, C>, d: FnA<E, D>, e: FnA<F, E>, f: FnA<G, F>, g: FnAnyA<G>): FnAnyA<A>;
export declare function compAsync<A, B, C, D, E, F, G, H>(a: FnA<B, A>, b: FnA<C, B>, c: FnA<D, C>, d: FnA<E, D>, e: FnA<F, E>, f: FnA<G, F>, g: FnA<H, G>, h: FnAnyA<H>): FnAnyA<A>;
export declare function compAsync<A, B, C, D, E, F, G, H, I>(a: FnA<B, A>, b: FnA<C, B>, c: FnA<D, C>, d: FnA<E, D>, e: FnA<F, E>, f: FnA<G, F>, g: FnA<H, G>, h: FnA<I, H>, i: FnAnyA<I>): FnAnyA<A>;
export declare function compAsync<A, B, C, D, E, F, G, H, I, J>(a: FnA<B, A>, b: FnA<C, B>, c: FnA<D, C>, d: FnA<E, D>, e: FnA<F, E>, f: FnA<G, F>, g: FnA<H, G>, h: FnA<I, H>, i: FnA<J, I>, j: FnAnyA<J>): FnAnyA<A>;
export declare function compAsync<A, B, C, D, E, F, G, H, I, J>(a: FnA<B, A>, b: FnA<C, B>, c: FnA<D, C>, d: FnA<E, D>, e: FnA<F, E>, f: FnA<G, F>, g: FnA<H, G>, h: FnA<I, H>, i: FnA<J, I>, j: FnA<any, J>, ...fns: FnAnyA<any>[]): FnAnyA<A>;
//# sourceMappingURL=comp.d.ts.map

@@ -31,10 +31,21 @@ import { illegalArity } from "@thi.ng/errors/illegal-arity";

}
function compL(...fns) {
function compLeft(...fns) {
return comp.apply(null, fns.reverse());
}
const compI = compL;
const compL = compLeft;
function compAsync(...fns) {
return async (...xs) => {
let n = fns.length - 1;
let res = fns[n](...xs);
while (n-- > 0) {
res = await fns[n](res);
}
return res;
};
}
export {
comp,
compI,
compL
compAsync,
compL,
compLeft
};
export * from "./comp.js";
export * from "./complement.js";
export * from "./constantly.js";
export * from "./delay.js";
export * from "./delayed.js";

@@ -6,0 +5,0 @@ export * from "./identity.js";

export * from "./comp.js";
export * from "./complement.js";
export * from "./constantly.js";
export * from "./delay.js";
export * from "./delayed.js";

@@ -6,0 +5,0 @@ export * from "./identity.js";

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

import type { Fn } from "@thi.ng/api";
import type { Fn, FnA } from "@thi.ng/api";
export declare function juxt<T, A>(a: Fn<T, A>): Fn<T, [A]>;

@@ -11,2 +11,18 @@ export declare function juxt<T, A, B>(a: Fn<T, A>, b: Fn<T, B>): Fn<T, [A, B]>;

export declare function juxt<T, A, B, C, D, E, F, G, H>(a: Fn<T, A>, b: Fn<T, B>, c: Fn<T, C>, d: Fn<T, D>, e: Fn<T, E>, f: Fn<T, F>, g: Fn<T, G>, h: Fn<T, H>, ...xs: Fn<T, any>[]): Fn<T, any[]>;
/**
* Async version of {@link juxt}. Returns an async function which takes a single
* arg `x`, calls all given functions with `x` and then waits for all results
* before returning them as tuple.
*
* @param a
*/
export declare function juxtAsync<T, A>(a: FnA<T, A>): FnA<T, [A]>;
export declare function juxtAsync<T, A, B>(a: FnA<T, A>, b: FnA<T, B>): FnA<T, [A, B]>;
export declare function juxtAsync<T, A, B, C>(a: FnA<T, A>, b: FnA<T, B>, c: FnA<T, C>): FnA<T, [A, B, C]>;
export declare function juxtAsync<T, A, B, C, D>(a: FnA<T, A>, b: FnA<T, B>, c: FnA<T, C>, d: FnA<T, D>): FnA<T, [A, B, C, D]>;
export declare function juxtAsync<T, A, B, C, D, E>(a: FnA<T, A>, b: FnA<T, B>, c: FnA<T, C>, d: FnA<T, D>, e: FnA<T, E>): FnA<T, [A, B, C, D, E]>;
export declare function juxtAsync<T, A, B, C, D, E, F>(a: FnA<T, A>, b: FnA<T, B>, c: FnA<T, C>, d: FnA<T, D>, e: FnA<T, E>, f: FnA<T, F>): FnA<T, [A, B, C, D, E, F]>;
export declare function juxtAsync<T, A, B, C, D, E, F, G>(a: FnA<T, A>, b: FnA<T, B>, c: FnA<T, C>, d: FnA<T, D>, e: FnA<T, E>, f: FnA<T, F>, g: FnA<T, G>): FnA<T, [A, B, C, D, E, F, G]>;
export declare function juxtAsync<T, A, B, C, D, E, F, G, H>(a: FnA<T, A>, b: FnA<T, B>, c: FnA<T, C>, d: FnA<T, D>, e: FnA<T, E>, f: FnA<T, F>, g: FnA<T, G>, h: FnA<T, H>): FnA<T, [A, B, C, D, E, F, G, H]>;
export declare function juxtAsync<T, A, B, C, D, E, F, G, H>(a: FnA<T, A>, b: FnA<T, B>, c: FnA<T, C>, d: FnA<T, D>, e: FnA<T, E>, f: FnA<T, F>, g: FnA<T, G>, h: FnA<T, H>, ...xs: FnA<T, any>[]): FnA<T, any[]>;
//# sourceMappingURL=juxt.d.ts.map

@@ -30,4 +30,8 @@ function juxt(...fns) {

}
function juxtAsync(...fns) {
return async (x) => await Promise.all(fns.map((f) => f(x)));
}
export {
juxt
juxt,
juxtAsync
};
{
"name": "@thi.ng/compose",
"version": "2.1.71",
"version": "3.0.0",
"description": "Optimized functional composition helpers",

@@ -39,4 +39,4 @@ "type": "module",

"dependencies": {
"@thi.ng/api": "^8.9.31",
"@thi.ng/errors": "^2.5.2"
"@thi.ng/api": "^8.10.0",
"@thi.ng/errors": "^2.5.3"
},

@@ -79,5 +79,2 @@ "devDependencies": {

},
"./delay": {
"default": "./delay.js"
},
"./delayed": {

@@ -111,3 +108,6 @@ "default": "./delayed.js"

},
"gitHead": "feb3b24654f2c931cd3c3308c1c0c807ee14d0e4\n"
"thi.ng": {
"alias": "comp"
},
"gitHead": "85ac4bd4d6d89f8e3689e2863d5bea0cecdb371c\n"
}

@@ -10,3 +10,3 @@ <!-- This file is generated - DO NOT EDIT! -->

> [!NOTE]
> This is one of 190 standalone projects, maintained as part
> This is one of 191 standalone projects, maintained as part
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo

@@ -19,2 +19,4 @@ > and anti-framework.

- [About](#about)
- [Composition helpers](#composition-helpers)
- [Async functions](#async-functions)
- [Status](#status)

@@ -32,2 +34,24 @@ - [Installation](#installation)

## Composition helpers
- [comp()](https://docs.thi.ng/umbrella/compose/functions/comp.html)
- [compLeft()](https://docs.thi.ng/umbrella/compose/functions/compLeft.html)
- [complement()](https://docs.thi.ng/umbrella/compose/functions/complement.html)
- [constantly()](https://docs.thi.ng/umbrella/compose/functions/constantly.html)
- [juxt()](https://docs.thi.ng/umbrella/compose/functions/juxt.html)
- [partial()](https://docs.thi.ng/umbrella/compose/functions/partial.html)
- [threadFirst()](https://docs.thi.ng/umbrella/compose/functions/threadFirst.html)
- [threadLast()](https://docs.thi.ng/umbrella/compose/functions/threadLast.html)
- [trampoline()](https://docs.thi.ng/umbrella/compose/functions/trampoline.html)
### Async functions
- [compAsync()](https://docs.thi.ng/umbrella/compose/functions/compAsync.html)
- [delayed()](https://docs.thi.ng/umbrella/compose/functions/delayed.html)
- [juxtAsync()](https://docs.thi.ng/umbrella/compose/functions/juxtAsync.html)
- [promisify()](https://docs.thi.ng/umbrella/compose/functions/promisify.html)
- [threadFirstAsync()](https://docs.thi.ng/umbrella/compose/functions/threadFirstAsync.html)
- [threadLastAsync()](https://docs.thi.ng/umbrella/compose/functions/threadLastAsync.html)
- [trampolineAsync()](https://docs.thi.ng/umbrella/compose/functions/trampolineAsync.html)
## Status

@@ -45,4 +69,10 @@

ES module import:
ESM import:
```ts
import * as comp from "@thi.ng/compose";
```
Browser ESM import:
```html

@@ -57,6 +87,6 @@ <script type="module" src="https://cdn.skypack.dev/@thi.ng/compose"></script>

```js
const compose = await import("@thi.ng/compose");
const comp = await import("@thi.ng/compose");
```
Package sizes (brotli'd, pre-treeshake): ESM: 858 bytes
Package sizes (brotli'd, pre-treeshake): ESM: 815 bytes

@@ -83,10 +113,2 @@ ## Dependencies

- [comp()](https://github.com/thi-ng/umbrella/tree/develop/packages/compose/src/comp.ts)
- [compL()](https://github.com/thi-ng/umbrella/tree/develop/packages/compose/src/comp.ts#L52)
- [juxt()](https://github.com/thi-ng/umbrella/tree/develop/packages/compose/src/juxt.ts)
- [partial()](https://github.com/thi-ng/umbrella/tree/develop/packages/compose/src/partial.ts)
- [threadFirst()](https://github.com/thi-ng/umbrella/tree/develop/packages/compose/src/thread-first.ts)
- [threadLast()](https://github.com/thi-ng/umbrella/tree/develop/packages/compose/src/thread-last.ts)
- [trampoline()](https://github.com/thi-ng/umbrella/tree/develop/packages/compose/src/trampoline.ts)
## Authors

@@ -93,0 +115,0 @@

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

import type { FnAny } from "@thi.ng/api";
import type { FnAny, FnAnyA, MaybePromise } from "@thi.ng/api";
/**

@@ -41,2 +41,12 @@ * Similar to {@link threadLast}. A dataflow operator to improve the legibility

export declare const threadFirst: (init: any, ...fns: (FnAny<any> | [FnAny<any>, ...any[]])[]) => any;
/**
* Async version of {@link threadFirst}.
*
* @remarks
* Also see {@link threadLastAsync}.
*
* @param init
* @param fns
*/
export declare const threadFirstAsync: (init: MaybePromise<any>, ...fns: (FnAnyA<any> | [FnAnyA<any>, ...any[]])[]) => Promise<any>;
//# sourceMappingURL=thread-first.d.ts.map

@@ -5,4 +5,12 @@ const threadFirst = (init, ...fns) => fns.reduce(

);
const threadFirstAsync = async (init, ...fns) => {
let res = await init;
for (let expr of fns) {
res = await (typeof expr === "function" ? expr(res) : expr[0](res, ...expr.slice(1)));
}
return res;
};
export {
threadFirst
threadFirst,
threadFirstAsync
};

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

import type { FnAny } from "@thi.ng/api";
import type { FnAny, FnAnyA, MaybePromise } from "@thi.ng/api";
/**

@@ -41,2 +41,12 @@ * Similar to {@link threadFirst}. A dataflow operator to improve the legibility

export declare const threadLast: (init: any, ...fns: (FnAny<any> | [FnAny<any>, ...any[]])[]) => any;
/**
* Async version of {@link threadLast}.
*
* @remarks
* Also see {@link threadFirstAsync}.
*
* @param init
* @param fns
*/
export declare const threadLastAsync: (init: MaybePromise<any>, ...fns: (FnAnyA<any> | [FnAnyA<any>, ...any[]])[]) => Promise<any>;
//# sourceMappingURL=thread-last.d.ts.map

@@ -5,4 +5,12 @@ const threadLast = (init, ...fns) => fns.reduce(

);
const threadLastAsync = async (init, ...fns) => {
let res = await init;
for (let expr of fns) {
res = await (typeof expr === "function" ? expr(res) : expr[0](...expr.slice(1), res));
}
return res;
};
export {
threadLast
threadLast,
threadLastAsync
};

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

import type { Fn0 } from "@thi.ng/api";
import type { Fn0, Fn0A, MaybePromise } from "@thi.ng/api";
/**

@@ -35,2 +35,8 @@ * Takes a function returning either a no-arg function (thunk) or its

export declare const trampoline: <T>(f: T | Fn0<T | Fn0<T>>) => T;
/**
* Async version of {@link trampoline}.
*
* @param f - function
*/
export declare const trampolineAsync: <T>(f: MaybePromise<T | Fn0A<T | Fn0A<T>>>) => Promise<T>;
//# sourceMappingURL=trampoline.d.ts.map

@@ -7,4 +7,12 @@ const trampoline = (f) => {

};
const trampolineAsync = async (f) => {
f = await f;
while (typeof f === "function") {
f = await f();
}
return f;
};
export {
trampoline
trampoline,
trampolineAsync
};
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