effect 4.0.0-beta.18 → 4.0.0-beta.19
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/dist/Array.d.ts +127 -299
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +102 -62
- package/dist/Array.js.map +1 -1
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +5 -4
- package/dist/Cache.js.map +1 -1
- package/dist/Channel.d.ts +97 -11
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +72 -29
- package/dist/Channel.js.map +1 -1
- package/dist/Chunk.d.ts +54 -247
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +36 -67
- package/dist/Chunk.js.map +1 -1
- package/dist/Effect.d.ts +304 -336
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +85 -26
- package/dist/Effect.js.map +1 -1
- package/dist/Filter.d.ts +0 -33
- package/dist/Filter.d.ts.map +1 -1
- package/dist/Filter.js +0 -13
- package/dist/Filter.js.map +1 -1
- package/dist/HashMap.d.ts +15 -14
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashMap.js +4 -4
- package/dist/HashMap.js.map +1 -1
- package/dist/Iterable.d.ts +40 -39
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +94 -22
- package/dist/Iterable.js.map +1 -1
- package/dist/Option.d.ts +22 -15
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +14 -7
- package/dist/Option.js.map +1 -1
- package/dist/Pull.d.ts.map +1 -1
- package/dist/Pull.js +1 -1
- package/dist/Pull.js.map +1 -1
- package/dist/Record.d.ts +24 -120
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +21 -41
- package/dist/Record.js.map +1 -1
- package/dist/Sink.d.ts +11 -11
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +53 -6
- package/dist/Sink.js.map +1 -1
- package/dist/Stream.d.ts +198 -386
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +103 -59
- package/dist/Stream.js.map +1 -1
- package/dist/Trie.d.ts +18 -17
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Trie.js +5 -5
- package/dist/Trie.js.map +1 -1
- package/dist/TxHashMap.d.ts +27 -26
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +8 -8
- package/dist/TxHashMap.js.map +1 -1
- package/dist/internal/effect.js +99 -42
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/hashMap.js +3 -2
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/trie.js +5 -4
- package/dist/internal/trie.js.map +1 -1
- package/dist/unstable/cli/Command.js +1 -1
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cluster/K8sHttpClient.js +4 -4
- package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
- package/dist/unstable/cluster/Sharding.js +1 -1
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/encoding/Sse.js +1 -1
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +1 -2
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +3 -3
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/package.json +1 -1
- package/src/Array.ts +190 -342
- package/src/Cache.ts +6 -5
- package/src/Channel.ts +506 -102
- package/src/Chunk.ts +81 -268
- package/src/Effect.ts +399 -401
- package/src/Filter.ts +0 -57
- package/src/HashMap.ts +15 -14
- package/src/Iterable.ts +105 -50
- package/src/Option.ts +30 -20
- package/src/Pull.ts +1 -1
- package/src/Record.ts +43 -152
- package/src/Sink.ts +75 -23
- package/src/Stream.ts +442 -502
- package/src/Trie.ts +18 -17
- package/src/TxHashMap.ts +29 -28
- package/src/internal/effect.ts +368 -163
- package/src/internal/hashMap.ts +7 -5
- package/src/internal/trie.ts +16 -9
- package/src/unstable/cli/Command.ts +2 -2
- package/src/unstable/cluster/K8sHttpClient.ts +4 -4
- package/src/unstable/cluster/Sharding.ts +1 -1
- package/src/unstable/encoding/Sse.ts +1 -1
- package/src/unstable/rpc/RpcServer.ts +1 -7
- package/src/unstable/socket/Socket.ts +9 -11
package/dist/Array.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Equivalence from "./Equivalence.ts";
|
|
2
|
-
import * as Filter from "./Filter.ts";
|
|
2
|
+
import type * as Filter from "./Filter.ts";
|
|
3
3
|
import type { LazyArg } from "./Function.ts";
|
|
4
4
|
import type { TypeLambda } from "./HKT.ts";
|
|
5
5
|
import * as Option from "./Option.ts";
|
|
@@ -1850,7 +1850,7 @@ export declare const takeWhile: {
|
|
|
1850
1850
|
* @category getters
|
|
1851
1851
|
* @since 2.0.0
|
|
1852
1852
|
*/
|
|
1853
|
-
<A, B
|
|
1853
|
+
<A, B extends A>(self: Iterable<A>, refinement: (a: A, i: number) => a is B): Array<B>;
|
|
1854
1854
|
/**
|
|
1855
1855
|
* Takes elements from the start while the predicate holds, stopping at the
|
|
1856
1856
|
* first element that fails.
|
|
@@ -1873,53 +1873,38 @@ export declare const takeWhile: {
|
|
|
1873
1873
|
* @category getters
|
|
1874
1874
|
* @since 2.0.0
|
|
1875
1875
|
*/
|
|
1876
|
-
<A
|
|
1876
|
+
<A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): Array<A>;
|
|
1877
|
+
};
|
|
1878
|
+
/**
|
|
1879
|
+
* Takes elements from the start while a `Filter` succeeds, collecting transformed values.
|
|
1880
|
+
*
|
|
1881
|
+
* - The filter receives `(element, index)`.
|
|
1882
|
+
* - Stops at the first filter failure.
|
|
1883
|
+
*
|
|
1884
|
+
* @category getters
|
|
1885
|
+
* @since 4.0.0
|
|
1886
|
+
*/
|
|
1887
|
+
export declare const takeWhileFilter: {
|
|
1877
1888
|
/**
|
|
1878
|
-
* Takes elements from the start while
|
|
1879
|
-
* first element that fails.
|
|
1880
|
-
*
|
|
1881
|
-
* - Supports refinements for type narrowing.
|
|
1882
|
-
* - The predicate receives `(element, index)`.
|
|
1883
|
-
*
|
|
1884
|
-
* **Example** (Taking while condition holds)
|
|
1889
|
+
* Takes elements from the start while a `Filter` succeeds, collecting transformed values.
|
|
1885
1890
|
*
|
|
1886
|
-
*
|
|
1887
|
-
*
|
|
1888
|
-
*
|
|
1889
|
-
* console.log(Array.takeWhile([1, 3, 2, 4, 1, 2], (x) => x < 4)) // [1, 3, 2]
|
|
1890
|
-
* ```
|
|
1891
|
-
*
|
|
1892
|
-
* @see {@link take} — take a fixed count
|
|
1893
|
-
* @see {@link dropWhile} — drop while predicate holds
|
|
1894
|
-
* @see {@link span} — split into matching prefix + rest
|
|
1891
|
+
* - The filter receives `(element, index)`.
|
|
1892
|
+
* - Stops at the first filter failure.
|
|
1895
1893
|
*
|
|
1896
1894
|
* @category getters
|
|
1897
|
-
* @since
|
|
1895
|
+
* @since 4.0.0
|
|
1898
1896
|
*/
|
|
1899
|
-
<A>(
|
|
1897
|
+
<A, B, X>(f: Filter.Filter<NoInfer<A>, B, X, [i: number]>): (self: Iterable<A>) => Array<B>;
|
|
1900
1898
|
/**
|
|
1901
|
-
* Takes elements from the start while
|
|
1902
|
-
* first element that fails.
|
|
1903
|
-
*
|
|
1904
|
-
* - Supports refinements for type narrowing.
|
|
1905
|
-
* - The predicate receives `(element, index)`.
|
|
1906
|
-
*
|
|
1907
|
-
* **Example** (Taking while condition holds)
|
|
1899
|
+
* Takes elements from the start while a `Filter` succeeds, collecting transformed values.
|
|
1908
1900
|
*
|
|
1909
|
-
*
|
|
1910
|
-
*
|
|
1911
|
-
*
|
|
1912
|
-
* console.log(Array.takeWhile([1, 3, 2, 4, 1, 2], (x) => x < 4)) // [1, 3, 2]
|
|
1913
|
-
* ```
|
|
1914
|
-
*
|
|
1915
|
-
* @see {@link take} — take a fixed count
|
|
1916
|
-
* @see {@link dropWhile} — drop while predicate holds
|
|
1917
|
-
* @see {@link span} — split into matching prefix + rest
|
|
1901
|
+
* - The filter receives `(element, index)`.
|
|
1902
|
+
* - Stops at the first filter failure.
|
|
1918
1903
|
*
|
|
1919
1904
|
* @category getters
|
|
1920
|
-
* @since
|
|
1905
|
+
* @since 4.0.0
|
|
1921
1906
|
*/
|
|
1922
|
-
<A, B, X>(self: Iterable<A>, f: Filter.Filter<A, B, X>): Array<B>;
|
|
1907
|
+
<A, B, X>(self: Iterable<A>, f: Filter.Filter<A, B, X, [i: number]>): Array<B>;
|
|
1923
1908
|
};
|
|
1924
1909
|
/**
|
|
1925
1910
|
* Splits an iterable into two arrays: the longest prefix where the predicate
|
|
@@ -2229,47 +2214,38 @@ export declare const dropWhile: {
|
|
|
2229
2214
|
* @category getters
|
|
2230
2215
|
* @since 2.0.0
|
|
2231
2216
|
*/
|
|
2232
|
-
<A
|
|
2217
|
+
<A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): Array<A>;
|
|
2218
|
+
};
|
|
2219
|
+
/**
|
|
2220
|
+
* Drops elements from the start while a `Filter` succeeds.
|
|
2221
|
+
*
|
|
2222
|
+
* - The filter receives `(element, index)`.
|
|
2223
|
+
* - Returns the remaining original elements after the first filter failure.
|
|
2224
|
+
*
|
|
2225
|
+
* @category getters
|
|
2226
|
+
* @since 4.0.0
|
|
2227
|
+
*/
|
|
2228
|
+
export declare const dropWhileFilter: {
|
|
2233
2229
|
/**
|
|
2234
|
-
* Drops elements from the start while
|
|
2235
|
-
*
|
|
2236
|
-
* - The predicate receives `(element, index)`.
|
|
2230
|
+
* Drops elements from the start while a `Filter` succeeds.
|
|
2237
2231
|
*
|
|
2238
|
-
*
|
|
2239
|
-
*
|
|
2240
|
-
* ```ts
|
|
2241
|
-
* import { Array } from "effect"
|
|
2242
|
-
*
|
|
2243
|
-
* console.log(Array.dropWhile([1, 2, 3, 4, 5], (x) => x < 4)) // [4, 5]
|
|
2244
|
-
* ```
|
|
2245
|
-
*
|
|
2246
|
-
* @see {@link takeWhile} — keep the matching prefix instead
|
|
2247
|
-
* @see {@link drop} — drop a fixed count
|
|
2232
|
+
* - The filter receives `(element, index)`.
|
|
2233
|
+
* - Returns the remaining original elements after the first filter failure.
|
|
2248
2234
|
*
|
|
2249
2235
|
* @category getters
|
|
2250
|
-
* @since
|
|
2236
|
+
* @since 4.0.0
|
|
2251
2237
|
*/
|
|
2252
|
-
<A>(
|
|
2238
|
+
<A, B, X>(f: Filter.Filter<NoInfer<A>, B, X, [i: number]>): (self: Iterable<A>) => Array<A>;
|
|
2253
2239
|
/**
|
|
2254
|
-
* Drops elements from the start while
|
|
2240
|
+
* Drops elements from the start while a `Filter` succeeds.
|
|
2255
2241
|
*
|
|
2256
|
-
* - The
|
|
2257
|
-
*
|
|
2258
|
-
* **Example** (Dropping while condition holds)
|
|
2259
|
-
*
|
|
2260
|
-
* ```ts
|
|
2261
|
-
* import { Array } from "effect"
|
|
2262
|
-
*
|
|
2263
|
-
* console.log(Array.dropWhile([1, 2, 3, 4, 5], (x) => x < 4)) // [4, 5]
|
|
2264
|
-
* ```
|
|
2265
|
-
*
|
|
2266
|
-
* @see {@link takeWhile} — keep the matching prefix instead
|
|
2267
|
-
* @see {@link drop} — drop a fixed count
|
|
2242
|
+
* - The filter receives `(element, index)`.
|
|
2243
|
+
* - Returns the remaining original elements after the first filter failure.
|
|
2268
2244
|
*
|
|
2269
2245
|
* @category getters
|
|
2270
|
-
* @since
|
|
2246
|
+
* @since 4.0.0
|
|
2271
2247
|
*/
|
|
2272
|
-
<A, B, X>(self: Iterable<A>, f: Filter.Filter<A, B, X>): Array<A>;
|
|
2248
|
+
<A, B, X>(self: Iterable<A>, f: Filter.Filter<A, B, X, [i: number]>): Array<A>;
|
|
2273
2249
|
};
|
|
2274
2250
|
/**
|
|
2275
2251
|
* Returns the index of the first element matching the predicate, or `undefined`
|
|
@@ -5520,82 +5496,6 @@ export declare const flatMap: {
|
|
|
5520
5496
|
* @since 2.0.0
|
|
5521
5497
|
*/
|
|
5522
5498
|
export declare const flatten: <const S extends ReadonlyArray<ReadonlyArray<any>>>(self: S) => ReadonlyArray.Flatten<S>;
|
|
5523
|
-
/**
|
|
5524
|
-
* Maps each element to a `Result`, then separates failures and successes into
|
|
5525
|
-
* two arrays.
|
|
5526
|
-
*
|
|
5527
|
-
* - Returns `[failures, successes]`.
|
|
5528
|
-
*
|
|
5529
|
-
* **Example** (Partitioning by Result)
|
|
5530
|
-
*
|
|
5531
|
-
* ```ts
|
|
5532
|
-
* import { Array, Result } from "effect"
|
|
5533
|
-
*
|
|
5534
|
-
* const result = Array.partitionMap(
|
|
5535
|
-
* [1, 2, 3, 4, 5],
|
|
5536
|
-
* (x) => x % 2 === 0 ? Result.succeed(x) : Result.fail(x)
|
|
5537
|
-
* )
|
|
5538
|
-
* console.log(result) // [[1, 3, 5], [2, 4]]
|
|
5539
|
-
* ```
|
|
5540
|
-
*
|
|
5541
|
-
* @see {@link partition} — partition by predicate
|
|
5542
|
-
* @see {@link separate} — partition an array of Results
|
|
5543
|
-
*
|
|
5544
|
-
* @category filtering
|
|
5545
|
-
* @since 2.0.0
|
|
5546
|
-
*/
|
|
5547
|
-
export declare const partitionMap: {
|
|
5548
|
-
/**
|
|
5549
|
-
* Maps each element to a `Result`, then separates failures and successes into
|
|
5550
|
-
* two arrays.
|
|
5551
|
-
*
|
|
5552
|
-
* - Returns `[failures, successes]`.
|
|
5553
|
-
*
|
|
5554
|
-
* **Example** (Partitioning by Result)
|
|
5555
|
-
*
|
|
5556
|
-
* ```ts
|
|
5557
|
-
* import { Array, Result } from "effect"
|
|
5558
|
-
*
|
|
5559
|
-
* const result = Array.partitionMap(
|
|
5560
|
-
* [1, 2, 3, 4, 5],
|
|
5561
|
-
* (x) => x % 2 === 0 ? Result.succeed(x) : Result.fail(x)
|
|
5562
|
-
* )
|
|
5563
|
-
* console.log(result) // [[1, 3, 5], [2, 4]]
|
|
5564
|
-
* ```
|
|
5565
|
-
*
|
|
5566
|
-
* @see {@link partition} — partition by predicate
|
|
5567
|
-
* @see {@link separate} — partition an array of Results
|
|
5568
|
-
*
|
|
5569
|
-
* @category filtering
|
|
5570
|
-
* @since 2.0.0
|
|
5571
|
-
*/
|
|
5572
|
-
<A, B, C>(f: (a: A, i: number) => Result.Result<C, B>): (self: Iterable<A>) => [fails: Array<B>, successes: Array<C>];
|
|
5573
|
-
/**
|
|
5574
|
-
* Maps each element to a `Result`, then separates failures and successes into
|
|
5575
|
-
* two arrays.
|
|
5576
|
-
*
|
|
5577
|
-
* - Returns `[failures, successes]`.
|
|
5578
|
-
*
|
|
5579
|
-
* **Example** (Partitioning by Result)
|
|
5580
|
-
*
|
|
5581
|
-
* ```ts
|
|
5582
|
-
* import { Array, Result } from "effect"
|
|
5583
|
-
*
|
|
5584
|
-
* const result = Array.partitionMap(
|
|
5585
|
-
* [1, 2, 3, 4, 5],
|
|
5586
|
-
* (x) => x % 2 === 0 ? Result.succeed(x) : Result.fail(x)
|
|
5587
|
-
* )
|
|
5588
|
-
* console.log(result) // [[1, 3, 5], [2, 4]]
|
|
5589
|
-
* ```
|
|
5590
|
-
*
|
|
5591
|
-
* @see {@link partition} — partition by predicate
|
|
5592
|
-
* @see {@link separate} — partition an array of Results
|
|
5593
|
-
*
|
|
5594
|
-
* @category filtering
|
|
5595
|
-
* @since 2.0.0
|
|
5596
|
-
*/
|
|
5597
|
-
<A, B, C>(self: Iterable<A>, f: (a: A, i: number) => Result.Result<C, B>): [fails: Array<B>, successes: Array<C>];
|
|
5598
|
-
};
|
|
5599
5499
|
/**
|
|
5600
5500
|
* Extracts all `Some` values from an iterable of `Option`s, discarding `None`s.
|
|
5601
5501
|
*
|
|
@@ -5655,65 +5555,89 @@ export declare const getFailures: <T extends Iterable<Result.Result<any, any>>>(
|
|
|
5655
5555
|
*/
|
|
5656
5556
|
export declare const getSuccesses: <T extends Iterable<Result.Result<any, any>>>(self: T) => Array<Result.Result.Success<ReadonlyArray.Infer<T>>>;
|
|
5657
5557
|
/**
|
|
5658
|
-
* Keeps
|
|
5558
|
+
* Keeps transformed values for elements where a `Filter` succeeds.
|
|
5659
5559
|
*
|
|
5660
|
-
* - The
|
|
5661
|
-
* -
|
|
5560
|
+
* - The filter receives `(element, index)`.
|
|
5561
|
+
* - Failures are discarded.
|
|
5662
5562
|
*
|
|
5663
|
-
* **Example** (
|
|
5563
|
+
* **Example** (Filter and transform)
|
|
5664
5564
|
*
|
|
5665
5565
|
* ```ts
|
|
5666
|
-
* import { Array } from "effect"
|
|
5566
|
+
* import { Array, Result } from "effect"
|
|
5667
5567
|
*
|
|
5668
|
-
* console.log(Array.
|
|
5568
|
+
* console.log(Array.filterMap([1, 2, 3, 4], (n) => n % 2 === 0 ? Result.succeed(n * 10) : Result.failVoid))
|
|
5569
|
+
* // [20, 40]
|
|
5669
5570
|
* ```
|
|
5670
5571
|
*
|
|
5671
|
-
* @see {@link
|
|
5572
|
+
* @see {@link filter} — keep original elements matching a predicate
|
|
5672
5573
|
*
|
|
5673
5574
|
* @category filtering
|
|
5674
|
-
* @since
|
|
5575
|
+
* @since 4.0.0
|
|
5675
5576
|
*/
|
|
5676
|
-
export declare const
|
|
5577
|
+
export declare const filterMap: {
|
|
5677
5578
|
/**
|
|
5678
|
-
* Keeps
|
|
5579
|
+
* Keeps transformed values for elements where a `Filter` succeeds.
|
|
5679
5580
|
*
|
|
5680
|
-
* - The
|
|
5681
|
-
* -
|
|
5581
|
+
* - The filter receives `(element, index)`.
|
|
5582
|
+
* - Failures are discarded.
|
|
5682
5583
|
*
|
|
5683
|
-
* **Example** (
|
|
5584
|
+
* **Example** (Filter and transform)
|
|
5684
5585
|
*
|
|
5685
5586
|
* ```ts
|
|
5686
|
-
* import { Array } from "effect"
|
|
5587
|
+
* import { Array, Result } from "effect"
|
|
5687
5588
|
*
|
|
5688
|
-
* console.log(Array.
|
|
5589
|
+
* console.log(Array.filterMap([1, 2, 3, 4], (n) => n % 2 === 0 ? Result.succeed(n * 10) : Result.failVoid))
|
|
5590
|
+
* // [20, 40]
|
|
5689
5591
|
* ```
|
|
5690
5592
|
*
|
|
5691
|
-
* @see {@link
|
|
5593
|
+
* @see {@link filter} — keep original elements matching a predicate
|
|
5692
5594
|
*
|
|
5693
5595
|
* @category filtering
|
|
5694
|
-
* @since
|
|
5596
|
+
* @since 4.0.0
|
|
5695
5597
|
*/
|
|
5696
|
-
<A, B
|
|
5598
|
+
<A, B, X>(f: Filter.Filter<NoInfer<A>, B, X, [i: number]>): (self: Iterable<A>) => Array<B>;
|
|
5697
5599
|
/**
|
|
5698
|
-
* Keeps
|
|
5600
|
+
* Keeps transformed values for elements where a `Filter` succeeds.
|
|
5699
5601
|
*
|
|
5700
|
-
* - The
|
|
5701
|
-
* -
|
|
5602
|
+
* - The filter receives `(element, index)`.
|
|
5603
|
+
* - Failures are discarded.
|
|
5702
5604
|
*
|
|
5703
|
-
* **Example** (
|
|
5605
|
+
* **Example** (Filter and transform)
|
|
5704
5606
|
*
|
|
5705
5607
|
* ```ts
|
|
5706
|
-
* import { Array } from "effect"
|
|
5608
|
+
* import { Array, Result } from "effect"
|
|
5707
5609
|
*
|
|
5708
|
-
* console.log(Array.
|
|
5610
|
+
* console.log(Array.filterMap([1, 2, 3, 4], (n) => n % 2 === 0 ? Result.succeed(n * 10) : Result.failVoid))
|
|
5611
|
+
* // [20, 40]
|
|
5709
5612
|
* ```
|
|
5710
5613
|
*
|
|
5711
|
-
* @see {@link
|
|
5614
|
+
* @see {@link filter} — keep original elements matching a predicate
|
|
5712
5615
|
*
|
|
5713
5616
|
* @category filtering
|
|
5714
|
-
* @since
|
|
5617
|
+
* @since 4.0.0
|
|
5715
5618
|
*/
|
|
5716
|
-
<A>(
|
|
5619
|
+
<A, B, X>(self: Iterable<A>, f: Filter.Filter<A, B, X, [i: number]>): Array<B>;
|
|
5620
|
+
};
|
|
5621
|
+
/**
|
|
5622
|
+
* Keeps only elements satisfying a predicate (or refinement).
|
|
5623
|
+
*
|
|
5624
|
+
* - The predicate receives `(element, index)`.
|
|
5625
|
+
* - Supports refinements for type narrowing.
|
|
5626
|
+
*
|
|
5627
|
+
* **Example** (Filtering even numbers)
|
|
5628
|
+
*
|
|
5629
|
+
* ```ts
|
|
5630
|
+
* import { Array } from "effect"
|
|
5631
|
+
*
|
|
5632
|
+
* console.log(Array.filter([1, 2, 3, 4], (x) => x % 2 === 0)) // [2, 4]
|
|
5633
|
+
* ```
|
|
5634
|
+
*
|
|
5635
|
+
* @see {@link partition} — split into matching and non-matching
|
|
5636
|
+
*
|
|
5637
|
+
* @category filtering
|
|
5638
|
+
* @since 2.0.0
|
|
5639
|
+
*/
|
|
5640
|
+
export declare const filter: {
|
|
5717
5641
|
/**
|
|
5718
5642
|
* Keeps only elements satisfying a predicate (or refinement).
|
|
5719
5643
|
*
|
|
@@ -5733,7 +5657,7 @@ export declare const filter: {
|
|
|
5733
5657
|
* @category filtering
|
|
5734
5658
|
* @since 2.0.0
|
|
5735
5659
|
*/
|
|
5736
|
-
<A, B
|
|
5660
|
+
<A, B extends A>(refinement: (a: NoInfer<A>, i: number) => a is B): (self: Iterable<A>) => Array<B>;
|
|
5737
5661
|
/**
|
|
5738
5662
|
* Keeps only elements satisfying a predicate (or refinement).
|
|
5739
5663
|
*
|
|
@@ -5753,7 +5677,7 @@ export declare const filter: {
|
|
|
5753
5677
|
* @category filtering
|
|
5754
5678
|
* @since 2.0.0
|
|
5755
5679
|
*/
|
|
5756
|
-
<A
|
|
5680
|
+
<A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: Iterable<A>) => Array<A>;
|
|
5757
5681
|
/**
|
|
5758
5682
|
* Keeps only elements satisfying a predicate (or refinement).
|
|
5759
5683
|
*
|
|
@@ -5773,7 +5697,7 @@ export declare const filter: {
|
|
|
5773
5697
|
* @category filtering
|
|
5774
5698
|
* @since 2.0.0
|
|
5775
5699
|
*/
|
|
5776
|
-
<A>(self: Iterable<A>,
|
|
5700
|
+
<A, B extends A>(self: Iterable<A>, refinement: (a: A, i: number) => a is B): Array<B>;
|
|
5777
5701
|
/**
|
|
5778
5702
|
* Keeps only elements satisfying a predicate (or refinement).
|
|
5779
5703
|
*
|
|
@@ -5793,176 +5717,80 @@ export declare const filter: {
|
|
|
5793
5717
|
* @category filtering
|
|
5794
5718
|
* @since 2.0.0
|
|
5795
5719
|
*/
|
|
5796
|
-
<A
|
|
5720
|
+
<A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): Array<A>;
|
|
5797
5721
|
};
|
|
5798
5722
|
/**
|
|
5799
|
-
* Splits an iterable
|
|
5800
|
-
* elements that satisfy it.
|
|
5723
|
+
* Splits an iterable using a `Filter` into failures and successes.
|
|
5801
5724
|
*
|
|
5802
5725
|
* - Returns `[excluded, satisfying]`.
|
|
5803
|
-
* -
|
|
5726
|
+
* - The filter receives `(element, index)`.
|
|
5804
5727
|
*
|
|
5805
|
-
* **Example** (Partitioning
|
|
5728
|
+
* **Example** (Partitioning with a filter)
|
|
5806
5729
|
*
|
|
5807
5730
|
* ```ts
|
|
5808
|
-
* import { Array } from "effect"
|
|
5731
|
+
* import { Array, Result } from "effect"
|
|
5809
5732
|
*
|
|
5810
|
-
* console.log(Array.partition([1, 2, 3
|
|
5733
|
+
* console.log(Array.partition([1, -2, 3], (n, i) =>
|
|
5734
|
+
* n > 0 ? Result.succeed(n + i) : Result.fail(`negative:${n}`)
|
|
5735
|
+
* ))
|
|
5736
|
+
* // [["negative:-2"], [1, 5]]
|
|
5811
5737
|
* ```
|
|
5812
5738
|
*
|
|
5813
5739
|
* @see {@link filter} — keep only matching elements
|
|
5814
5740
|
* @see {@link partitionMap} — partition using a Result-returning function
|
|
5815
5741
|
*
|
|
5816
|
-
* Also accepts a `Filter` to split elements with custom pass/fail payloads.
|
|
5817
|
-
*
|
|
5818
5742
|
* @category filtering
|
|
5819
5743
|
* @since 2.0.0
|
|
5820
5744
|
*/
|
|
5821
5745
|
export declare const partition: {
|
|
5822
5746
|
/**
|
|
5823
|
-
* Splits an iterable
|
|
5824
|
-
* elements that satisfy it.
|
|
5747
|
+
* Splits an iterable using a `Filter` into failures and successes.
|
|
5825
5748
|
*
|
|
5826
5749
|
* - Returns `[excluded, satisfying]`.
|
|
5827
|
-
* -
|
|
5750
|
+
* - The filter receives `(element, index)`.
|
|
5828
5751
|
*
|
|
5829
|
-
* **Example** (Partitioning
|
|
5752
|
+
* **Example** (Partitioning with a filter)
|
|
5830
5753
|
*
|
|
5831
5754
|
* ```ts
|
|
5832
|
-
* import { Array } from "effect"
|
|
5833
|
-
*
|
|
5834
|
-
* console.log(Array.partition([1, 2, 3, 4], (n) => n % 2 === 0)) // [[1, 3], [2, 4]]
|
|
5835
|
-
* ```
|
|
5836
|
-
*
|
|
5837
|
-
* @see {@link filter} — keep only matching elements
|
|
5838
|
-
* @see {@link partitionMap} — partition using a Result-returning function
|
|
5839
|
-
*
|
|
5840
|
-
* Also accepts a `Filter` to split elements with custom pass/fail payloads.
|
|
5841
|
-
*
|
|
5842
|
-
* @category filtering
|
|
5843
|
-
* @since 2.0.0
|
|
5844
|
-
*/
|
|
5845
|
-
<A, B extends A>(refinement: (a: NoInfer<A>, i: number) => a is B): (self: Iterable<A>) => [excluded: Array<Exclude<A, B>>, satisfying: Array<B>];
|
|
5846
|
-
/**
|
|
5847
|
-
* Splits an iterable into two arrays: elements that fail the predicate and
|
|
5848
|
-
* elements that satisfy it.
|
|
5849
|
-
*
|
|
5850
|
-
* - Returns `[excluded, satisfying]`.
|
|
5851
|
-
* - Supports refinements for type narrowing.
|
|
5852
|
-
*
|
|
5853
|
-
* **Example** (Partitioning by predicate)
|
|
5854
|
-
*
|
|
5855
|
-
* ```ts
|
|
5856
|
-
* import { Array } from "effect"
|
|
5857
|
-
*
|
|
5858
|
-
* console.log(Array.partition([1, 2, 3, 4], (n) => n % 2 === 0)) // [[1, 3], [2, 4]]
|
|
5859
|
-
* ```
|
|
5860
|
-
*
|
|
5861
|
-
* @see {@link filter} — keep only matching elements
|
|
5862
|
-
* @see {@link partitionMap} — partition using a Result-returning function
|
|
5863
|
-
*
|
|
5864
|
-
* Also accepts a `Filter` to split elements with custom pass/fail payloads.
|
|
5865
|
-
*
|
|
5866
|
-
* @category filtering
|
|
5867
|
-
* @since 2.0.0
|
|
5868
|
-
*/
|
|
5869
|
-
<A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: Iterable<A>) => [excluded: Array<A>, satisfying: Array<A>];
|
|
5870
|
-
/**
|
|
5871
|
-
* Splits an iterable into two arrays: elements that fail the predicate and
|
|
5872
|
-
* elements that satisfy it.
|
|
5873
|
-
*
|
|
5874
|
-
* - Returns `[excluded, satisfying]`.
|
|
5875
|
-
* - Supports refinements for type narrowing.
|
|
5876
|
-
*
|
|
5877
|
-
* **Example** (Partitioning by predicate)
|
|
5878
|
-
*
|
|
5879
|
-
* ```ts
|
|
5880
|
-
* import { Array } from "effect"
|
|
5881
|
-
*
|
|
5882
|
-
* console.log(Array.partition([1, 2, 3, 4], (n) => n % 2 === 0)) // [[1, 3], [2, 4]]
|
|
5883
|
-
* ```
|
|
5884
|
-
*
|
|
5885
|
-
* @see {@link filter} — keep only matching elements
|
|
5886
|
-
* @see {@link partitionMap} — partition using a Result-returning function
|
|
5887
|
-
*
|
|
5888
|
-
* Also accepts a `Filter` to split elements with custom pass/fail payloads.
|
|
5889
|
-
*
|
|
5890
|
-
* @category filtering
|
|
5891
|
-
* @since 2.0.0
|
|
5892
|
-
*/
|
|
5893
|
-
<A, Pass, Fail>(f: Filter.Filter<A, Pass, Fail>): (self: Iterable<A>) => [excluded: Array<Fail>, satisfying: Array<Pass>];
|
|
5894
|
-
/**
|
|
5895
|
-
* Splits an iterable into two arrays: elements that fail the predicate and
|
|
5896
|
-
* elements that satisfy it.
|
|
5897
|
-
*
|
|
5898
|
-
* - Returns `[excluded, satisfying]`.
|
|
5899
|
-
* - Supports refinements for type narrowing.
|
|
5900
|
-
*
|
|
5901
|
-
* **Example** (Partitioning by predicate)
|
|
5902
|
-
*
|
|
5903
|
-
* ```ts
|
|
5904
|
-
* import { Array } from "effect"
|
|
5905
|
-
*
|
|
5906
|
-
* console.log(Array.partition([1, 2, 3, 4], (n) => n % 2 === 0)) // [[1, 3], [2, 4]]
|
|
5907
|
-
* ```
|
|
5908
|
-
*
|
|
5909
|
-
* @see {@link filter} — keep only matching elements
|
|
5910
|
-
* @see {@link partitionMap} — partition using a Result-returning function
|
|
5911
|
-
*
|
|
5912
|
-
* Also accepts a `Filter` to split elements with custom pass/fail payloads.
|
|
5913
|
-
*
|
|
5914
|
-
* @category filtering
|
|
5915
|
-
* @since 2.0.0
|
|
5916
|
-
*/
|
|
5917
|
-
<A, B extends A>(self: Iterable<A>, refinement: (a: A, i: number) => a is B): [excluded: Array<Exclude<A, B>>, satisfying: Array<B>];
|
|
5918
|
-
/**
|
|
5919
|
-
* Splits an iterable into two arrays: elements that fail the predicate and
|
|
5920
|
-
* elements that satisfy it.
|
|
5921
|
-
*
|
|
5922
|
-
* - Returns `[excluded, satisfying]`.
|
|
5923
|
-
* - Supports refinements for type narrowing.
|
|
5924
|
-
*
|
|
5925
|
-
* **Example** (Partitioning by predicate)
|
|
5926
|
-
*
|
|
5927
|
-
* ```ts
|
|
5928
|
-
* import { Array } from "effect"
|
|
5755
|
+
* import { Array, Result } from "effect"
|
|
5929
5756
|
*
|
|
5930
|
-
* console.log(Array.partition([1, 2, 3
|
|
5757
|
+
* console.log(Array.partition([1, -2, 3], (n, i) =>
|
|
5758
|
+
* n > 0 ? Result.succeed(n + i) : Result.fail(`negative:${n}`)
|
|
5759
|
+
* ))
|
|
5760
|
+
* // [["negative:-2"], [1, 5]]
|
|
5931
5761
|
* ```
|
|
5932
5762
|
*
|
|
5933
5763
|
* @see {@link filter} — keep only matching elements
|
|
5934
5764
|
* @see {@link partitionMap} — partition using a Result-returning function
|
|
5935
5765
|
*
|
|
5936
|
-
* Also accepts a `Filter` to split elements with custom pass/fail payloads.
|
|
5937
|
-
*
|
|
5938
5766
|
* @category filtering
|
|
5939
5767
|
* @since 2.0.0
|
|
5940
5768
|
*/
|
|
5941
|
-
<A>(
|
|
5769
|
+
<A, Pass, Fail>(f: Filter.Filter<NoInfer<A>, Pass, Fail, [i: number]>): (self: Iterable<A>) => [excluded: Array<Fail>, satisfying: Array<Pass>];
|
|
5942
5770
|
/**
|
|
5943
|
-
* Splits an iterable
|
|
5944
|
-
* elements that satisfy it.
|
|
5771
|
+
* Splits an iterable using a `Filter` into failures and successes.
|
|
5945
5772
|
*
|
|
5946
5773
|
* - Returns `[excluded, satisfying]`.
|
|
5947
|
-
* -
|
|
5774
|
+
* - The filter receives `(element, index)`.
|
|
5948
5775
|
*
|
|
5949
|
-
* **Example** (Partitioning
|
|
5776
|
+
* **Example** (Partitioning with a filter)
|
|
5950
5777
|
*
|
|
5951
5778
|
* ```ts
|
|
5952
|
-
* import { Array } from "effect"
|
|
5779
|
+
* import { Array, Result } from "effect"
|
|
5953
5780
|
*
|
|
5954
|
-
* console.log(Array.partition([1, 2, 3
|
|
5781
|
+
* console.log(Array.partition([1, -2, 3], (n, i) =>
|
|
5782
|
+
* n > 0 ? Result.succeed(n + i) : Result.fail(`negative:${n}`)
|
|
5783
|
+
* ))
|
|
5784
|
+
* // [["negative:-2"], [1, 5]]
|
|
5955
5785
|
* ```
|
|
5956
5786
|
*
|
|
5957
5787
|
* @see {@link filter} — keep only matching elements
|
|
5958
5788
|
* @see {@link partitionMap} — partition using a Result-returning function
|
|
5959
5789
|
*
|
|
5960
|
-
* Also accepts a `Filter` to split elements with custom pass/fail payloads.
|
|
5961
|
-
*
|
|
5962
5790
|
* @category filtering
|
|
5963
5791
|
* @since 2.0.0
|
|
5964
5792
|
*/
|
|
5965
|
-
<A, Pass, Fail>(self: Iterable<A>, f: Filter.Filter<A, Pass, Fail>): [excluded: Array<Fail>, satisfying: Array<Pass>];
|
|
5793
|
+
<A, Pass, Fail>(self: Iterable<A>, f: Filter.Filter<A, Pass, Fail, [i: number]>): [excluded: Array<Fail>, satisfying: Array<Pass>];
|
|
5966
5794
|
};
|
|
5967
5795
|
/**
|
|
5968
5796
|
* Separates an iterable of `Result`s into two arrays: failures and successes.
|