@anabranch/fs 0.1.8 → 0.1.10

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 (51) hide show
  1. package/esm/{fs/dir.d.ts → dir.d.ts} +1 -1
  2. package/esm/dir.d.ts.map +1 -0
  3. package/esm/{fs/dir.js → dir.js} +1 -1
  4. package/esm/errors.d.ts.map +1 -0
  5. package/esm/glob_match.d.ts.map +1 -0
  6. package/esm/{fs/index.d.ts → index.d.ts} +1 -1
  7. package/esm/index.d.ts.map +1 -0
  8. package/esm/{fs/index.js → index.js} +1 -1
  9. package/esm/{fs/read.d.ts → read.d.ts} +1 -1
  10. package/esm/read.d.ts.map +1 -0
  11. package/esm/{fs/read.js → read.js} +1 -1
  12. package/esm/types.d.ts.map +1 -0
  13. package/esm/{fs/watch.d.ts → watch.d.ts} +1 -1
  14. package/esm/watch.d.ts.map +1 -0
  15. package/esm/{fs/watch.js → watch.js} +1 -1
  16. package/esm/{fs/write.d.ts → write.d.ts} +1 -1
  17. package/esm/write.d.ts.map +1 -0
  18. package/esm/{fs/write.js → write.js} +1 -1
  19. package/package.json +3 -3
  20. package/esm/anabranch/index.d.ts +0 -44
  21. package/esm/anabranch/index.d.ts.map +0 -1
  22. package/esm/anabranch/index.js +0 -41
  23. package/esm/anabranch/streams/channel.d.ts +0 -15
  24. package/esm/anabranch/streams/channel.d.ts.map +0 -1
  25. package/esm/anabranch/streams/channel.js +0 -122
  26. package/esm/anabranch/streams/source.d.ts +0 -75
  27. package/esm/anabranch/streams/source.d.ts.map +0 -1
  28. package/esm/anabranch/streams/source.js +0 -77
  29. package/esm/anabranch/streams/stream.d.ts +0 -431
  30. package/esm/anabranch/streams/stream.d.ts.map +0 -1
  31. package/esm/anabranch/streams/stream.js +0 -627
  32. package/esm/anabranch/streams/task.d.ts +0 -117
  33. package/esm/anabranch/streams/task.d.ts.map +0 -1
  34. package/esm/anabranch/streams/task.js +0 -419
  35. package/esm/anabranch/streams/util.d.ts +0 -33
  36. package/esm/anabranch/streams/util.d.ts.map +0 -1
  37. package/esm/anabranch/streams/util.js +0 -18
  38. package/esm/fs/dir.d.ts.map +0 -1
  39. package/esm/fs/errors.d.ts.map +0 -1
  40. package/esm/fs/glob_match.d.ts.map +0 -1
  41. package/esm/fs/index.d.ts.map +0 -1
  42. package/esm/fs/read.d.ts.map +0 -1
  43. package/esm/fs/types.d.ts.map +0 -1
  44. package/esm/fs/watch.d.ts.map +0 -1
  45. package/esm/fs/write.d.ts.map +0 -1
  46. /package/esm/{fs/errors.d.ts → errors.d.ts} +0 -0
  47. /package/esm/{fs/errors.js → errors.js} +0 -0
  48. /package/esm/{fs/glob_match.d.ts → glob_match.d.ts} +0 -0
  49. /package/esm/{fs/glob_match.js → glob_match.js} +0 -0
  50. /package/esm/{fs/types.d.ts → types.d.ts} +0 -0
  51. /package/esm/{fs/types.js → types.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { Source } from "../anabranch/index.js";
1
+ import { Source } from "anabranch";
2
2
  import type { DirEntry, GlobOptions, WalkEntry, WalkOptions } from "./types.js";
3
3
  import { type NotDirectory, type NotFound, type PermissionDenied, type Unknown } from "./errors.js";
4
4
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dir.d.ts","sourceRoot":"","sources":["../src/dir.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,OAAO,EACb,MAAM,aAAa,CAAC;AAErB;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAgBtE;AAED;;GAEG;AACH,wBAAgB,IAAI,CAClB,IAAI,EAAE,MAAM,GAAG,GAAG,EAClB,OAAO,CAAC,EAAE,WAAW,GACpB,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,CA6D7B;AAED;;GAEG;AACH,wBAAgB,IAAI,CAClB,IAAI,EAAE,MAAM,GAAG,GAAG,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,WAAW,GACpB,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,CAG7B;AAED,sDAAsD;AACtD,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,YAAY,GAAG,gBAAgB,GAAG,OAAO,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { readdir } from "node:fs/promises";
2
2
  import { join, relative } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
- import { Source } from "../anabranch/index.js";
4
+ import { Source } from "anabranch";
5
5
  import { _matchGlob } from "./glob_match.js";
6
6
  import { nodeErrorToFSError, } from "./errors.js";
7
7
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,OAAQ,SAAQ,KAAK;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC;gBAEhB,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,EAAE,OAAO,EAAE,MAAM;CAK9D;AAED,qBAAa,QAAS,SAAQ,OAAO;gBACvB,IAAI,EAAE,MAAM,GAAG,GAAG,EAAE,OAAO,EAAE,MAAM;CAGhD;AAED,8CAA8C;AAC9C,qBAAa,aAAc,SAAQ,OAAO;gBAC5B,IAAI,EAAE,MAAM,GAAG,GAAG,EAAE,OAAO,EAAE,MAAM;CAGhD;AAED,oDAAoD;AACpD,qBAAa,WAAY,SAAQ,OAAO;gBAC1B,IAAI,EAAE,MAAM,GAAG,GAAG,EAAE,OAAO,EAAE,MAAM;CAGhD;AAED,6DAA6D;AAC7D,qBAAa,YAAa,SAAQ,OAAO;gBAC3B,IAAI,EAAE,MAAM,GAAG,GAAG,EAAE,OAAO,EAAE,MAAM;CAGhD;AAED,mDAAmD;AACnD,qBAAa,gBAAiB,SAAQ,OAAO;gBAC/B,IAAI,EAAE,MAAM,GAAG,GAAG,EAAE,OAAO,EAAE,MAAM;CAGhD;AAED,0CAA0C;AAC1C,qBAAa,SAAU,SAAQ,OAAO;gBACxB,IAAI,EAAE,MAAM,GAAG,GAAG,EAAE,OAAO,EAAE,MAAM;CAGhD;AAED,wCAAwC;AACxC,qBAAa,UAAW,SAAQ,OAAO;gBACzB,IAAI,EAAE,MAAM,GAAG,GAAG,EAAE,OAAO,EAAE,MAAM;CAGhD;AAED,sDAAsD;AACtD,qBAAa,WAAY,SAAQ,OAAO;IACtC,SAAkB,KAAK,CAAC,EAAE,OAAO,CAAC;gBAEtB,IAAI,EAAE,MAAM,GAAG,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAIjE;AAED,iCAAiC;AACjC,qBAAa,OAAQ,SAAQ,OAAO;IAClC,SAAkB,KAAK,CAAC,EAAE,OAAO,CAAC;gBAEtB,IAAI,EAAE,MAAM,GAAG,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAIjE;AAED,0EAA0E;AAC1E,eAAO,MAAM,QAAQ;;;;;;;;;;CAUX,CAAC;AAEX,iBAAS,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,CAmBvE;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glob_match.d.ts","sourceRoot":"","sources":["../src/glob_match.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAElD"}
@@ -23,7 +23,7 @@
23
23
  *
24
24
  * @module
25
25
  */
26
- import "../_dnt.polyfills.js";
26
+ import "./_dnt.polyfills.js";
27
27
  export { readFile, readJson, readLines, readTextFile } from "./read.js";
28
28
  export type { ReadFileError, ReadJsonError } from "./read.js";
29
29
  export { writeFile, writeJson, writeTextFile } from "./write.js";
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,qBAAqB,CAAC;AAE7B,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACxE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACjE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAC/C,YAAY,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,YAAY,EACV,QAAQ,EACR,OAAO,EACP,WAAW,EACX,SAAS,EACT,WAAW,EACX,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAChD,YAAY,EACV,aAAa,EACb,WAAW,EACX,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,gBAAgB,EAChB,SAAS,EACT,OAAO,EACP,UAAU,GACX,MAAM,aAAa,CAAC"}
@@ -23,7 +23,7 @@
23
23
  *
24
24
  * @module
25
25
  */
26
- import "../_dnt.polyfills.js";
26
+ import "./_dnt.polyfills.js";
27
27
  export { readFile, readJson, readLines, readTextFile } from "./read.js";
28
28
  export { writeFile, writeJson, writeTextFile } from "./write.js";
29
29
  export { glob, readDir, walk } from "./dir.js";
@@ -1,4 +1,4 @@
1
- import { Source, Task } from "../anabranch/index.js";
1
+ import { Source, Task } from "anabranch";
2
2
  import { FSError, FSErrors, type NotFound, type PermissionDenied, type ReadError, type Unknown } from "./errors.js";
3
3
  export { FSError, FSErrors };
4
4
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EACL,OAAO,EACP,QAAQ,EAER,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,OAAO,EACb,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAE7B;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAe3E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,GAAG,GAAG,GACjB,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAQ7B;AAED;;GAEG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,GAAG,GAAG,GACjB,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,CASjC;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC,EAAE,aAAa,CAAC,CAkBtE;AAED,gDAAgD;AAChD,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,gBAAgB,GAAG,SAAS,GAAG,OAAO,CAAC;AAE9E,qDAAqD;AACrD,MAAM,MAAM,aAAa,GACrB,QAAQ,GACR,gBAAgB,GAChB,SAAS,GACT,YAAY,CAAC,OAAO,QAAQ,CAAC,WAAW,CAAC,GACzC,OAAO,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { createReadStream } from "node:fs";
2
2
  import { readFile as fsReadFile } from "node:fs/promises";
3
3
  import { createInterface } from "node:readline";
4
- import { Source, Task } from "../anabranch/index.js";
4
+ import { Source, Task } from "anabranch";
5
5
  import { FSError, FSErrors, nodeErrorToFSError, } from "./errors.js";
6
6
  export { FSError, FSErrors };
7
7
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,MAAM,WAAW,QAAQ;IACvB,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,MAAM,EAAE,OAAO,CAAC;IAChB,wCAAwC;IACxC,WAAW,EAAE,OAAO,CAAC;IACrB,4CAA4C;IAC5C,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,yFAAyF;AACzF,MAAM,WAAW,SAAU,SAAQ,QAAQ;IACzC,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,gCAAgC;AAChC,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,6EAA6E;AAC7E,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC;CAAG;AAElE,+DAA+D;AAC/D,MAAM,WAAW,OAAO;IACtB,0BAA0B;IAC1B,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACrC,4CAA4C;IAC5C,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,iCAAiC;AACjC,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB"}
@@ -1,4 +1,4 @@
1
- import type { Stream } from "../anabranch/index.js";
1
+ import type { Stream } from "anabranch";
2
2
  import type { FsEvent, WatchOptions } from "./types.js";
3
3
  import { type NotFound, type PermissionDenied } from "./errors.js";
4
4
  /** Errors that can occur when watching the file system. */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../src/watch.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACtB,MAAM,aAAa,CAAC;AAErB,2DAA2D;AAC3D,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,gBAAgB,CAAC;AAErD;;;;;;;;;;GAUG;AACH,wBAAgB,KAAK,CACnB,IAAI,EAAE,MAAM,GAAG,GAAG,EAClB,OAAO,CAAC,EAAE,YAAY,GACrB,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,CAgC7B"}
@@ -1,7 +1,7 @@
1
1
  import { existsSync, watch as fsWatch } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
- import { Channel, Source } from "../anabranch/index.js";
4
+ import { Channel, Source } from "anabranch";
5
5
  import { nodeErrorToFSError, } from "./errors.js";
6
6
  /**
7
7
  * Watches `path` for file-system changes, yielding a {@link FsEvent} for each.
@@ -1,4 +1,4 @@
1
- import { Task } from "../anabranch/index.js";
1
+ import { Task } from "anabranch";
2
2
  import { type IsDirectory, type NotFound, type PermissionDenied, type Unknown, type WriteError } from "./errors.js";
3
3
  /**
4
4
  * Writes a UTF-8 string to a file, creating or overwriting it.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../src/write.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,OAAO,EACZ,KAAK,UAAU,EAChB,MAAM,aAAa,CAAC;AAErB;;GAEG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,GAAG,GAAG,EAClB,OAAO,EAAE,MAAM,GACd,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAQ5B;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,GAAG,GAAG,EAClB,IAAI,EAAE,UAAU,GACf,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAQ5B;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,GAAG,GAAG,EAClB,KAAK,EAAE,OAAO,GACb,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAQ5B;AAED,gDAAgD;AAChD,MAAM,MAAM,cAAc,GACtB,QAAQ,GACR,WAAW,GACX,gBAAgB,GAChB,UAAU,GACV,OAAO,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { writeFile as fsWriteFile } from "node:fs/promises";
2
- import { Task } from "../anabranch/index.js";
2
+ import { Task } from "anabranch";
3
3
  import { nodeErrorToFSError, } from "./errors.js";
4
4
  /**
5
5
  * Writes a UTF-8 string to a file, creating or overwriting it.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anabranch/fs",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "Streaming file-system utilities for the anabranch ecosystem",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,10 +10,10 @@
10
10
  "bugs": {
11
11
  "url": "https://github.com/frodi-karlsson/anabranch/issues"
12
12
  },
13
- "module": "./esm/fs/index.js",
13
+ "module": "./esm/index.js",
14
14
  "exports": {
15
15
  ".": {
16
- "import": "./esm/fs/index.js"
16
+ "import": "./esm/index.js"
17
17
  }
18
18
  },
19
19
  "scripts": {},
@@ -1,44 +0,0 @@
1
- /**
2
- * Anabranch is a TypeScript library for error-tolerant async streams.
3
- *
4
- * Instead of throwing on the first error, it collects errors alongside
5
- * successful values so you can process a stream to completion and deal with
6
- * failures at the end — or not at all.
7
- *
8
- * The entry point is {@link Source}. Once you have a stream, chain operations
9
- * like {@link Stream.map map}, {@link Stream.filter filter},
10
- * {@link Stream.flatMap flatMap}, and {@link Stream.fold fold} to transform it,
11
- * then consume it with {@link Stream.collect collect} or
12
- * {@link Stream.partition partition}.
13
- *
14
- * @example Fetch a list of URLs concurrently, collect results and failures separately
15
- * ```ts
16
- * import { Source } from "anabranch";
17
- *
18
- * const { successes, errors } = await Source.from<string, Error>(
19
- * async function* () {
20
- * yield "https://example.com/1";
21
- * yield "https://example.com/2";
22
- * yield "https://example.com/3";
23
- * },
24
- * )
25
- * .withConcurrency(3)
26
- * .map(async (url) => {
27
- * const res = await fetch(url);
28
- * if (!res.ok) throw new Error(`HTTP ${res.status} for ${url}`);
29
- * return res.json();
30
- * })
31
- * .partition();
32
- *
33
- * console.log(`${successes.length} succeeded, ${errors.length} failed`);
34
- * ```
35
- *
36
- * @module
37
- */
38
- export { Source } from "./streams/source.js";
39
- export { Task } from "./streams/task.js";
40
- export { Channel } from "./streams/channel.js";
41
- export type { Stream } from "./streams/stream.js";
42
- export { AggregateError } from "./streams/util.js";
43
- export type { ErrorResult, Promisable, Result, SuccessResult, } from "./streams/util.js";
44
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/anabranch/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,YAAY,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,YAAY,EACV,WAAW,EACX,UAAU,EACV,MAAM,EACN,aAAa,GACd,MAAM,mBAAmB,CAAC"}
@@ -1,41 +0,0 @@
1
- /**
2
- * Anabranch is a TypeScript library for error-tolerant async streams.
3
- *
4
- * Instead of throwing on the first error, it collects errors alongside
5
- * successful values so you can process a stream to completion and deal with
6
- * failures at the end — or not at all.
7
- *
8
- * The entry point is {@link Source}. Once you have a stream, chain operations
9
- * like {@link Stream.map map}, {@link Stream.filter filter},
10
- * {@link Stream.flatMap flatMap}, and {@link Stream.fold fold} to transform it,
11
- * then consume it with {@link Stream.collect collect} or
12
- * {@link Stream.partition partition}.
13
- *
14
- * @example Fetch a list of URLs concurrently, collect results and failures separately
15
- * ```ts
16
- * import { Source } from "anabranch";
17
- *
18
- * const { successes, errors } = await Source.from<string, Error>(
19
- * async function* () {
20
- * yield "https://example.com/1";
21
- * yield "https://example.com/2";
22
- * yield "https://example.com/3";
23
- * },
24
- * )
25
- * .withConcurrency(3)
26
- * .map(async (url) => {
27
- * const res = await fetch(url);
28
- * if (!res.ok) throw new Error(`HTTP ${res.status} for ${url}`);
29
- * return res.json();
30
- * })
31
- * .partition();
32
- *
33
- * console.log(`${successes.length} succeeded, ${errors.length} failed`);
34
- * ```
35
- *
36
- * @module
37
- */
38
- export { Source } from "./streams/source.js";
39
- export { Task } from "./streams/task.js";
40
- export { Channel } from "./streams/channel.js";
41
- export { AggregateError } from "./streams/util.js";
@@ -1,15 +0,0 @@
1
- import { _StreamImpl } from "./stream.js";
2
- interface ChannelOptions<T> {
3
- bufferSize?: number;
4
- onDrop?: (value: T) => void;
5
- onClose?: () => void;
6
- }
7
- export declare class Channel<T, E = never> extends _StreamImpl<T, E> {
8
- private sourceImpl;
9
- constructor(options?: ChannelOptions<T>);
10
- send(value: T): void;
11
- fail(error: E): void;
12
- close(): void;
13
- }
14
- export {};
15
- //# sourceMappingURL=channel.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../../src/anabranch/streams/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,UAAU,cAAc,CAAC,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAgFD,qBAAa,OAAO,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,CAAE,SAAQ,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC;IAC1D,OAAO,CAAC,UAAU,CAAsB;gBAE5B,OAAO,GAAE,cAAc,CAAC,CAAC,CAAM;IAM3C,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;IAIpB,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;IAIpB,KAAK,IAAI,IAAI;CAGd"}
@@ -1,122 +0,0 @@
1
- import { _StreamImpl } from "./stream.js";
2
- class ChannelSource {
3
- constructor(options = {}) {
4
- Object.defineProperty(this, "queue", {
5
- enumerable: true,
6
- configurable: true,
7
- writable: true,
8
- value: []
9
- });
10
- Object.defineProperty(this, "closed", {
11
- enumerable: true,
12
- configurable: true,
13
- writable: true,
14
- value: false
15
- });
16
- Object.defineProperty(this, "consumers", {
17
- enumerable: true,
18
- configurable: true,
19
- writable: true,
20
- value: []
21
- });
22
- Object.defineProperty(this, "bufferSize", {
23
- enumerable: true,
24
- configurable: true,
25
- writable: true,
26
- value: void 0
27
- });
28
- Object.defineProperty(this, "onDrop", {
29
- enumerable: true,
30
- configurable: true,
31
- writable: true,
32
- value: void 0
33
- });
34
- Object.defineProperty(this, "onClose", {
35
- enumerable: true,
36
- configurable: true,
37
- writable: true,
38
- value: void 0
39
- });
40
- this.bufferSize = Number.isFinite(options.bufferSize)
41
- ? Math.max(1, options.bufferSize)
42
- : Infinity;
43
- this.onDrop = options.onDrop;
44
- this.onClose = options.onClose;
45
- }
46
- send(value) {
47
- if (this.closed) {
48
- return;
49
- }
50
- if (this.queue.length >= this.bufferSize && this.bufferSize !== Infinity) {
51
- this.onDrop?.(value);
52
- return;
53
- }
54
- this.queue.push({ type: "success", value });
55
- this.wake();
56
- }
57
- fail(error) {
58
- if (this.closed) {
59
- return;
60
- }
61
- this.queue.push({ type: "error", error });
62
- this.wake();
63
- }
64
- close() {
65
- if (this.closed) {
66
- return;
67
- }
68
- this.closed = true;
69
- this.wake();
70
- }
71
- wake() {
72
- while (this.consumers.length > 0) {
73
- const consumer = this.consumers.shift();
74
- if (consumer)
75
- consumer();
76
- }
77
- }
78
- async *generator() {
79
- try {
80
- while (true) {
81
- while (this.queue.length > 0) {
82
- yield this.queue.shift();
83
- }
84
- if (this.closed && this.queue.length === 0) {
85
- return;
86
- }
87
- if (this.queue.length === 0) {
88
- await new Promise((resolve) => {
89
- this.consumers.push(resolve);
90
- });
91
- if (this.queue.length > 0)
92
- continue;
93
- }
94
- }
95
- }
96
- finally {
97
- this.onClose?.();
98
- }
99
- }
100
- }
101
- export class Channel extends _StreamImpl {
102
- constructor(options = {}) {
103
- const sourceImpl = new ChannelSource(options);
104
- super(() => sourceImpl.generator(), Infinity, Infinity);
105
- Object.defineProperty(this, "sourceImpl", {
106
- enumerable: true,
107
- configurable: true,
108
- writable: true,
109
- value: void 0
110
- });
111
- this.sourceImpl = sourceImpl;
112
- }
113
- send(value) {
114
- this.sourceImpl.send(value);
115
- }
116
- fail(error) {
117
- this.sourceImpl.fail(error);
118
- }
119
- close() {
120
- this.sourceImpl.close();
121
- }
122
- }
@@ -1,75 +0,0 @@
1
- import { _StreamImpl } from "./stream.js";
2
- import type { Result } from "./util.js";
3
- /**
4
- * The entry point for creating a {@link Stream}. Wraps an async generator so
5
- * that yielded values become success results and any thrown error becomes a
6
- * single error result.
7
- *
8
- * Use {@link Source.from} to create a source from an existing `AsyncIterable`
9
- * or generator function. Use {@link Source.withConcurrency} and
10
- * {@link Source.withBufferSize} to configure parallel execution.
11
- *
12
- * @example
13
- * ```ts
14
- * import { Source } from "anabranch";
15
- *
16
- * const stream = Source.from<number, Error>(async function* () {
17
- * yield 1;
18
- * yield 2;
19
- * yield 3;
20
- * });
21
- *
22
- * const results = await stream.collect();
23
- * ```
24
- */
25
- export declare class Source<T, E> extends _StreamImpl<T, E> {
26
- private readonly resultSource;
27
- /**
28
- * @param source An async generator function. Each yielded value becomes a
29
- * success result; any thrown error becomes an error result and terminates
30
- * the source.
31
- * @param concurrency Maximum number of concurrent operations. Defaults to `Infinity`.
32
- * @param bufferSize Maximum number of buffered results before backpressure is applied. Defaults to `Infinity`.
33
- */
34
- private constructor();
35
- /**
36
- * Creates a {@link Source} from an existing `AsyncIterable` or async
37
- * generator function. Each value emitted becomes a success result; any
38
- * thrown error becomes an error result.
39
- *
40
- * @example
41
- * ```ts
42
- * import { Source } from "anabranch";
43
- *
44
- * // From a generator function
45
- * const stream = Source.from<number, Error>(async function* () {
46
- * yield 1;
47
- * yield 2;
48
- * });
49
- *
50
- * // From an AsyncIterable
51
- * async function* generate() {
52
- * yield 1;
53
- * yield 2;
54
- * }
55
- * const stream2 = Source.from<number, Error>(generate());
56
- * ```
57
- */
58
- static from<T, E>(source: AsyncIterable<T>): Source<T, E>;
59
- static from<T, E>(fn: () => AsyncGenerator<T>): Source<T, E>;
60
- /**
61
- * Creates a {@link Source} from an async generator that yields {@link Result}
62
- * values directly. This is useful when you want to yield both successes and
63
- * errors from the source without terminating it on the first error.
64
- */
65
- static fromResults<T, E>(source: () => AsyncGenerator<Result<T, E>>): Source<T, E>;
66
- /**
67
- * Sets the maximum number of concurrent operations for the stream.
68
- */
69
- withConcurrency(n: number): Source<T, E>;
70
- /**
71
- * Sets the maximum number of buffered results before backpressure is applied to the stream. If the buffer is full, the stream will pause until there is space in the buffer for new results.
72
- */
73
- withBufferSize(n: number): Source<T, E>;
74
- }
75
- //# sourceMappingURL=source.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../../src/anabranch/streams/source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,MAAM,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC;IAS/C,OAAO,CAAC,QAAQ,CAAC,YAAY;IAR/B;;;;;;OAMG;IACH,OAAO;IAQP;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;IACzD,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;IAoB5D;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,EACrB,MAAM,EAAE,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GACzC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;IAIf;;OAEG;IACH,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;IAIxC;;OAEG;IACH,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;CAGxC"}
@@ -1,77 +0,0 @@
1
- import { _StreamImpl } from "./stream.js";
2
- /**
3
- * The entry point for creating a {@link Stream}. Wraps an async generator so
4
- * that yielded values become success results and any thrown error becomes a
5
- * single error result.
6
- *
7
- * Use {@link Source.from} to create a source from an existing `AsyncIterable`
8
- * or generator function. Use {@link Source.withConcurrency} and
9
- * {@link Source.withBufferSize} to configure parallel execution.
10
- *
11
- * @example
12
- * ```ts
13
- * import { Source } from "anabranch";
14
- *
15
- * const stream = Source.from<number, Error>(async function* () {
16
- * yield 1;
17
- * yield 2;
18
- * yield 3;
19
- * });
20
- *
21
- * const results = await stream.collect();
22
- * ```
23
- */
24
- export class Source extends _StreamImpl {
25
- /**
26
- * @param source An async generator function. Each yielded value becomes a
27
- * success result; any thrown error becomes an error result and terminates
28
- * the source.
29
- * @param concurrency Maximum number of concurrent operations. Defaults to `Infinity`.
30
- * @param bufferSize Maximum number of buffered results before backpressure is applied. Defaults to `Infinity`.
31
- */
32
- constructor(resultSource, concurrency = Infinity, bufferSize = Infinity) {
33
- super(resultSource, concurrency, bufferSize);
34
- Object.defineProperty(this, "resultSource", {
35
- enumerable: true,
36
- configurable: true,
37
- writable: true,
38
- value: resultSource
39
- });
40
- }
41
- static from(source) {
42
- const fn = typeof source === "function" ? source : async function* () {
43
- yield* source;
44
- };
45
- const resultSource = async function* () {
46
- try {
47
- for await (const value of fn()) {
48
- yield { type: "success", value };
49
- }
50
- }
51
- catch (error) {
52
- yield { type: "error", error: error };
53
- }
54
- };
55
- return new Source(resultSource);
56
- }
57
- /**
58
- * Creates a {@link Source} from an async generator that yields {@link Result}
59
- * values directly. This is useful when you want to yield both successes and
60
- * errors from the source without terminating it on the first error.
61
- */
62
- static fromResults(source) {
63
- return new Source(source);
64
- }
65
- /**
66
- * Sets the maximum number of concurrent operations for the stream.
67
- */
68
- withConcurrency(n) {
69
- return new Source(this.resultSource, n, this.bufferSize);
70
- }
71
- /**
72
- * Sets the maximum number of buffered results before backpressure is applied to the stream. If the buffer is full, the stream will pause until there is space in the buffer for new results.
73
- */
74
- withBufferSize(n) {
75
- return new Source(this.resultSource, this.concurrency, n);
76
- }
77
- }