fp-pack 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -7
- package/dist/fp-pack.umd.js +1 -1
- package/dist/fp-pack.umd.js.map +1 -1
- package/dist/implement/async/index.d.ts +1 -0
- package/dist/implement/async/index.d.ts.map +1 -1
- package/dist/implement/async/pipeAsync.d.ts +1 -0
- package/dist/implement/async/pipeAsync.d.ts.map +1 -1
- package/dist/implement/async/pipeAsync.mjs.map +1 -1
- package/dist/implement/async/pipeAsyncSideEffect.d.ts +1 -0
- package/dist/implement/async/pipeAsyncSideEffect.d.ts.map +1 -1
- package/dist/implement/async/pipeAsyncSideEffect.mjs.map +1 -1
- package/dist/implement/async/pipeAsyncSideEffectStrict.d.ts +73 -0
- package/dist/implement/async/pipeAsyncSideEffectStrict.d.ts.map +1 -0
- package/dist/implement/async/pipeAsyncSideEffectStrict.mjs +16 -0
- package/dist/implement/async/pipeAsyncSideEffectStrict.mjs.map +1 -0
- package/dist/implement/composition/from.d.ts +6 -0
- package/dist/implement/composition/from.d.ts.map +1 -0
- package/dist/implement/composition/from.mjs +7 -0
- package/dist/implement/composition/from.mjs.map +1 -0
- package/dist/implement/composition/index.d.ts +2 -0
- package/dist/implement/composition/index.d.ts.map +1 -1
- package/dist/implement/composition/pipe.d.ts +8 -0
- package/dist/implement/composition/pipe.d.ts.map +1 -1
- package/dist/implement/composition/pipe.mjs.map +1 -1
- package/dist/implement/composition/pipe.type-test.d.ts +64 -0
- package/dist/implement/composition/pipe.type-test.d.ts.map +1 -1
- package/dist/implement/composition/pipeSideEffect.d.ts +8 -0
- package/dist/implement/composition/pipeSideEffect.d.ts.map +1 -1
- package/dist/implement/composition/pipeSideEffect.mjs.map +1 -1
- package/dist/implement/composition/pipeSideEffectStrict.d.ts +69 -0
- package/dist/implement/composition/pipeSideEffectStrict.d.ts.map +1 -0
- package/dist/implement/composition/pipeSideEffectStrict.mjs +16 -0
- package/dist/implement/composition/pipeSideEffectStrict.mjs.map +1 -0
- package/dist/implement/control/ifElse.d.ts +4 -3
- package/dist/implement/control/ifElse.d.ts.map +1 -1
- package/dist/implement/control/ifElse.mjs.map +1 -1
- package/dist/implement/control/unless.d.ts +14 -2
- package/dist/implement/control/unless.d.ts.map +1 -1
- package/dist/implement/control/unless.mjs.map +1 -1
- package/dist/implement/control/when.d.ts +14 -2
- package/dist/implement/control/when.d.ts.map +1 -1
- package/dist/implement/control/when.mjs.map +1 -1
- package/dist/implement/object/index.d.ts +1 -0
- package/dist/implement/object/index.d.ts.map +1 -1
- package/dist/implement/object/propStrict.d.ts +7 -0
- package/dist/implement/object/propStrict.d.ts.map +1 -0
- package/dist/implement/object/propStrict.mjs +12 -0
- package/dist/implement/object/propStrict.mjs.map +1 -0
- package/dist/index.mjs +248 -240
- package/dist/index.mjs.map +1 -1
- package/dist/skills/fp-pack/SKILL.md +1699 -0
- package/dist/skills/fp-pack.md +57 -9
- package/package.json +1 -1
- package/src/implement/async/index.ts +1 -0
- package/src/implement/async/pipeAsync.ts +8 -0
- package/src/implement/async/pipeAsyncSideEffect.ts +8 -0
- package/src/implement/async/pipeAsyncSideEffectStrict.test.ts +23 -0
- package/src/implement/async/pipeAsyncSideEffectStrict.ts +170 -0
- package/src/implement/composition/from.test.ts +16 -0
- package/src/implement/composition/from.ts +8 -0
- package/src/implement/composition/index.ts +2 -0
- package/src/implement/composition/pipe.test.ts +8 -0
- package/src/implement/composition/pipe.ts +28 -0
- package/src/implement/composition/pipe.type-test.ts +142 -0
- package/src/implement/composition/pipeSideEffect.test.ts +8 -0
- package/src/implement/composition/pipeSideEffect.ts +33 -0
- package/src/implement/composition/pipeSideEffectStrict.test.ts +23 -0
- package/src/implement/composition/pipeSideEffectStrict.ts +164 -0
- package/src/implement/control/curried.test.ts +18 -0
- package/src/implement/control/ifElse.ts +5 -3
- package/src/implement/control/unless.ts +20 -2
- package/src/implement/control/when.ts +20 -2
- package/src/implement/object/index.ts +1 -0
- package/src/implement/object/propStrict.test.ts +29 -0
- package/src/implement/object/propStrict.ts +20 -0
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<img src="https://github.
|
|
2
|
+
<img src="https://superlucky84.github.io/fp-pack/fp.png" alt="fp-pack" width="200" />
|
|
3
3
|
|
|
4
4
|
# fp-pack
|
|
5
5
|
|
|
@@ -54,7 +54,7 @@ export default curriedChunk;
|
|
|
54
54
|
Built around `pipe` and `pipeAsync` for clean, left-to-right function composition.
|
|
55
55
|
|
|
56
56
|
- ⚡ **SideEffect Pattern**
|
|
57
|
-
Handle errors and side effects declaratively in SideEffect-aware pipelines. Use `pipeSideEffect` / `pipeAsyncSideEffect` to short-circuit on `SideEffect` without breaking composition. Focus on business logic, not error plumbing.
|
|
57
|
+
Handle errors and side effects declaratively in SideEffect-aware pipelines. Use `pipeSideEffect` / `pipeAsyncSideEffect` to short-circuit on `SideEffect` without breaking composition. Focus on business logic, not error plumbing. For strict effect unions, use `pipeSideEffectStrict` / `pipeAsyncSideEffectStrict`.
|
|
58
58
|
|
|
59
59
|
- 💧 **Lazy Stream Processing**
|
|
60
60
|
Efficient iterable processing with `stream/*` functions for memory-conscious operations on large datasets.
|
|
@@ -76,7 +76,7 @@ export default curriedChunk;
|
|
|
76
76
|
`pipe` (sync) and `pipeAsync` (async) are the primary composition tools. All utilities are designed to work seamlessly in pipe chains.
|
|
77
77
|
|
|
78
78
|
- **Pragmatic error handling**
|
|
79
|
-
The `SideEffect` pattern handles errors and side effects declaratively in `pipeSideEffect`/`pipeAsyncSideEffect` pipelines. Write normal functions that compose naturally—these pipelines automatically short-circuit when they encounter a `SideEffect`, eliminating the need for wrapper types everywhere. Use `runPipeResult<T, R>`/`matchSideEffect` **outside** the pipeline with generics for type safety, and `isSideEffect` for runtime type checking.
|
|
79
|
+
The `SideEffect` pattern handles errors and side effects declaratively in `pipeSideEffect`/`pipeAsyncSideEffect` pipelines. Write normal functions that compose naturally—these pipelines automatically short-circuit when they encounter a `SideEffect`, eliminating the need for wrapper types everywhere. For strict union typing across branches, use `pipeSideEffectStrict` / `pipeAsyncSideEffectStrict`. Use `runPipeResult<T, R>`/`matchSideEffect` **outside** the pipeline with generics for type safety, and `isSideEffect` for runtime type checking.
|
|
80
80
|
|
|
81
81
|
- **Immutable & Pure by default**
|
|
82
82
|
Core utilities avoid mutations and side effects. Any exception is explicitly named (e.g. `tap`, `log`).
|
|
@@ -115,7 +115,7 @@ yarn add fp-pack
|
|
|
115
115
|
fp-pack includes an AI agent skills file that helps AI coding assistants (Claude Code, GitHub Copilot, Cursor, etc.) automatically write fp-pack-style functional code.
|
|
116
116
|
|
|
117
117
|
When you have this skills file in your project, AI assistants will:
|
|
118
|
-
- Default to using `pipe`/`pipeAsync` for pure transformations, and `pipeSideEffect`/`pipeAsyncSideEffect` when SideEffect is involved
|
|
118
|
+
- Default to using `pipe`/`pipeAsync` for pure transformations, and `pipeSideEffect`/`pipeAsyncSideEffect` when SideEffect is involved (use strict variants when you need strict effect unions)
|
|
119
119
|
- Use the `SideEffect` pattern instead of try-catch
|
|
120
120
|
- Prefer `stream/*` functions for large datasets
|
|
121
121
|
- Write declarative, functional code using fp-pack utilities
|
|
@@ -136,6 +136,20 @@ mkdir -p .claude/skills
|
|
|
136
136
|
cp node_modules/fp-pack/dist/skills/fp-pack.md .claude/skills/
|
|
137
137
|
```
|
|
138
138
|
|
|
139
|
+
### Setup for Codex
|
|
140
|
+
|
|
141
|
+
Copy the Codex skill to your project's `$CODEX_HOME/skills/` directory (default: `~/.codex/skills`):
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# Unix/macOS/Linux
|
|
145
|
+
mkdir -p ~/.codex/skills/fp-pack
|
|
146
|
+
cp node_modules/fp-pack/dist/skills/fp-pack/SKILL.md ~/.codex/skills/fp-pack/SKILL.md
|
|
147
|
+
|
|
148
|
+
# Windows (PowerShell)
|
|
149
|
+
New-Item -ItemType Directory -Force -Path "$HOME/.codex/skills/fp-pack"
|
|
150
|
+
Copy-Item node_modules/fp-pack/dist/skills/fp-pack/SKILL.md $HOME/.codex/skills/fp-pack/SKILL.md
|
|
151
|
+
```
|
|
152
|
+
|
|
139
153
|
Once configured, AI assistants will automatically apply fp-pack coding patterns when helping you write code.
|
|
140
154
|
|
|
141
155
|
> **Note:** The skills file is located at `node_modules/fp-pack/dist/skills/fp-pack.md` after installation. You can also view it in the [GitHub repository](https://github.com/superlucky84/fp-pack/blob/main/fp-pack.md).
|
|
@@ -213,6 +227,7 @@ Functions for composing and transforming other functions.
|
|
|
213
227
|
|
|
214
228
|
- **pipe** - Compose functions left to right (f → g → h)
|
|
215
229
|
- **pipeSideEffect** - Compose functions left to right with SideEffect short-circuiting
|
|
230
|
+
- **pipeSideEffectStrict** - SideEffect composition with strict effect unions
|
|
216
231
|
- **compose** - Compose functions right to left (h → g → f)
|
|
217
232
|
- **curry** - Transform a function to support partial application
|
|
218
233
|
- **partial** - Pre-fill function arguments
|
|
@@ -220,6 +235,7 @@ Functions for composing and transforming other functions.
|
|
|
220
235
|
- **complement** - Logical negation of a predicate
|
|
221
236
|
- **identity** - Return input unchanged
|
|
222
237
|
- **constant** - Always return the same value
|
|
238
|
+
- **from** - Ignore input and return a fixed value
|
|
223
239
|
- **tap** - Execute side effects without changing the value
|
|
224
240
|
- **once** - Create a function that only executes once
|
|
225
241
|
- **memoize** - Cache function results for same inputs
|
|
@@ -282,6 +298,7 @@ Functions for working with arrays. All operations are immutable and return new a
|
|
|
282
298
|
Functions for working with objects and records. All operations are immutable.
|
|
283
299
|
|
|
284
300
|
- **prop** - Safely access object property
|
|
301
|
+
- **propStrict** - Access property and throw if it is null or undefined
|
|
285
302
|
- **propOr** - Access property with default value
|
|
286
303
|
- **path** - Safely access nested property path
|
|
287
304
|
- **pathOr** - Access nested path with default value
|
|
@@ -354,6 +371,7 @@ Functions for asynchronous operations.
|
|
|
354
371
|
|
|
355
372
|
- **pipeAsync** - Compose async/sync functions (pure)
|
|
356
373
|
- **pipeAsyncSideEffect** - Async composition with SideEffect short-circuiting
|
|
374
|
+
- **pipeAsyncSideEffectStrict** - Async SideEffect composition with strict effect unions
|
|
357
375
|
- **delay** - Wait for specified milliseconds
|
|
358
376
|
- **timeout** - Execute promise with timeout limit
|
|
359
377
|
- **retry** - Retry failed operations with optional delay
|
|
@@ -414,7 +432,7 @@ Functions for debugging and development.
|
|
|
414
432
|
|
|
415
433
|
**The JavaScript exception problem:** In functional pipelines, throwing exceptions breaks composition—control jumps out of the pipe. To avoid this, you need `try-catch` (which breaks flow) or wrap every function in `Either`/`Result` (which requires `map`/`chain` everywhere). Both solutions make you think about error plumbing instead of business logic.
|
|
416
434
|
|
|
417
|
-
**The SideEffect solution:** Write normal functions that compose naturally. When you need to terminate early (validation failure, missing data, errors), return `SideEffect.of(() => ...)`. `pipeSideEffect`/`pipeAsyncSideEffect` pipelines automatically stop—no ceremony, no wrappers, no plumbing.
|
|
435
|
+
**The SideEffect solution:** Write normal functions that compose naturally. When you need to terminate early (validation failure, missing data, errors), return `SideEffect.of(() => ...)`. `pipeSideEffect`/`pipeAsyncSideEffect` pipelines automatically stop—no ceremony, no wrappers, no plumbing. For stricter union typing across branches, use `pipeSideEffectStrict` / `pipeAsyncSideEffectStrict`.
|
|
418
436
|
|
|
419
437
|
```typescript
|
|
420
438
|
import { pipeSideEffect, SideEffect, runPipeResult } from 'fp-pack';
|
|
@@ -517,8 +535,10 @@ Most data transformations are pure and don't need SideEffect handling. Use `pipe
|
|
|
517
535
|
- **`pipeAsync`** - Async, **pure** transformations (99% of cases)
|
|
518
536
|
- **`pipeSideEffect`** - **Only when you need** SideEffect short-circuiting (sync)
|
|
519
537
|
- **`pipeAsyncSideEffect`** - **Only when you need** SideEffect short-circuiting (async)
|
|
538
|
+
- **`pipeSideEffectStrict`** - Sync SideEffect pipelines with strict effect unions
|
|
539
|
+
- **`pipeAsyncSideEffectStrict`** - Async SideEffect pipelines with strict effect unions
|
|
520
540
|
|
|
521
|
-
**Important:** `pipe` and `pipeAsync` are for **pure** functions only—they don't handle `SideEffect`. If your pipeline can return `SideEffect`, use `pipeSideEffect` or `pipeAsyncSideEffect` instead.
|
|
541
|
+
**Important:** `pipe` and `pipeAsync` are for **pure** functions only—they don't handle `SideEffect`. If your pipeline can return `SideEffect`, use `pipeSideEffect` or `pipeAsyncSideEffect` instead. Choose the strict variants when you need precise unions for SideEffect results.
|
|
522
542
|
|
|
523
543
|
```typescript
|
|
524
544
|
// Pure sync pipe - no SideEffect handling
|
|
@@ -552,7 +572,7 @@ const fetchAndValidate = pipeAsyncSideEffect(
|
|
|
552
572
|
|
|
553
573
|
**🔄 Critical Rule: SideEffect Contagion**
|
|
554
574
|
|
|
555
|
-
Once you use `pipeSideEffect` or `pipeAsyncSideEffect`, the result is **always `T | SideEffect`** (or `Promise<T | SideEffect>` for async).
|
|
575
|
+
Once you use `pipeSideEffect` or `pipeAsyncSideEffect`, the result is **always `T | SideEffect`** (or `Promise<T | SideEffect>` for async). The same rule applies to strict variants.
|
|
556
576
|
|
|
557
577
|
If you want to continue composing this result, you **MUST** keep using SideEffect-aware pipes. You **CANNOT** switch back to `pipe` or `pipeAsync` because they don't handle `SideEffect`.
|
|
558
578
|
|
package/dist/fp-pack.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(i,y){typeof exports=="object"&&typeof module<"u"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):(i=typeof globalThis<"u"?globalThis:i||self,y(i.FpPack={}))})(this,(function(i){"use strict";function y(...n){return t=>n.reduce((e,r)=>r(e),t)}class d{effect;label;constructor(t,e){this.effect=t,this.label=e}static of(t,e){return new d(t,e)}}function N(n,t){return n instanceof d?t.effect(n):t.value(n)}function E(n){return m(n)?n.effect():n}function m(n){return n instanceof d}function P(...n){return t=>{let e=t;for(const r of n){if(m(e))return e;e=r(e)}return e}}function S(...n){return t=>n.reduceRight((e,r)=>r(e),t)}function c(n,...t){const e=r=>r.length>=n.length?n(...r):(...u)=>e([...r,...u]);return t.length===0?e([]):e(t)}function k(n,...t){return function(...r){const u=[...t,...r];return n.apply(this,u)}}function z(n){return function(...e){const r=[...e].reverse();return n.apply(this,r)}}function I(n,...t){return t.length===0?(...e)=>!n(...e):!n(...t)}function W(n){return n}function D(n){return()=>n}function L(n){return t=>(n(t),t)}function _(n){let t=!1,e;return function(...u){return t||(t=!0,e=n.apply(this,u)),e}}function C(n){const t=new Map,e=Symbol("result");return function(...u){let o=t;for(const s of u)o.has(s)||o.set(s,new Map),o=o.get(s);if(o.has(e))return o.get(e);const f=n.apply(this,u);return o.set(e,f),f}}function v(n,t,e,r){return n(r)?t(r):e(r)}const K=c(v);function q(n,t,e){return n(e)?t(e):e}const B=c(q);function F(n,t,e){return n(e)?e:t(e)}const V=c(F);function R(n){return t=>{for(const[e,r]of n)if(e(t))return r(t)}}function $(n,t,e){try{return n(e)}catch(r){const u=r instanceof Error?r:new Error(String(r));return t(u,e)}}const U=c($);function j(n,t,e){return n(e)?e:t}const G=c(j);function Z(n,t){return t.map(n)}const H=c(Z);function J(n,t){return t.filter(n)}const Q=c(J);function X(n,t,e){return e.reduce(n,t)}const Y=c(X);function x(n,t){return t.flatMap(n)}const nn=c(x);function tn(n,t){return t.find(n)}const en=c(tn);function rn(n,t){for(let e=0;e<t.length;e++)if(n(t[e]))return!0;return!1}const un=c(rn);function cn(n,t){return t.every(n)}const on=c(cn);function fn(n,t){return n<=0?[]:n>=t.length?[...t]:t.slice(0,n)}const sn=c(fn);function ln(n,t){const e=Math.floor(n);return!Number.isFinite(e)||e<=0?t:t.slice(e)}const an=c(ln);function dn(n,t){const e=[];let r=!0;for(const u of t)r&&!n(u)&&(r=!1),r||e.push(u);return e}const hn=c(dn);function yn(n,t){const e=Math.floor(n);if(!Number.isFinite(e)||e<=0)return[];const r=[];for(let u=0;u<t.length;u+=e)r.push(t.slice(u,u+e));return r}const mn=c(yn);function gn(n,t){const e=Math.min(t.length,n.length),r=[];for(let u=0;u<e;u+=1)r.push([t[u],n[u]]);return r}const pn=c(gn);function An(n,t,e){const r=Math.min(e.length,t.length),u=[];for(let o=0;o<r;o+=1)u.push(n(e[o],t[o]));return u}const wn=c(An);function bn(n){const t=[],e=[];for(const[r,u]of n)t.push(r),e.push(u);return[t,e]}function On(n){const t=new Set,e=[];for(const r of n)t.has(r)||(t.add(r),e.push(r));return e}function Tn(n,t){const e=new Set,r=[];for(const u of t){const o=n(u);e.has(o)||(e.add(o),r.push(u))}return r}const Mn=c(Tn);function Nn(n,t){return[...t].sort((e,r)=>{const u=n(e),o=n(r);return u<o?-1:u>o?1:0})}const En=c(Nn);function Pn(n,t){return[...t].sort(n)}const Sn=c(Pn);function kn(n,t){return t.reduce((e,r)=>{const u=n(r);return e[u]||(e[u]=[]),e[u].push(r),e},{})}const zn=c(kn);function In(n){return n.map((t,e)=>[e,t])}function Wn(n,t){const e=[];for(const r of t){if(!n(r))break;e.push(r)}return e}const Dn=c(Wn);function Ln(n,t,e){const r=[];let u=t;for(const o of e)u=n(u,o),r.push(u);return r}const _n=c(Ln);function Cn(n,t){return[...t,...n]}const vn=c(Cn);function Kn(n,t){return[...t,n]}const qn=c(Kn);function Bn(n,t){return[n,...t]}const Fn=c(Bn);function Vn(n){return n.flat()}function Rn(n){return n[0]}function $n(n){return n.slice(1)}function Un(n){if(n.length!==0)return n[n.length-1]}function jn(n){return n.length<=1?[]:n.slice(0,-1)}function Gn(n,t){if(!Number.isFinite(n)||!Number.isFinite(t))return[];if(n===t)return[];const e=n<t?1:-1,r=[];for(let u=n;e>0?u<t:u>t;u+=e)r.push(u);return r}function Zn(n,t){const e=[],r=[];for(const u of t)n(u)?e.push(u):r.push(u);return[e,r]}const Hn=c(Zn);function Jn(n){const t=[],e=r=>{for(const u of r)Array.isArray(u)?e(u):t.push(u)};return e(n),t}function Qn(n,t){return t?.[n]}const Xn=c(Qn);function Yn(n,t,e){const r=e?.[t];return r??n}const xn=c(Yn);function nt(n,t){return n.reduce((e,r)=>e?.[r],t)}const tt=c(nt);function et(n,t,e){const r=t.reduce((u,o)=>u?.[o],e);return r??n}const rt=c(et);function it(n,t){const e={};for(const r of n)r in t&&(e[r]=t[r]);return e}const ut=c(it);function ct(n,t){const e={...t};for(const r of n)delete e[r];return e}const ot=c(ct);function ft(n,t,e){if(Array.isArray(e)){const r=e.slice();return r[n]=t,r}return e&&typeof e=="object"?{...e,[n]:t}:{[n]:t}}const st=c(ft),b=n=>typeof n=="number"?Number.isInteger(n):typeof n=="string"?/^-?\d+$/.test(n):!1,lt=(n,t)=>{const e=typeof n=="number"?n:Number(n);return Number.isNaN(e)?-1:e<0?Math.max(t+e,0):e},O=n=>n!==null&&typeof n=="object";function g(n,t,e){if(n.length===0)return t;const[r,...u]=n,o=b(r),f=Array.isArray(e)?e.slice():O(e)?{...e}:o?[]:{};if(Array.isArray(f)&&b(r)){const a=lt(r,f.length),A=f[a],w=u.length===0?t:g(u,t,A);return f[a]=w,f}const s=O(f)?f[r]:void 0,l=u.length===0?t:g(u,t,s);return f[r]=l,f}const at=c(g);function dt(n,t){if(Array.isArray(t)){const e=t.slice(),r=typeof n=="number"?n:Number.isNaN(Number(n))?-1:Number(n);return r>=0&&r<e.length?e.splice(r,1):delete e[n],e}if(t&&typeof t=="object"){const{[n]:e,...r}=t;return r}return t}const ht=n=>typeof n=="number"?Number.isInteger(n):typeof n=="string"?/^-?\d+$/.test(n):!1,yt=(n,t)=>{const e=typeof n=="number"?n:Number(n);return Number.isNaN(e)?-1:e<0?t+e:e},mt=n=>n!==null&&typeof n=="object";function p(n,t){if(n.length===0||!mt(t))return t;const[e,...r]=n;if(Array.isArray(t)&&ht(e)){const o=yt(e,t.length);if(o<0||o>=t.length)return t;const f=t.slice();if(r.length===0)return f.splice(o,1),f;const s=p(r,f[o]);return f[o]=s,f}if(!Object.prototype.hasOwnProperty.call(t,e))return t;if(r.length===0){const{[e]:o,...f}=t;return f}const u={...t};return u[e]=p(r,u[e]),u}const gt=c(p);function pt(n,t){return{...n,...t}}const At=c(pt);function wt(n,t){const e=u=>typeof u=="object"&&u!==null&&!Array.isArray(u),r=(u,o)=>{const f={...u};for(const[s,l]of Object.entries(o)){const a=f[s];e(a)&&e(l)?f[s]=r(a,l):f[s]=l}return f};return e(n)&&e(t)?r(n,t):{...n,...t}}const bt=c(wt);function Ot(n){return n.reduce((e,r)=>({...e,...r}),{})}function Tt(n){return Object.keys(n)}function Mt(n){return Object.values(n)}function Nt(n){return Object.entries(n)}function Et(n){return t=>{const e={};for(const[r,u]of Object.entries(t))e[r]=n(u);return e}}function Pt(n,t){const e={...t};for(const r of Object.keys(n)){const u=n[r];typeof u=="function"&&(e[r]=u(t[r]))}return e}const St=c(Pt);function kt(n,t){return Object.prototype.hasOwnProperty.call(t,n)}const zt=c(kt);function It(n){return t=>{let e=t;for(const r of n){if(e==null||!Object.prototype.hasOwnProperty.call(e,r))return!1;e=e[r]}return!0}}function Wt(n,t){return h(n,t,new WeakMap)}function h(n,t,e){if(n===t||typeof n=="number"&&typeof t=="number"&&Number.isNaN(n)&&Number.isNaN(t))return!0;if(n===null||t===null||typeof n!="object"||typeof t!="object")return!1;if(e.has(n))return e.get(n)===t;if(e.set(n,t),n instanceof Date&&t instanceof Date)return n.getTime()===t.getTime();if(n instanceof Map&&t instanceof Map){if(n.size!==t.size)return!1;const o=Array.from(t.entries());for(const[f,s]of n.entries()){let l=!1;for(let a=0;a<o.length;a++){const[A,w]=o[a];if(h(f,A,e)&&h(s,w,e)){o.splice(a,1),l=!0;break}}if(!l)return!1}return!0}if(n instanceof Set&&t instanceof Set){if(n.size!==t.size)return!1;const o=Array.from(t.values());for(const f of n.values()){let s=!1;for(let l=0;l<o.length;l++)if(h(f,o[l],e)){o.splice(l,1),s=!0;break}if(!s)return!1}return!0}if(Array.isArray(n)&&Array.isArray(t)){if(n.length!==t.length)return!1;for(let o=0;o<n.length;o++)if(!h(n[o],t[o],e))return!1;return!0}const r=Reflect.ownKeys(n),u=Reflect.ownKeys(t);if(r.length!==u.length)return!1;for(const o of r)if(!Object.prototype.hasOwnProperty.call(t,o)||!h(n[o],t[o],e))return!1;return!0}const T=c(Wt);function Dt(n){return n==null}function Lt(n){return n==null?!0:typeof n=="string"||Array.isArray(n)?n.length===0:n instanceof Map||n instanceof Set?n.size===0:typeof n=="object"?Object.keys(n).length===0:!1}function _t(n){const t=n.toLowerCase();return e=>{if(e===null)return t==="null";if(e===void 0)return t==="undefined";const r=typeof e;return r!=="object"?r===t:Object.prototype.toString.call(e).slice(8,-1).toLowerCase()===t}}function Ct(n){return t=>t>n}function vt(n){return t=>t>=n}function Kt(n){return t=>t<n}function qt(n){return t=>t<=n}function Bt(n,t,e){return e<n?n:e>t?t:e}const Ft=c(Bt);function Vt(n,t){if(typeof t=="string"&&typeof n=="string")return t.includes(n);if(Array.isArray(t)){for(let e=0;e<t.length;e++)if(T(t[e],n))return!0;return!1}return!1}function Rt(n,t){return n+t}const $t=c(Rt);function Ut(n,t){return n-t}const jt=c(Ut);function Gt(n,t){return n*t}const Zt=c(Gt);function Ht(n,t){return n/t}const Jt=c(Ht);function Qt(n){return n.reduce((t,e)=>t+e,0)}function Xt(n){return n.length===0?NaN:n.reduce((e,r)=>e+r,0)/n.length}function Yt(n){return n.length===0?1/0:Math.min(...n)}function xt(n){return n.length===0?-1/0:Math.max(...n)}function ne(n){return Math.round(n)}function te(n){return Math.floor(n)}function ee(n){return Math.ceil(n)}function re(n,t){const e=Math.ceil(n),r=Math.floor(t);return r<e?e:Math.floor(Math.random()*(r-e+1))+e}const ie=c(re);function ue(n){return n.trim()}function ce(n,t){return t.split(n)}const oe=c(ce);function fe(n,t){return t.join(n)}const se=c(fe);function le(n,t,e){return e.replace(n,t)}const ae=c(le);function de(n){return n.toUpperCase()}function he(n){return n.toLowerCase()}function ye(n,t){if(typeof t=="string"&&typeof n=="string")return t.startsWith(n);if(Array.isArray(n)&&Array.isArray(t)){if(n.length===0)return!0;if(n.length>t.length)return!1;for(let e=0;e<n.length;e++)if(t[e]!==n[e])return!1;return!0}return!1}function me(n,t){if(typeof t=="string"&&typeof n=="string")return t.endsWith(n);if(Array.isArray(n)&&Array.isArray(t)){if(n.length===0)return!0;if(n.length>t.length)return!1;for(let e=0;e<n.length;e++){const r=t.length-n.length+e;if(t[r]!==n[e])return!1}return!0}return!1}function ge(n,t){return t.match(n)}const pe=c(ge);function Ae(...n){return async t=>{let e=t;for(const r of n)e=await r(e);return e}}function we(...n){return async t=>{let e=t;for(const r of n){if(m(e))return e;e=await r(e)}return e}}function M(n){return new Promise(t=>{setTimeout(t,n)})}function be(n,t){return new Promise((e,r)=>{const u=setTimeout(()=>r(new Error(`Timed out after ${n}ms`)),n);t.then(o=>{clearTimeout(u),e(o)}).catch(o=>{clearTimeout(u),r(o)})})}const Oe=c(be);function Te(n,t,e=0){return(async()=>{let r=0;for(;;)try{return await t()}catch(u){if(r+=1,r>n)throw u;e>0&&await M(e)}})()}const Me=c(Te);function Ne(n,t){let e;return function(...u){e&&clearTimeout(e);const o=this;e=setTimeout(()=>{e=void 0,n.apply(o,u)},t)}}const Ee=c(Ne);function Pe(n,t){let e;return function(...u){e||(n.apply(this,u),e=setTimeout(()=>{e=void 0},t))}}const Se=c(Pe);function ke(n,t){let e,r=!1,u,o;const f=()=>{e=void 0,r&&u&&(r=!1,n.apply(o,u))};return function(...l){if(!e){n.apply(this,l),e=setTimeout(f,t);return}r=!0,u=l,o=this,clearTimeout(e),e=setTimeout(f,t)}}const ze=c(ke);function Ie(n,t){let e=0,r=null,u=null;const o=(s,l)=>{e=Date.now(),n.apply(s,l)};return function(...s){const l=Date.now(),a=t-(l-e);a<=0?(u&&(clearTimeout(u),u=null),r=null,o(this,s)):(r=s,u||(u=setTimeout(()=>{u=null,r&&(o(this,r),r=null)},a)))}}const We=c(Ie);function De(n){return t=>t==null?null:n(t)}function Le(n){return t=>{const e=[];for(const r of t){const u=n(r);u!=null&&e.push(u)}return e}}function _e(n){return t=>t??n}function Ce(n){try{return{ok:!0,value:n()}}catch(t){return{ok:!1,error:t}}}function ve(n,t,e){return e==null?n():t(e)}const Ke=c(ve);function qe(n,t){if(!n)throw new Error(t??"Assertion failed")}const Be=c(qe);function Fe(n,t){if(!n)throw new Error(t??"Invariant failed")}const Ve=c(Fe);function Re(n){return t=>(n?console.log(n,t):console.log(t),t)}i.SideEffect=d,i.SideEffectClass=d,i.add=$t,i.append=qn,i.assert=Be,i.assoc=st,i.assocPath=at,i.ceil=ee,i.chunk=mn,i.clamp=Ft,i.complement=I,i.compose=S,i.concat=vn,i.cond=R,i.constant=D,i.curry=c,i.debounce=Ee,i.debounceLeading=Se,i.debounceLeadingTrailing=ze,i.delay=M,i.dissoc=dt,i.dissocPath=gt,i.div=Jt,i.drop=an,i.dropWhile=hn,i.endsWith=me,i.entries=Nt,i.equals=T,i.every=on,i.evolve=St,i.filter=Q,i.find=en,i.flatMap=nn,i.flatten=Vn,i.flattenDeep=Jn,i.flip=z,i.floor=te,i.fold=Ke,i.getOrElse=_e,i.groupBy=zn,i.gt=Ct,i.gte=vt,i.guard=G,i.has=zt,i.hasPath=It,i.head=Rn,i.identity=W,i.ifElse=K,i.includes=Vt,i.init=jn,i.invariant=Ve,i.isEmpty=Lt,i.isNil=Dt,i.isSideEffect=m,i.isType=_t,i.join=se,i.keys=Tt,i.last=Un,i.log=Re,i.lt=Kt,i.lte=qt,i.map=H,i.mapMaybe=Le,i.mapValues=Et,i.match=pe,i.matchSideEffect=N,i.max=xt,i.maybe=De,i.mean=Xt,i.memoize=C,i.merge=At,i.mergeAll=Ot,i.mergeDeep=bt,i.min=Yt,i.mul=Zt,i.omit=ot,i.once=_,i.partial=k,i.partition=Hn,i.path=tt,i.pathOr=rt,i.pick=ut,i.pipe=y,i.pipeAsync=Ae,i.pipeAsyncSideEffect=we,i.pipeSideEffect=P,i.prepend=Fn,i.prop=Xn,i.propOr=xn,i.randomInt=ie,i.range=Gn,i.reduce=Y,i.replace=ae,i.result=Ce,i.retry=Me,i.round=ne,i.runPipeResult=E,i.scan=_n,i.some=un,i.sort=Sn,i.sortBy=En,i.split=oe,i.startsWith=ye,i.sub=jt,i.sum=Qt,i.tail=$n,i.take=sn,i.takeWhile=Dn,i.tap=L,i.throttle=We,i.timeout=Oe,i.toLower=he,i.toUpper=de,i.trim=ue,i.tryCatch=U,i.uniq=On,i.uniqBy=Mn,i.unless=V,i.unzip=bn,i.values=Mt,i.when=B,i.zip=pn,i.zipIndex=In,i.zipWith=wn,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(i,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(i=typeof globalThis<"u"?globalThis:i||self,m(i.FpPack={}))})(this,(function(i){"use strict";function m(...n){return t=>n.reduce((e,r)=>r(e),t)}class d{effect;label;constructor(t,e){this.effect=t,this.label=e}static of(t,e){return new d(t,e)}}function T(n,t){return n instanceof d?t.effect(n):t.value(n)}function M(n){return h(n)?n.effect():n}function h(n){return n instanceof d}function N(...n){return t=>{let e=t;for(const r of n){if(h(e))return e;e=r(e)}return e}}function P(...n){return t=>{let e=t;for(const r of n){if(h(e))return e;e=r(e)}return e}}function k(...n){return t=>n.reduceRight((e,r)=>r(e),t)}function c(n,...t){const e=r=>r.length>=n.length?n(...r):(...u)=>e([...r,...u]);return t.length===0?e([]):e(t)}function z(n,...t){return function(...r){const u=[...t,...r];return n.apply(this,u)}}function I(n){return function(...e){const r=[...e].reverse();return n.apply(this,r)}}function W(n,...t){return t.length===0?(...e)=>!n(...e):!n(...t)}function D(n){return n}function L(n){return()=>n}function _(n){return t=>n}function v(n){return t=>(n(t),t)}function C(n){let t=!1,e;return function(...u){return t||(t=!0,e=n.apply(this,u)),e}}function K(n){const t=new Map,e=Symbol("result");return function(...u){let o=t;for(const s of u)o.has(s)||o.set(s,new Map),o=o.get(s);if(o.has(e))return o.get(e);const f=n.apply(this,u);return o.set(e,f),f}}function q(n,t,e,r){return n(r)?t(r):e(r)}const B=c(q);function F(n,t,e){return n(e)?t(e):e}const V=c(F);function R(n,t,e){return n(e)?e:t(e)}const $=c(R);function U(n){return t=>{for(const[e,r]of n)if(e(t))return r(t)}}function j(n,t,e){try{return n(e)}catch(r){const u=r instanceof Error?r:new Error(String(r));return t(u,e)}}const G=c(j);function Z(n,t,e){return n(e)?e:t}const H=c(Z);function J(n,t){return t.map(n)}const Q=c(J);function X(n,t){return t.filter(n)}const Y=c(X);function x(n,t,e){return e.reduce(n,t)}const nn=c(x);function tn(n,t){return t.flatMap(n)}const en=c(tn);function rn(n,t){return t.find(n)}const un=c(rn);function cn(n,t){for(let e=0;e<t.length;e++)if(n(t[e]))return!0;return!1}const on=c(cn);function fn(n,t){return t.every(n)}const sn=c(fn);function ln(n,t){return n<=0?[]:n>=t.length?[...t]:t.slice(0,n)}const an=c(ln);function dn(n,t){const e=Math.floor(n);return!Number.isFinite(e)||e<=0?t:t.slice(e)}const hn=c(dn);function yn(n,t){const e=[];let r=!0;for(const u of t)r&&!n(u)&&(r=!1),r||e.push(u);return e}const mn=c(yn);function pn(n,t){const e=Math.floor(n);if(!Number.isFinite(e)||e<=0)return[];const r=[];for(let u=0;u<t.length;u+=e)r.push(t.slice(u,u+e));return r}const gn=c(pn);function An(n,t){const e=Math.min(t.length,n.length),r=[];for(let u=0;u<e;u+=1)r.push([t[u],n[u]]);return r}const wn=c(An);function Sn(n,t,e){const r=Math.min(e.length,t.length),u=[];for(let o=0;o<r;o+=1)u.push(n(e[o],t[o]));return u}const bn=c(Sn);function En(n){const t=[],e=[];for(const[r,u]of n)t.push(r),e.push(u);return[t,e]}function On(n){const t=new Set,e=[];for(const r of n)t.has(r)||(t.add(r),e.push(r));return e}function Tn(n,t){const e=new Set,r=[];for(const u of t){const o=n(u);e.has(o)||(e.add(o),r.push(u))}return r}const Mn=c(Tn);function Nn(n,t){return[...t].sort((e,r)=>{const u=n(e),o=n(r);return u<o?-1:u>o?1:0})}const Pn=c(Nn);function kn(n,t){return[...t].sort(n)}const zn=c(kn);function In(n,t){return t.reduce((e,r)=>{const u=n(r);return e[u]||(e[u]=[]),e[u].push(r),e},{})}const Wn=c(In);function Dn(n){return n.map((t,e)=>[e,t])}function Ln(n,t){const e=[];for(const r of t){if(!n(r))break;e.push(r)}return e}const _n=c(Ln);function vn(n,t,e){const r=[];let u=t;for(const o of e)u=n(u,o),r.push(u);return r}const Cn=c(vn);function Kn(n,t){return[...t,...n]}const qn=c(Kn);function Bn(n,t){return[...t,n]}const Fn=c(Bn);function Vn(n,t){return[n,...t]}const Rn=c(Vn);function $n(n){return n.flat()}function Un(n){return n[0]}function jn(n){return n.slice(1)}function Gn(n){if(n.length!==0)return n[n.length-1]}function Zn(n){return n.length<=1?[]:n.slice(0,-1)}function Hn(n,t){if(!Number.isFinite(n)||!Number.isFinite(t))return[];if(n===t)return[];const e=n<t?1:-1,r=[];for(let u=n;e>0?u<t:u>t;u+=e)r.push(u);return r}function Jn(n,t){const e=[],r=[];for(const u of t)n(u)?e.push(u):r.push(u);return[e,r]}const Qn=c(Jn);function Xn(n){const t=[],e=r=>{for(const u of r)Array.isArray(u)?e(u):t.push(u)};return e(n),t}function Yn(n,t){return t?.[n]}const xn=c(Yn);function nt(n,t){const e=t?.[n];if(e==null)throw new Error(`propStrict: "${String(n)}" is null or undefined`);return e}const tt=c(nt);function et(n,t,e){const r=e?.[t];return r??n}const rt=c(et);function it(n,t){return n.reduce((e,r)=>e?.[r],t)}const ut=c(it);function ct(n,t,e){const r=t.reduce((u,o)=>u?.[o],e);return r??n}const ot=c(ct);function ft(n,t){const e={};for(const r of n)r in t&&(e[r]=t[r]);return e}const st=c(ft);function lt(n,t){const e={...t};for(const r of n)delete e[r];return e}const at=c(lt);function dt(n,t,e){if(Array.isArray(e)){const r=e.slice();return r[n]=t,r}return e&&typeof e=="object"?{...e,[n]:t}:{[n]:t}}const ht=c(dt),S=n=>typeof n=="number"?Number.isInteger(n):typeof n=="string"?/^-?\d+$/.test(n):!1,yt=(n,t)=>{const e=typeof n=="number"?n:Number(n);return Number.isNaN(e)?-1:e<0?Math.max(t+e,0):e},b=n=>n!==null&&typeof n=="object";function p(n,t,e){if(n.length===0)return t;const[r,...u]=n,o=S(r),f=Array.isArray(e)?e.slice():b(e)?{...e}:o?[]:{};if(Array.isArray(f)&&S(r)){const a=yt(r,f.length),A=f[a],w=u.length===0?t:p(u,t,A);return f[a]=w,f}const s=b(f)?f[r]:void 0,l=u.length===0?t:p(u,t,s);return f[r]=l,f}const mt=c(p);function pt(n,t){if(Array.isArray(t)){const e=t.slice(),r=typeof n=="number"?n:Number.isNaN(Number(n))?-1:Number(n);return r>=0&&r<e.length?e.splice(r,1):delete e[n],e}if(t&&typeof t=="object"){const{[n]:e,...r}=t;return r}return t}const gt=n=>typeof n=="number"?Number.isInteger(n):typeof n=="string"?/^-?\d+$/.test(n):!1,At=(n,t)=>{const e=typeof n=="number"?n:Number(n);return Number.isNaN(e)?-1:e<0?t+e:e},wt=n=>n!==null&&typeof n=="object";function g(n,t){if(n.length===0||!wt(t))return t;const[e,...r]=n;if(Array.isArray(t)&>(e)){const o=At(e,t.length);if(o<0||o>=t.length)return t;const f=t.slice();if(r.length===0)return f.splice(o,1),f;const s=g(r,f[o]);return f[o]=s,f}if(!Object.prototype.hasOwnProperty.call(t,e))return t;if(r.length===0){const{[e]:o,...f}=t;return f}const u={...t};return u[e]=g(r,u[e]),u}const St=c(g);function bt(n,t){return{...n,...t}}const Et=c(bt);function Ot(n,t){const e=u=>typeof u=="object"&&u!==null&&!Array.isArray(u),r=(u,o)=>{const f={...u};for(const[s,l]of Object.entries(o)){const a=f[s];e(a)&&e(l)?f[s]=r(a,l):f[s]=l}return f};return e(n)&&e(t)?r(n,t):{...n,...t}}const Tt=c(Ot);function Mt(n){return n.reduce((e,r)=>({...e,...r}),{})}function Nt(n){return Object.keys(n)}function Pt(n){return Object.values(n)}function kt(n){return Object.entries(n)}function zt(n){return t=>{const e={};for(const[r,u]of Object.entries(t))e[r]=n(u);return e}}function It(n,t){const e={...t};for(const r of Object.keys(n)){const u=n[r];typeof u=="function"&&(e[r]=u(t[r]))}return e}const Wt=c(It);function Dt(n,t){return Object.prototype.hasOwnProperty.call(t,n)}const Lt=c(Dt);function _t(n){return t=>{let e=t;for(const r of n){if(e==null||!Object.prototype.hasOwnProperty.call(e,r))return!1;e=e[r]}return!0}}function vt(n,t){return y(n,t,new WeakMap)}function y(n,t,e){if(n===t||typeof n=="number"&&typeof t=="number"&&Number.isNaN(n)&&Number.isNaN(t))return!0;if(n===null||t===null||typeof n!="object"||typeof t!="object")return!1;if(e.has(n))return e.get(n)===t;if(e.set(n,t),n instanceof Date&&t instanceof Date)return n.getTime()===t.getTime();if(n instanceof Map&&t instanceof Map){if(n.size!==t.size)return!1;const o=Array.from(t.entries());for(const[f,s]of n.entries()){let l=!1;for(let a=0;a<o.length;a++){const[A,w]=o[a];if(y(f,A,e)&&y(s,w,e)){o.splice(a,1),l=!0;break}}if(!l)return!1}return!0}if(n instanceof Set&&t instanceof Set){if(n.size!==t.size)return!1;const o=Array.from(t.values());for(const f of n.values()){let s=!1;for(let l=0;l<o.length;l++)if(y(f,o[l],e)){o.splice(l,1),s=!0;break}if(!s)return!1}return!0}if(Array.isArray(n)&&Array.isArray(t)){if(n.length!==t.length)return!1;for(let o=0;o<n.length;o++)if(!y(n[o],t[o],e))return!1;return!0}const r=Reflect.ownKeys(n),u=Reflect.ownKeys(t);if(r.length!==u.length)return!1;for(const o of r)if(!Object.prototype.hasOwnProperty.call(t,o)||!y(n[o],t[o],e))return!1;return!0}const E=c(vt);function Ct(n){return n==null}function Kt(n){return n==null?!0:typeof n=="string"||Array.isArray(n)?n.length===0:n instanceof Map||n instanceof Set?n.size===0:typeof n=="object"?Object.keys(n).length===0:!1}function qt(n){const t=n.toLowerCase();return e=>{if(e===null)return t==="null";if(e===void 0)return t==="undefined";const r=typeof e;return r!=="object"?r===t:Object.prototype.toString.call(e).slice(8,-1).toLowerCase()===t}}function Bt(n){return t=>t>n}function Ft(n){return t=>t>=n}function Vt(n){return t=>t<n}function Rt(n){return t=>t<=n}function $t(n,t,e){return e<n?n:e>t?t:e}const Ut=c($t);function jt(n,t){if(typeof t=="string"&&typeof n=="string")return t.includes(n);if(Array.isArray(t)){for(let e=0;e<t.length;e++)if(E(t[e],n))return!0;return!1}return!1}function Gt(n,t){return n+t}const Zt=c(Gt);function Ht(n,t){return n-t}const Jt=c(Ht);function Qt(n,t){return n*t}const Xt=c(Qt);function Yt(n,t){return n/t}const xt=c(Yt);function ne(n){return n.reduce((t,e)=>t+e,0)}function te(n){return n.length===0?NaN:n.reduce((e,r)=>e+r,0)/n.length}function ee(n){return n.length===0?1/0:Math.min(...n)}function re(n){return n.length===0?-1/0:Math.max(...n)}function ie(n){return Math.round(n)}function ue(n){return Math.floor(n)}function ce(n){return Math.ceil(n)}function oe(n,t){const e=Math.ceil(n),r=Math.floor(t);return r<e?e:Math.floor(Math.random()*(r-e+1))+e}const fe=c(oe);function se(n){return n.trim()}function le(n,t){return t.split(n)}const ae=c(le);function de(n,t){return t.join(n)}const he=c(de);function ye(n,t,e){return e.replace(n,t)}const me=c(ye);function pe(n){return n.toUpperCase()}function ge(n){return n.toLowerCase()}function Ae(n,t){if(typeof t=="string"&&typeof n=="string")return t.startsWith(n);if(Array.isArray(n)&&Array.isArray(t)){if(n.length===0)return!0;if(n.length>t.length)return!1;for(let e=0;e<n.length;e++)if(t[e]!==n[e])return!1;return!0}return!1}function we(n,t){if(typeof t=="string"&&typeof n=="string")return t.endsWith(n);if(Array.isArray(n)&&Array.isArray(t)){if(n.length===0)return!0;if(n.length>t.length)return!1;for(let e=0;e<n.length;e++){const r=t.length-n.length+e;if(t[r]!==n[e])return!1}return!0}return!1}function Se(n,t){return t.match(n)}const be=c(Se);function Ee(...n){return async t=>{let e=t;for(const r of n)e=await r(e);return e}}function Oe(...n){return async t=>{let e=t;for(const r of n){if(h(e))return e;e=await r(e)}return e}}function Te(...n){return async t=>{let e=t;for(const r of n){if(h(e))return e;e=await r(e)}return e}}function O(n){return new Promise(t=>{setTimeout(t,n)})}function Me(n,t){return new Promise((e,r)=>{const u=setTimeout(()=>r(new Error(`Timed out after ${n}ms`)),n);t.then(o=>{clearTimeout(u),e(o)}).catch(o=>{clearTimeout(u),r(o)})})}const Ne=c(Me);function Pe(n,t,e=0){return(async()=>{let r=0;for(;;)try{return await t()}catch(u){if(r+=1,r>n)throw u;e>0&&await O(e)}})()}const ke=c(Pe);function ze(n,t){let e;return function(...u){e&&clearTimeout(e);const o=this;e=setTimeout(()=>{e=void 0,n.apply(o,u)},t)}}const Ie=c(ze);function We(n,t){let e;return function(...u){e||(n.apply(this,u),e=setTimeout(()=>{e=void 0},t))}}const De=c(We);function Le(n,t){let e,r=!1,u,o;const f=()=>{e=void 0,r&&u&&(r=!1,n.apply(o,u))};return function(...l){if(!e){n.apply(this,l),e=setTimeout(f,t);return}r=!0,u=l,o=this,clearTimeout(e),e=setTimeout(f,t)}}const _e=c(Le);function ve(n,t){let e=0,r=null,u=null;const o=(s,l)=>{e=Date.now(),n.apply(s,l)};return function(...s){const l=Date.now(),a=t-(l-e);a<=0?(u&&(clearTimeout(u),u=null),r=null,o(this,s)):(r=s,u||(u=setTimeout(()=>{u=null,r&&(o(this,r),r=null)},a)))}}const Ce=c(ve);function Ke(n){return t=>t==null?null:n(t)}function qe(n){return t=>{const e=[];for(const r of t){const u=n(r);u!=null&&e.push(u)}return e}}function Be(n){return t=>t??n}function Fe(n){try{return{ok:!0,value:n()}}catch(t){return{ok:!1,error:t}}}function Ve(n,t,e){return e==null?n():t(e)}const Re=c(Ve);function $e(n,t){if(!n)throw new Error(t??"Assertion failed")}const Ue=c($e);function je(n,t){if(!n)throw new Error(t??"Invariant failed")}const Ge=c(je);function Ze(n){return t=>(n?console.log(n,t):console.log(t),t)}i.SideEffect=d,i.SideEffectClass=d,i.add=Zt,i.append=Fn,i.assert=Ue,i.assoc=ht,i.assocPath=mt,i.ceil=ce,i.chunk=gn,i.clamp=Ut,i.complement=W,i.compose=k,i.concat=qn,i.cond=U,i.constant=L,i.curry=c,i.debounce=Ie,i.debounceLeading=De,i.debounceLeadingTrailing=_e,i.delay=O,i.dissoc=pt,i.dissocPath=St,i.div=xt,i.drop=hn,i.dropWhile=mn,i.endsWith=we,i.entries=kt,i.equals=E,i.every=sn,i.evolve=Wt,i.filter=Y,i.find=un,i.flatMap=en,i.flatten=$n,i.flattenDeep=Xn,i.flip=I,i.floor=ue,i.fold=Re,i.from=_,i.getOrElse=Be,i.groupBy=Wn,i.gt=Bt,i.gte=Ft,i.guard=H,i.has=Lt,i.hasPath=_t,i.head=Un,i.identity=D,i.ifElse=B,i.includes=jt,i.init=Zn,i.invariant=Ge,i.isEmpty=Kt,i.isNil=Ct,i.isSideEffect=h,i.isType=qt,i.join=he,i.keys=Nt,i.last=Gn,i.log=Ze,i.lt=Vt,i.lte=Rt,i.map=Q,i.mapMaybe=qe,i.mapValues=zt,i.match=be,i.matchSideEffect=T,i.max=re,i.maybe=Ke,i.mean=te,i.memoize=K,i.merge=Et,i.mergeAll=Mt,i.mergeDeep=Tt,i.min=ee,i.mul=Xt,i.omit=at,i.once=C,i.partial=z,i.partition=Qn,i.path=ut,i.pathOr=ot,i.pick=st,i.pipe=m,i.pipeAsync=Ee,i.pipeAsyncSideEffect=Oe,i.pipeAsyncSideEffectStrict=Te,i.pipeSideEffect=N,i.pipeSideEffectStrict=P,i.prepend=Rn,i.prop=xn,i.propOr=rt,i.propStrict=tt,i.randomInt=fe,i.range=Hn,i.reduce=nn,i.replace=me,i.result=Fe,i.retry=ke,i.round=ie,i.runPipeResult=M,i.scan=Cn,i.some=on,i.sort=zn,i.sortBy=Pn,i.split=ae,i.startsWith=Ae,i.sub=Jt,i.sum=ne,i.tail=jn,i.take=an,i.takeWhile=_n,i.tap=v,i.throttle=Ce,i.timeout=Ne,i.toLower=ge,i.toUpper=pe,i.trim=se,i.tryCatch=G,i.uniq=On,i.uniqBy=Mn,i.unless=$,i.unzip=En,i.values=Pt,i.when=V,i.zip=wn,i.zipIndex=Dn,i.zipWith=bn,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
|
|
2
2
|
//# sourceMappingURL=fp-pack.umd.js.map
|