iterable-linq-utility 0.0.16 → 0.2.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 +72 -0
- package/dist/index.d.cts +875 -0
- package/dist/index.d.ts +875 -14
- package/dist/iterable-linq-utility.js +641 -0
- package/dist/iterable-linq-utility.umd.cjs +1 -0
- package/package.json +42 -24
- package/dist/collections/index.d.ts +0 -2
- package/dist/collections/linkedList.d.ts +0 -24
- package/dist/functions/collectToArray.d.ts +0 -1
- package/dist/functions/empty.d.ts +0 -1
- package/dist/functions/filter.d.ts +0 -9
- package/dist/functions/flatMap.d.ts +0 -8
- package/dist/functions/forEach.d.ts +0 -3
- package/dist/functions/index.d.ts +0 -23
- package/dist/functions/map.d.ts +0 -9
- package/dist/functions/materialize.d.ts +0 -7
- package/dist/functions/max.d.ts +0 -9
- package/dist/functions/memoize.d.ts +0 -11
- package/dist/functions/min.d.ts +0 -9
- package/dist/functions/range.d.ts +0 -7
- package/dist/functions/reduce.d.ts +0 -10
- package/dist/functions/repeat.d.ts +0 -1
- package/dist/functions/some.d.ts +0 -9
- package/dist/functions/tap.d.ts +0 -9
- package/dist/functions/tapChain.d.ts +0 -9
- package/dist/interable-linq-utility.js +0 -708
- package/dist/interable-linq-utility.umd.cjs +0 -1
- package/dist/linqIterable.d.ts +0 -45
- package/dist/types/action.d.ts +0 -3
- package/dist/types/comparer.d.ts +0 -4
- package/dist/types/index.d.ts +0 -7
- package/dist/types/mapper.d.ts +0 -1
- package/dist/types/predicate.d.ts +0 -1
- package/dist/types/reducer.d.ts +0 -1
- package/dist/types/tapper.d.ts +0 -2
- package/dist/types/unit.d.ts +0 -3
- package/dist/utils/index.d.ts +0 -4
- package/dist/utils/iteratorResults.d.ts +0 -4
- package/dist/utils/utils.d.ts +0 -56
- package/dist/utils/validations.d.ts +0 -5
package/README.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
[](https://www.jsdelivr.com/package/npm/iterable-linq-utility)
|
|
2
|
+
[](https://npmjs.org/package/iterable-linq-utility)
|
|
3
|
+
[](https://npmjs.org/package/iterable-linq-utility)
|
|
2
4
|
|
|
3
5
|
A [.NET Linq to Objects](https://learn.microsoft.com/it-it/dotnet/csharp/programming-guide/concepts/linq/linq-to-objects) porting with javacript naming conventions (e.g.: `Select` as been ranamed to `map`) and some new features (e.g.: [memoize](https://amebus.github.io/iterable-linq-utility/api-reference/transformations.md#memoize) and [materialize](https://amebus.github.io/iterable-linq-utility/api-reference/actions.md#materialize)).
|
|
4
6
|
|
|
@@ -33,3 +35,73 @@ The **O~s~C** supports two types of operations:
|
|
|
33
35
|
|
|
34
36
|
- [Actions](https://amebus.github.io/iterable-linq-utility/api-reference/actions.md)
|
|
35
37
|
- [Transformations](https://amebus.github.io/iterable-linq-utility/api-reference/transformations.md)
|
|
38
|
+
|
|
39
|
+
## Benchmarks
|
|
40
|
+
|
|
41
|
+
The benchmarks use [Vitest benchmarking](https://vitest.dev/guide/benchmarking) and live in `test/bench`:
|
|
42
|
+
|
|
43
|
+
- `functions/`: one file for each function, with several variants (for example `min` with no comparer, a compare function, a key and a list of keys);
|
|
44
|
+
- `chains/`: whole chains, from `map(filter(range))` to multi-stage pipelines, early exits and chains read by more than one action.
|
|
45
|
+
|
|
46
|
+
Every table compares the library with a native reference (an array method or a hand-written loop) and, where it exists, with the raw function in `Functions`.
|
|
47
|
+
|
|
48
|
+
The benchmarks measure the built bundle (`dist/iterable-linq-utility.js`), the same code that users run. The `bench` scripts build it first.
|
|
49
|
+
|
|
50
|
+
### Run
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
pnpm bench # every benchmark, about 3 minutes
|
|
54
|
+
pnpm bench functions/min # only the files whose path contains "functions/min"
|
|
55
|
+
pnpm bench chains # only the chains
|
|
56
|
+
BENCH_TIME=1000 pnpm bench # more time for each case (default 500 ms): more samples, less noise
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Find regressions
|
|
60
|
+
|
|
61
|
+
A baseline is a saved run. Each table shows it as extra rows, marked `(baseline)`, next to the new run.
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
git switch main
|
|
65
|
+
pnpm bench:baseline # saves every result in .bench/
|
|
66
|
+
git switch my-branch
|
|
67
|
+
pnpm bench # shows each case next to its "(baseline)" row
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The timings depend on the machine, so `.bench/` is not committed and the benchmarks do not run in CI. Create the baseline and the new run on the same machine, with the same load.
|
|
71
|
+
|
|
72
|
+
### Read the tables
|
|
73
|
+
|
|
74
|
+
| Column | Meaning |
|
|
75
|
+
|---|---|
|
|
76
|
+
| `hz` | runs per second: higher is faster |
|
|
77
|
+
| `mean`, `p75`, `p99` | time of one run, in ms |
|
|
78
|
+
| `rme` | relative margin of error |
|
|
79
|
+
| `samples` | how many runs were measured |
|
|
80
|
+
|
|
81
|
+
A difference smaller than the `rme` of the two rows is noise.
|
|
82
|
+
|
|
83
|
+
### Add a benchmark
|
|
84
|
+
|
|
85
|
+
Create `test/bench/functions/<name>.bench.ts` or `test/bench/chains/<scenario>.bench.ts`:
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
import * as IterableLinq from 'iterable-linq-utility';
|
|
89
|
+
import { test } from 'vitest';
|
|
90
|
+
|
|
91
|
+
import * as Helpers from '../helpers';
|
|
92
|
+
|
|
93
|
+
// Read the exports once: an imported binding goes through a module runner getter on every read.
|
|
94
|
+
const { from } = IterableLinq;
|
|
95
|
+
const { cases, numbers, sum } = Helpers;
|
|
96
|
+
|
|
97
|
+
test('map: number', async ({ bench }) => {
|
|
98
|
+
await cases(bench, 'map/number') // the baseline folder: <function>/<variant>
|
|
99
|
+
.add('native', () => sum(numbers.map(v => v * 2)))
|
|
100
|
+
.add('chain', () => sum(from(numbers).map(v => v * 2)))
|
|
101
|
+
.run();
|
|
102
|
+
});
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
- Every table needs at least two cases: add a native reference.
|
|
106
|
+
- Import the library and the helpers as namespaces and copy the exports into local constants, as above. Vitest prints a `Benchmark Warning` when a benchmark reads an imported binding too many times.
|
|
107
|
+
- The shared data is in `test/bench/helpers.ts`: `numbers` (100,000 integers), `records` (100,000 objects) and `small` (1,000 integers).
|