iterflow 0.3.2 → 0.5.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.
Files changed (2) hide show
  1. package/README.md +87 -9
  2. package/package.json +16 -2
package/README.md CHANGED
@@ -45,7 +45,7 @@ import { iter } from 'iterflow';
45
45
  iter([1, 2, 3, 4, 5])
46
46
  .filter(x => x > 2) // Native iterator method
47
47
  .map(x => x * 2) // Native iterator method
48
- .sum(); // iterflow extension - 18
48
+ .sum(); // iterflow extension - 24
49
49
  ```
50
50
 
51
51
  ### Functional API
@@ -54,7 +54,7 @@ iter([1, 2, 3, 4, 5])
54
54
  import { sum, filter, map } from 'iterflow/fn';
55
55
 
56
56
  const data = [1, 2, 3, 4, 5];
57
- sum(map(x => x * 2)(filter(x => x > 2)(data))); // 18
57
+ sum(map(x => x * 2)(filter(x => x > 2)(data))); // 24
58
58
  ```
59
59
 
60
60
  ## Operations
@@ -62,13 +62,11 @@ sum(map(x => x * 2)(filter(x => x > 2)(data))); // 18
62
62
  ### Statistical
63
63
 
64
64
  ```typescript
65
- const numbers = iter([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
66
-
67
- numbers.sum(); // 55
68
- numbers.mean(); // 5.5
69
- numbers.median(); // 5.5
70
- numbers.variance(); // 8.25
71
- numbers.percentile(75); // 7.75
65
+ iter([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).sum(); // 55
66
+ iter([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).mean(); // 5.5
67
+ iter([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).median(); // 5.5
68
+ iter([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).variance(); // 8.25
69
+ iter([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).percentile(75); // 7.75
72
70
  ```
73
71
 
74
72
  ### Windowing
@@ -223,9 +221,89 @@ const movingAverages = iter(temperatures)
223
221
  .toArray();
224
222
  ```
225
223
 
224
+ ## When to Use iterflow
225
+
226
+ iterflow balances developer experience with performance. Here's how to decide:
227
+
228
+ ### Use iterflow when:
229
+
230
+ - **Large datasets** (1000+ items) - lazy evaluation avoids unnecessary work
231
+ - **Early termination** - finding first match, taking limited results (find, some, every, take)
232
+ - **Memory efficiency** - windowing, chunking, or processing huge files
233
+ - **Complex pipelines** - chaining 3+ operations together
234
+ - **Statistical operations** - mean, median, variance, percentile calculations
235
+ - **Code readability** - method chaining feels more natural than manual loops
236
+
237
+ ### Consider alternatives when:
238
+
239
+ - **Small arrays** (< 100 items) - native Array methods are slightly faster
240
+ - **Single simple operation** - map or filter alone on small data
241
+ - **Performance-critical hot paths** - called millions of times, every microsecond matters
242
+ - **Need multiple iterations** - arrays are easier to loop over multiple times
243
+
244
+ ### The Trade-off
245
+
246
+ iterflow uses lazy evaluation, which means:
247
+ - **Lower memory usage** - no intermediate arrays created
248
+ - **Slightly slower per operation** - small function call overhead
249
+ - **Better for large datasets** - memory savings far exceed speed cost
250
+ - **Better for partial consumption** - stops early when possible
251
+
252
+ ### Real Performance Impact
253
+
254
+ For datasets < 100 items, the differences are negligible—use what feels natural.
255
+
256
+ For datasets > 1000 items:
257
+ - **With early termination** (take 10 from 100K): iterflow can be 20-300x faster
258
+ - **With windowing** (moving average): iterflow can be 35-600x faster due to memory efficiency
259
+ - **Full consumption** (process all items): native arrays are 2-5x faster
260
+
261
+ See **[docs/BENCHMARKS.md](docs/BENCHMARKS.md)** for detailed performance data and specific operation comparisons.
262
+
226
263
  <!-- BENCHMARK_SUMMARY_START -->
264
+ ## Performance
265
+
266
+ iterflow balances performance with developer experience. Here's how it performs across different operation categories:
267
+
268
+ | Category | vs Native | vs Lodash | vs Ramda | Operations Tested |
269
+ |----------|-----------|-----------|----------|-------------------|
270
+ | Transformations | 10.8x slower | 6.9x slower | 8.9x slower | 13 |
271
+ | Statistics | N/A | 1.8x slower | 1.4x slower | 14 |
272
+ | Windowing | N/A | 6.1x slower | 8.7x slower | 13 |
273
+ | Terminals | 5.8x slower | 2.6x slower | 5.1x slower | 13 |
274
+ | Lazy Evaluation | 2.8x slower | N/A | 12.9x slower | 3 |
275
+ | Memory Profiling | N/A | N/A | N/A | 0 |
276
+ | Production Profiling | N/A | N/A | N/A | 0 |
277
+
278
+ **Detailed benchmarks:** See [docs/BENCHMARKS.md](docs/BENCHMARKS.md) for comprehensive performance data.
279
+
280
+ *Last updated: December 22, 2025 (v0.4.0)*
227
281
  <!-- BENCHMARK_SUMMARY_END -->
228
282
 
283
+ ## Documentation
284
+
285
+ - **[FAQ](FAQ.md)** - Frequently asked questions, common patterns, and troubleshooting
286
+ - **[Examples](examples/)** - Real-world usage examples
287
+ - **[SECURITY.md](SECURITY.md)** - Security best practices and vulnerability reporting
288
+
289
+ ## Contributing
290
+
291
+ We welcome contributions! Please see our [PLAYBOOK.md](PLAYBOOK.md) for:
292
+
293
+ - Development workflow and branching strategy
294
+ - Commit message guidelines
295
+ - Testing requirements
296
+ - Release process
297
+
298
+ For quick start:
299
+
300
+ 1. Fork the repository
301
+ 2. Create a feature branch from `dev`
302
+ 3. Make your changes with tests
303
+ 4. Submit a PR to `dev`
304
+
305
+ See [PLAYBOOK.md](PLAYBOOK.md) for complete details.
306
+
229
307
  ## License
230
308
 
231
309
  The Unlicense - See [LICENSE](LICENSE) for details.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iterflow",
3
- "version": "0.3.2",
3
+ "version": "0.5.0",
4
4
  "description": "Powerful iterator utilities for ES2022+ with statistical operations, windowing, and lazy evaluation. Forward compatible with ES2025 iterator helpers.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -41,7 +41,21 @@
41
41
  "validate-commits": "node scripts/validate-commits.js",
42
42
  "prepublishOnly": "npm run build && npm test && npm run test:types",
43
43
  "website:dev": "cd website && npm run dev",
44
- "website:build": "npm run build && cd website && npm run build && cd .. && npm run docs"
44
+ "website:build": "npm run build && cd website && npm run build && cd .. && npm run docs",
45
+ "bench:transformations": "vitest bench --run benchmarks/transformations.bench.ts",
46
+ "bench:statistics": "vitest bench --run benchmarks/statistics.bench.ts",
47
+ "bench:windowing": "vitest bench --run benchmarks/windowing.bench.ts",
48
+ "bench:terminals": "vitest bench --run benchmarks/terminals.bench.ts",
49
+ "bench:lazy-evaluation": "vitest bench --run benchmarks/lazy-evaluation.bench.ts",
50
+ "bench:memory-profiling": "vitest bench --run benchmarks/memory-profiling.bench.ts",
51
+ "bench:production-profiling": "vitest bench --run benchmarks/production-profiling.bench.ts",
52
+ "bench:quick": "VITEST_BENCH_TIME=1000 node scripts/run-benchmarks.cjs",
53
+ "bench:all": "node scripts/run-benchmarks.cjs",
54
+ "bench:report": "node scripts/generate-benchmark-report.cjs",
55
+ "bench:update-readme": "node scripts/update-readme-benchmarks.cjs",
56
+ "bench:update-changelog": "node scripts/update-changelog-benchmarks.cjs",
57
+ "bench:full": "npm run bench:all && npm run bench:report && npm run bench:update-readme",
58
+ "bench:workflow": "bash scripts/run-benchmarks-full.sh"
45
59
  },
46
60
  "keywords": [
47
61
  "iterator",