fp-pack 0.4.0 → 0.6.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 +135 -47
- package/dist/fp-pack.umd.js +1 -1
- package/dist/fp-pack.umd.js.map +1 -1
- package/dist/implement/async/pipeAsync.d.ts +3 -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 +3 -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 +6 -0
- package/dist/implement/async/pipeAsyncSideEffectStrict.d.ts.map +1 -1
- package/dist/implement/async/pipeAsyncSideEffectStrict.mjs.map +1 -1
- package/dist/implement/composition/curry.d.ts +5 -5
- package/dist/implement/composition/curry.d.ts.map +1 -1
- package/dist/implement/composition/curry.mjs.map +1 -1
- package/dist/implement/composition/from.d.ts +5 -1
- package/dist/implement/composition/from.d.ts.map +1 -1
- package/dist/implement/composition/from.mjs +4 -3
- package/dist/implement/composition/from.mjs.map +1 -1
- package/dist/implement/composition/index.d.ts +3 -0
- package/dist/implement/composition/index.d.ts.map +1 -1
- package/dist/implement/composition/pipe.d.ts +3 -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 +38 -8
- package/dist/implement/composition/pipe.type-test.d.ts.map +1 -1
- package/dist/implement/composition/pipeSideEffect.d.ts +3 -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 +6 -0
- package/dist/implement/composition/pipeSideEffectStrict.d.ts.map +1 -1
- package/dist/implement/composition/pipeSideEffectStrict.mjs.map +1 -1
- package/dist/implement/composition/sideEffect.d.ts +1 -1
- package/dist/implement/composition/sideEffect.d.ts.map +1 -1
- package/dist/implement/composition/sideEffect.mjs.map +1 -1
- package/dist/implement/object/assocPath.d.ts +2 -1
- package/dist/implement/object/assocPath.d.ts.map +1 -1
- package/dist/implement/object/assocPath.mjs.map +1 -1
- package/dist/implement/object/dissocPath.d.ts +2 -1
- package/dist/implement/object/dissocPath.d.ts.map +1 -1
- package/dist/implement/object/dissocPath.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/path.d.ts +4 -2
- package/dist/implement/object/path.d.ts.map +1 -1
- package/dist/implement/object/path.mjs.map +1 -1
- package/dist/implement/object/pathKey.d.ts +2 -0
- package/dist/implement/object/pathKey.d.ts.map +1 -0
- package/dist/implement/object/pathOr.d.ts +5 -3
- package/dist/implement/object/pathOr.d.ts.map +1 -1
- package/dist/implement/object/pathOr.mjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/skills/fp-pack/SKILL.md +30 -20
- package/dist/skills/fp-pack.md +30 -20
- package/dist/stream/index.d.ts +1 -0
- package/dist/stream/index.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/implement/async/pipeAsync.ts +6 -0
- package/src/implement/async/pipeAsyncSideEffect.ts +7 -0
- package/src/implement/async/pipeAsyncSideEffectStrict.ts +10 -0
- package/src/implement/composition/curry.ts +5 -5
- package/src/implement/composition/from.ts +9 -2
- package/src/implement/composition/index.ts +3 -0
- package/src/implement/composition/pipe.ts +4 -0
- package/src/implement/composition/pipe.type-test.ts +67 -1
- package/src/implement/composition/pipeSideEffect.ts +5 -0
- package/src/implement/composition/pipeSideEffectStrict.ts +10 -0
- package/src/implement/composition/sideEffect.ts +1 -1
- package/src/implement/object/assocPath.ts +2 -2
- package/src/implement/object/dissocPath.ts +2 -2
- package/src/implement/object/index.ts +1 -0
- package/src/implement/object/path.ts +5 -3
- package/src/implement/object/pathKey.ts +1 -0
- package/src/implement/object/pathOr.ts +6 -4
- package/src/index.ts +3 -0
- package/src/stream/index.ts +1 -0
package/README.md
CHANGED
|
@@ -17,36 +17,50 @@ There's no framework and no heavy abstractions—just well-chosen helpers that m
|
|
|
17
17
|
|
|
18
18
|
---
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
<div align="center">
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
### 📚 [**Full Documentation**](https://superlucky84.github.io/fp-pack/)
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
- **Curry multi-argument functions** to make them pipe-friendly.
|
|
26
|
-
- **Fixed signatures** can use `curry(fn)` directly.
|
|
27
|
-
- **Generic or overloaded signatures** should be wrapped with an explicit type alias and a cast to preserve inference.
|
|
28
|
-
|
|
29
|
-
```typescript
|
|
30
|
-
// Fixed signature: curry is enough
|
|
31
|
-
function split(separator: string, str: string): string[] {
|
|
32
|
-
return str.split(separator);
|
|
33
|
-
}
|
|
34
|
-
export default curry(split);
|
|
24
|
+
</div>
|
|
35
25
|
|
|
36
|
-
|
|
37
|
-
type Chunk = {
|
|
38
|
-
(size: number): <T>(arr: T[]) => T[][];
|
|
39
|
-
<T>(size: number, arr: T[]): T[][];
|
|
40
|
-
};
|
|
26
|
+
---
|
|
41
27
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
28
|
+
## Table of Contents
|
|
29
|
+
|
|
30
|
+
- [Why fp-pack?](#why-fp-pack)
|
|
31
|
+
- [Design Principles](#design-principles)
|
|
32
|
+
- [Installation](#installation)
|
|
33
|
+
- [AI Agent Skills (Optional)](#ai-agent-skills-optional)
|
|
34
|
+
- [Quick Start](#quick-start)
|
|
35
|
+
- [Basic Pipe Composition](#basic-pipe-composition)
|
|
36
|
+
- [Async Operations with pipeAsync](#async-operations-with-pipeasync)
|
|
37
|
+
- [Object Transformation](#object-transformation)
|
|
38
|
+
- [Lazy Stream Processing](#lazy-stream-processing)
|
|
39
|
+
- [Custom Utility Authoring Guide](#custom-utility-authoring-guide-for-pipe)
|
|
40
|
+
- [API Reference](#api-reference)
|
|
41
|
+
- [Composition](#composition)
|
|
42
|
+
- [Control Flow](#control-flow)
|
|
43
|
+
- [Array](#array)
|
|
44
|
+
- [Object](#object)
|
|
45
|
+
- [Equality & Comparison](#equality--comparison)
|
|
46
|
+
- [Math](#math)
|
|
47
|
+
- [String](#string)
|
|
48
|
+
- [Async](#async)
|
|
49
|
+
- [Stream (Lazy Iterables)](#stream-lazy-iterables)
|
|
50
|
+
- [Nullable](#nullable)
|
|
51
|
+
- [Debug](#debug)
|
|
52
|
+
- [Key Concepts](#key-concepts)
|
|
53
|
+
- [SideEffect Pattern](#sideeffect-pattern)
|
|
54
|
+
- [Pipe vs PipeAsync](#pipe-vs-pipeasync)
|
|
55
|
+
- [SideEffect Composition Rule](#sideeffect-composition-rule)
|
|
56
|
+
- [Stream vs Array](#stream-vs-array)
|
|
57
|
+
- [What You Get](#what-you-get)
|
|
58
|
+
- [Import Paths](#import-paths)
|
|
59
|
+
- [Development](#development)
|
|
60
|
+
- [Acknowledgements](#acknowledgements)
|
|
61
|
+
- [License](#license)
|
|
46
62
|
|
|
47
|
-
|
|
48
|
-
export default curriedChunk;
|
|
49
|
-
```
|
|
63
|
+
---
|
|
50
64
|
|
|
51
65
|
## Why fp-pack?
|
|
52
66
|
|
|
@@ -56,9 +70,6 @@ export default curriedChunk;
|
|
|
56
70
|
- ⚡ **SideEffect Pattern**
|
|
57
71
|
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
72
|
|
|
59
|
-
- 💧 **Lazy Stream Processing**
|
|
60
|
-
Efficient iterable processing with `stream/*` functions for memory-conscious operations on large datasets.
|
|
61
|
-
|
|
62
73
|
- 📘 **JavaScript & TypeScript**
|
|
63
74
|
Works seamlessly in JavaScript. Written in TypeScript for robust type inference when you need it.
|
|
64
75
|
|
|
@@ -68,6 +79,9 @@ export default curriedChunk;
|
|
|
68
79
|
- 🪶 **Lightweight & Modular**
|
|
69
80
|
Zero dependencies and tree-shakeable modules.
|
|
70
81
|
|
|
82
|
+
- 💧 **Lazy Stream Processing**
|
|
83
|
+
Efficient iterable processing with `stream/*` functions for memory-conscious operations on large datasets.
|
|
84
|
+
|
|
71
85
|
---
|
|
72
86
|
|
|
73
87
|
## Design Principles
|
|
@@ -76,13 +90,13 @@ export default curriedChunk;
|
|
|
76
90
|
`pipe` (sync) and `pipeAsync` (async) are the primary composition tools. All utilities are designed to work seamlessly in pipe chains.
|
|
77
91
|
|
|
78
92
|
- **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. For strict union typing across branches, use `pipeSideEffectStrict` / `pipeAsyncSideEffectStrict`. Use `runPipeResult
|
|
93
|
+
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`/`matchSideEffect` **outside** the pipeline. If the result type is widened (e.g. `SideEffect<any>`), provide generics to recover a safe union. Use `isSideEffect` for precise runtime narrowing.
|
|
80
94
|
|
|
81
95
|
- **Immutable & Pure by default**
|
|
82
96
|
Core utilities avoid mutations and side effects. Any exception is explicitly named (e.g. `tap`, `log`).
|
|
83
97
|
|
|
84
|
-
- **
|
|
85
|
-
|
|
98
|
+
- **Stream functions**
|
|
99
|
+
Stream helpers (`stream/*`) provide lazy evaluation for large datasets.
|
|
86
100
|
|
|
87
101
|
- **Curried by design**
|
|
88
102
|
All multi-argument utility functions are curried or behave like curried functions, enabling partial application and point-free style. This design allows elegant composition in pipes without awkward wrapper functions.
|
|
@@ -100,6 +114,31 @@ export default curriedChunk;
|
|
|
100
114
|
// [4, 8, 12, 16, 20]
|
|
101
115
|
```
|
|
102
116
|
|
|
117
|
+
- **Data-first with `from`**
|
|
118
|
+
Use `from` to inject constant values in pipelines and enable data-first patterns. Particularly useful with `ifElse` and `cond` for constant branches.
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
import { pipe, ifElse, from, filter, map } from 'fp-pack';
|
|
122
|
+
|
|
123
|
+
// Use from to return constant values in conditional branches
|
|
124
|
+
const getStatusLabel = ifElse(
|
|
125
|
+
(score: number) => score >= 60,
|
|
126
|
+
from('pass'), // Constant value instead of (score) => 'pass'
|
|
127
|
+
from('fail')
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
const result = getStatusLabel(75); // 'pass'
|
|
131
|
+
|
|
132
|
+
// Data-first pattern: inject data into pipeline
|
|
133
|
+
const processWithData = pipe(
|
|
134
|
+
from([1, 2, 3, 4, 5]),
|
|
135
|
+
filter((n: number) => n % 2 === 0),
|
|
136
|
+
map(n => n * 2)
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
const processed = processWithData(); // [4, 8]
|
|
140
|
+
```
|
|
141
|
+
|
|
103
142
|
## Installation
|
|
104
143
|
|
|
105
144
|
```bash
|
|
@@ -158,6 +197,8 @@ Once configured, AI assistants will automatically apply fp-pack coding patterns
|
|
|
158
197
|
|
|
159
198
|
### Basic Pipe Composition
|
|
160
199
|
|
|
200
|
+
`pipe` is a pure function composition tool - it takes functions and returns a new function that applies data to those composed functions.
|
|
201
|
+
|
|
161
202
|
```typescript
|
|
162
203
|
import { pipe, map, filter, take } from 'fp-pack';
|
|
163
204
|
|
|
@@ -171,6 +212,21 @@ const processUsers = pipe(
|
|
|
171
212
|
const result = processUsers(users);
|
|
172
213
|
```
|
|
173
214
|
|
|
215
|
+
**Data-first with `from` (optional)**: While `pipe` is designed for composing functions, you can optionally use `from` to inject data directly into pipelines for convenience:
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
import { pipe, from, filter, map } from 'fp-pack';
|
|
219
|
+
|
|
220
|
+
// Optional: data-first pattern with from
|
|
221
|
+
const processData = pipe(
|
|
222
|
+
from([1, 2, 3, 4, 5]),
|
|
223
|
+
filter((n: number) => n % 2 === 0),
|
|
224
|
+
map(n => n * 2)
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
const result = processData(); // [4, 8]
|
|
228
|
+
```
|
|
229
|
+
|
|
174
230
|
### Async Operations with pipeAsync
|
|
175
231
|
|
|
176
232
|
```typescript
|
|
@@ -219,6 +275,37 @@ const processLargeDataset = pipe(
|
|
|
219
275
|
const result = processLargeDataset(range(1, 1000000));
|
|
220
276
|
```
|
|
221
277
|
|
|
278
|
+
## Custom Utility Authoring Guide (for pipe)
|
|
279
|
+
|
|
280
|
+
When you write your own helpers that should compose cleanly with `pipe`/`pipeAsync`, follow these conventions:
|
|
281
|
+
|
|
282
|
+
- **Data-last arguments** so partial application works naturally in pipelines.
|
|
283
|
+
- **Curry multi-argument functions** to make them pipe-friendly.
|
|
284
|
+
- **Fixed signatures** can use `curry(fn)` directly.
|
|
285
|
+
- **Generic or overloaded signatures** should be wrapped with an explicit type alias and a cast to preserve inference.
|
|
286
|
+
|
|
287
|
+
```typescript
|
|
288
|
+
// Fixed signature: curry is enough
|
|
289
|
+
function split(separator: string, str: string): string[] {
|
|
290
|
+
return str.split(separator);
|
|
291
|
+
}
|
|
292
|
+
export default curry(split);
|
|
293
|
+
|
|
294
|
+
// Generic signature: add a type alias for the curried form
|
|
295
|
+
type Chunk = {
|
|
296
|
+
(size: number): <T>(arr: T[]) => T[][];
|
|
297
|
+
<T>(size: number, arr: T[]): T[][];
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
function chunk<T>(size: number, arr: T[]): T[][] {
|
|
301
|
+
// ...
|
|
302
|
+
return [];
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const curriedChunk = curry(chunk) as Chunk;
|
|
306
|
+
export default curriedChunk;
|
|
307
|
+
```
|
|
308
|
+
|
|
222
309
|
## API Reference
|
|
223
310
|
|
|
224
311
|
### Composition
|
|
@@ -242,7 +329,7 @@ Functions for composing and transforming other functions.
|
|
|
242
329
|
- **SideEffect** - Side effect container for SideEffect-aware pipelines
|
|
243
330
|
- **isSideEffect** - Type guard for runtime checking whether a value is a SideEffect
|
|
244
331
|
- **matchSideEffect** - Pattern match on value or SideEffect
|
|
245
|
-
- **runPipeResult** - Execute SideEffect or return value (call OUTSIDE pipelines).
|
|
332
|
+
- **runPipeResult** - Execute SideEffect or return value (call OUTSIDE pipelines). If the input is widened to `SideEffect<any>`/`any`, the result becomes `any`; provide explicit type parameters `runPipeResult<SuccessType, ErrorType>` to recover a safe union. Use `isSideEffect` for precise type narrowing.
|
|
246
333
|
|
|
247
334
|
### Control Flow
|
|
248
335
|
|
|
@@ -496,34 +583,35 @@ const processNumbers = pipeSideEffect(
|
|
|
496
583
|
|
|
497
584
|
const oddsDoubled = processNumbers([1, 2, 3, 4, 5]);
|
|
498
585
|
|
|
499
|
-
// ✅ CORRECT: Use isSideEffect for type checking
|
|
586
|
+
// ✅ CORRECT: Use isSideEffect for type checking
|
|
500
587
|
if (!isSideEffect(oddsDoubled)) {
|
|
501
588
|
// TypeScript knows: oddsDoubled is number[]
|
|
502
589
|
const sum: number = oddsDoubled.reduce((a, b) => a + b, 0);
|
|
503
590
|
console.log(`Sum: ${sum}`); // sum: number
|
|
504
591
|
} else {
|
|
505
|
-
//
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
console.log(`Error: ${error}`); // error: number[] | string
|
|
592
|
+
// pipeSideEffect widens SideEffect to any, so runPipeResult becomes any here
|
|
593
|
+
const error = runPipeResult(oddsDoubled);
|
|
594
|
+
console.log(`Error: ${error}`); // error: any
|
|
509
595
|
}
|
|
510
596
|
|
|
511
|
-
//
|
|
512
|
-
const
|
|
597
|
+
// ⚠️ If the result type is widened, inference is lost
|
|
598
|
+
const widened: number[] | SideEffect<any> = oddsDoubled;
|
|
599
|
+
const unsafeResult = runPipeResult(widened); // result: any
|
|
513
600
|
|
|
514
|
-
// ✅ CORRECT: Provide generics to
|
|
515
|
-
const
|
|
601
|
+
// ✅ CORRECT: Provide generics to recover a safe union
|
|
602
|
+
const safeResult = runPipeResult<number[], string>(oddsDoubled); // result: number[] | string (union type - safe but not narrowed)
|
|
516
603
|
```
|
|
517
604
|
|
|
518
605
|
**⚠️ CRITICAL: runPipeResult Type Safety**
|
|
519
606
|
|
|
520
607
|
`runPipeResult<T, R=any>` has a default type parameter `R=any`. This means:
|
|
521
608
|
|
|
522
|
-
-
|
|
523
|
-
-
|
|
524
|
-
- ✅ **With
|
|
609
|
+
- ✅ **Precise input types**: `T | SideEffect<'E'>` preserves `T | 'E'` without extra annotations.
|
|
610
|
+
- ⚠️ **Widened inputs**: `T | SideEffect<any>` (or `any`) collapses to `any`.
|
|
611
|
+
- ✅ **With generics**: `runPipeResult<SuccessType, ErrorType>(result)` restores a safe union when inference is lost.
|
|
612
|
+
- ✅ **With isSideEffect**: Use for runtime checking and precise narrowing.
|
|
525
613
|
|
|
526
|
-
|
|
614
|
+
Provide generics when inference is lost; prefer `isSideEffect` for precise narrowing.
|
|
527
615
|
|
|
528
616
|
### Pipe vs PipeAsync
|
|
529
617
|
|
|
@@ -672,12 +760,12 @@ pnpm dev
|
|
|
672
760
|
|
|
673
761
|
## Acknowledgements
|
|
674
762
|
|
|
675
|
-
fp-pack
|
|
763
|
+
fp-pack draws inspiration from excellent functional programming libraries in the JavaScript ecosystem:
|
|
676
764
|
|
|
677
765
|
- **[Ramda](https://ramdajs.com/)** - A practical functional library that pioneered many of the patterns we use today
|
|
678
766
|
- **[FxJS](https://github.com/marpple/FxJS)** and **[FxTS](https://github.com/marpple/FxTS)** - Inspired by their exceptional combination of lazy evaluation and functional tooling patterns
|
|
679
767
|
|
|
680
|
-
|
|
768
|
+
We're deeply grateful for their influence. Our implementation explores different approaches using generator functions, the SideEffect pattern, and pipe-first composition.
|
|
681
769
|
|
|
682
770
|
## License
|
|
683
771
|
|
package/dist/fp-pack.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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"})}));
|
|
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 _(n){return n}function D(n){return()=>n}function L(n){const t=e=>n;return Object.defineProperty(t,"__from",{value:!0}),t}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 _n(n){return n.map((t,e)=>[e,t])}function Dn(n,t){const e=[];for(const r of t){if(!n(r))break;e.push(r)}return e}const Ln=c(Dn);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 _t(n,t){return Object.prototype.hasOwnProperty.call(t,n)}const Dt=c(_t);function Lt(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 _e=c(We);function De(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 Le=c(De);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=D,i.curry=c,i.debounce=Ie,i.debounceLeading=_e,i.debounceLeadingTrailing=Le,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=L,i.getOrElse=Be,i.groupBy=Wn,i.gt=Bt,i.gte=Ft,i.guard=H,i.has=Dt,i.hasPath=Lt,i.head=Un,i.identity=_,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=Ln,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=_n,i.zipWith=bn,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
|
|
2
2
|
//# sourceMappingURL=fp-pack.umd.js.map
|