@versori/run 0.1.0-alpha.10 → 0.1.0-alpha.11

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 (155) hide show
  1. package/esm/_dnt.shims.d.ts +1 -5
  2. package/esm/_dnt.shims.d.ts.map +1 -1
  3. package/esm/_dnt.shims.js +1 -5
  4. package/esm/deps/jsr.io/@std/fs/1.0.16/exists.d.ts +1 -0
  5. package/esm/deps/jsr.io/@std/fs/1.0.16/exists.d.ts.map +1 -1
  6. package/esm/deps/jsr.io/@std/fs/1.0.16/exists.js +10 -12
  7. package/esm/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts +0 -21
  8. package/esm/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts.map +1 -1
  9. package/esm/deps/jsr.io/@std/log/0.224.14/file_handler.d.ts +2 -3
  10. package/esm/deps/jsr.io/@std/log/0.224.14/file_handler.d.ts.map +1 -1
  11. package/esm/deps/jsr.io/@std/log/0.224.14/file_handler.js +1 -2
  12. package/esm/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.d.ts.map +1 -1
  13. package/esm/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.js +6 -8
  14. package/esm/src/dsl/http/versori/configloader.d.ts.map +1 -1
  15. package/esm/src/dsl/http/versori/configloader.js +2 -3
  16. package/esm/src/dsl/http/versori/internalauth.d.ts.map +1 -1
  17. package/esm/src/dsl/http/versori/internalauth.js +5 -6
  18. package/esm/src/dsl/http/versori/platformapi.d.ts.map +1 -1
  19. package/esm/src/dsl/http/versori/platformapi.js +3 -4
  20. package/esm/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
  21. package/esm/src/dsl/http/versori/roundtripper.js +4 -5
  22. package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
  23. package/esm/src/interpreter/memory/MemoryInterpreter.js +7 -5
  24. package/esm/src/kv/nats/NatsKeyValueProvider.d.ts +1 -2
  25. package/esm/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
  26. package/esm/src/kv/nats/NatsKeyValueProvider.js +8 -9
  27. package/package.json +2 -6
  28. package/script/_dnt.shims.d.ts +1 -5
  29. package/script/_dnt.shims.d.ts.map +1 -1
  30. package/script/_dnt.shims.js +2 -7
  31. package/script/deps/jsr.io/@std/fs/1.0.16/exists.d.ts +1 -0
  32. package/script/deps/jsr.io/@std/fs/1.0.16/exists.d.ts.map +1 -1
  33. package/script/deps/jsr.io/@std/fs/1.0.16/exists.js +10 -35
  34. package/script/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts +0 -21
  35. package/script/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts.map +1 -1
  36. package/script/deps/jsr.io/@std/log/0.224.14/file_handler.d.ts +2 -3
  37. package/script/deps/jsr.io/@std/log/0.224.14/file_handler.d.ts.map +1 -1
  38. package/script/deps/jsr.io/@std/log/0.224.14/file_handler.js +1 -25
  39. package/script/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.d.ts.map +1 -1
  40. package/script/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.js +6 -31
  41. package/script/src/dsl/http/versori/configloader.d.ts.map +1 -1
  42. package/script/src/dsl/http/versori/configloader.js +2 -26
  43. package/script/src/dsl/http/versori/internalauth.d.ts.map +1 -1
  44. package/script/src/dsl/http/versori/internalauth.js +5 -29
  45. package/script/src/dsl/http/versori/platformapi.d.ts.map +1 -1
  46. package/script/src/dsl/http/versori/platformapi.js +3 -27
  47. package/script/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
  48. package/script/src/dsl/http/versori/roundtripper.js +4 -28
  49. package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
  50. package/script/src/interpreter/memory/MemoryInterpreter.js +7 -28
  51. package/script/src/kv/nats/NatsKeyValueProvider.d.ts +1 -2
  52. package/script/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
  53. package/script/src/kv/nats/NatsKeyValueProvider.js +10 -34
  54. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.d.ts +0 -3
  55. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.d.ts.map +0 -1
  56. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.js +0 -28
  57. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts +0 -36
  58. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts.map +0 -1
  59. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.js +0 -329
  60. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.d.ts +0 -3
  61. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.d.ts.map +0 -1
  62. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.js +0 -2
  63. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.d.ts +0 -2
  64. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.d.ts.map +0 -1
  65. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.js +0 -2
  66. package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts +0 -9
  67. package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts.map +0 -1
  68. package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.js +0 -2
  69. package/esm/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts +0 -21
  70. package/esm/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts.map +0 -1
  71. package/esm/deps/jsr.io/@std/bytes/1.0.5/concat.js +0 -32
  72. package/esm/deps/jsr.io/@std/bytes/1.0.5/copy.d.ts +0 -41
  73. package/esm/deps/jsr.io/@std/bytes/1.0.5/copy.d.ts.map +0 -1
  74. package/esm/deps/jsr.io/@std/bytes/1.0.5/copy.js +0 -50
  75. package/esm/deps/jsr.io/@std/io/0.225.2/_common.d.ts +0 -3
  76. package/esm/deps/jsr.io/@std/io/0.225.2/_common.d.ts.map +0 -1
  77. package/esm/deps/jsr.io/@std/io/0.225.2/_common.js +0 -8
  78. package/esm/deps/jsr.io/@std/io/0.225.2/_constants.d.ts +0 -3
  79. package/esm/deps/jsr.io/@std/io/0.225.2/_constants.d.ts.map +0 -1
  80. package/esm/deps/jsr.io/@std/io/0.225.2/_constants.js +0 -4
  81. package/esm/deps/jsr.io/@std/io/0.225.2/buffer.d.ts +0 -321
  82. package/esm/deps/jsr.io/@std/io/0.225.2/buffer.d.ts.map +0 -1
  83. package/esm/deps/jsr.io/@std/io/0.225.2/buffer.js +0 -488
  84. package/esm/deps/jsr.io/@std/io/0.225.2/copy.d.ts +0 -25
  85. package/esm/deps/jsr.io/@std/io/0.225.2/copy.d.ts.map +0 -1
  86. package/esm/deps/jsr.io/@std/io/0.225.2/copy.js +0 -36
  87. package/esm/deps/jsr.io/@std/io/0.225.2/iterate_reader.d.ts +0 -80
  88. package/esm/deps/jsr.io/@std/io/0.225.2/iterate_reader.d.ts.map +0 -1
  89. package/esm/deps/jsr.io/@std/io/0.225.2/iterate_reader.js +0 -96
  90. package/esm/deps/jsr.io/@std/io/0.225.2/mod.d.ts +0 -25
  91. package/esm/deps/jsr.io/@std/io/0.225.2/mod.d.ts.map +0 -1
  92. package/esm/deps/jsr.io/@std/io/0.225.2/mod.js +0 -25
  93. package/esm/deps/jsr.io/@std/io/0.225.2/read_all.d.ts +0 -42
  94. package/esm/deps/jsr.io/@std/io/0.225.2/read_all.d.ts.map +0 -1
  95. package/esm/deps/jsr.io/@std/io/0.225.2/read_all.js +0 -72
  96. package/esm/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.d.ts +0 -20
  97. package/esm/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.d.ts.map +0 -1
  98. package/esm/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.js +0 -36
  99. package/esm/deps/jsr.io/@std/io/0.225.2/to_readable_stream.d.ts +0 -40
  100. package/esm/deps/jsr.io/@std/io/0.225.2/to_readable_stream.d.ts.map +0 -1
  101. package/esm/deps/jsr.io/@std/io/0.225.2/to_readable_stream.js +0 -54
  102. package/esm/deps/jsr.io/@std/io/0.225.2/to_writable_stream.d.ts +0 -27
  103. package/esm/deps/jsr.io/@std/io/0.225.2/to_writable_stream.d.ts.map +0 -1
  104. package/esm/deps/jsr.io/@std/io/0.225.2/to_writable_stream.js +0 -44
  105. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.d.ts +0 -3
  106. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.d.ts.map +0 -1
  107. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.js +0 -31
  108. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts +0 -36
  109. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts.map +0 -1
  110. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.js +0 -357
  111. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.d.ts +0 -3
  112. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.d.ts.map +0 -1
  113. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.js +0 -20
  114. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.d.ts +0 -2
  115. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.d.ts.map +0 -1
  116. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.js +0 -5
  117. package/script/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts +0 -9
  118. package/script/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts.map +0 -1
  119. package/script/deps/jsr.io/@std/bytes/1.0.5/_types.js +0 -3
  120. package/script/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts +0 -21
  121. package/script/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts.map +0 -1
  122. package/script/deps/jsr.io/@std/bytes/1.0.5/concat.js +0 -35
  123. package/script/deps/jsr.io/@std/bytes/1.0.5/copy.d.ts +0 -41
  124. package/script/deps/jsr.io/@std/bytes/1.0.5/copy.d.ts.map +0 -1
  125. package/script/deps/jsr.io/@std/bytes/1.0.5/copy.js +0 -53
  126. package/script/deps/jsr.io/@std/io/0.225.2/_common.d.ts +0 -3
  127. package/script/deps/jsr.io/@std/io/0.225.2/_common.d.ts.map +0 -1
  128. package/script/deps/jsr.io/@std/io/0.225.2/_common.js +0 -11
  129. package/script/deps/jsr.io/@std/io/0.225.2/_constants.d.ts +0 -3
  130. package/script/deps/jsr.io/@std/io/0.225.2/_constants.d.ts.map +0 -1
  131. package/script/deps/jsr.io/@std/io/0.225.2/_constants.js +0 -7
  132. package/script/deps/jsr.io/@std/io/0.225.2/buffer.d.ts +0 -321
  133. package/script/deps/jsr.io/@std/io/0.225.2/buffer.d.ts.map +0 -1
  134. package/script/deps/jsr.io/@std/io/0.225.2/buffer.js +0 -492
  135. package/script/deps/jsr.io/@std/io/0.225.2/copy.d.ts +0 -25
  136. package/script/deps/jsr.io/@std/io/0.225.2/copy.d.ts.map +0 -1
  137. package/script/deps/jsr.io/@std/io/0.225.2/copy.js +0 -39
  138. package/script/deps/jsr.io/@std/io/0.225.2/iterate_reader.d.ts +0 -80
  139. package/script/deps/jsr.io/@std/io/0.225.2/iterate_reader.d.ts.map +0 -1
  140. package/script/deps/jsr.io/@std/io/0.225.2/iterate_reader.js +0 -100
  141. package/script/deps/jsr.io/@std/io/0.225.2/mod.d.ts +0 -25
  142. package/script/deps/jsr.io/@std/io/0.225.2/mod.d.ts.map +0 -1
  143. package/script/deps/jsr.io/@std/io/0.225.2/mod.js +0 -41
  144. package/script/deps/jsr.io/@std/io/0.225.2/read_all.d.ts +0 -42
  145. package/script/deps/jsr.io/@std/io/0.225.2/read_all.d.ts.map +0 -1
  146. package/script/deps/jsr.io/@std/io/0.225.2/read_all.js +0 -76
  147. package/script/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.d.ts +0 -20
  148. package/script/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.d.ts.map +0 -1
  149. package/script/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.js +0 -39
  150. package/script/deps/jsr.io/@std/io/0.225.2/to_readable_stream.d.ts +0 -40
  151. package/script/deps/jsr.io/@std/io/0.225.2/to_readable_stream.d.ts.map +0 -1
  152. package/script/deps/jsr.io/@std/io/0.225.2/to_readable_stream.js +0 -57
  153. package/script/deps/jsr.io/@std/io/0.225.2/to_writable_stream.d.ts +0 -27
  154. package/script/deps/jsr.io/@std/io/0.225.2/to_writable_stream.d.ts.map +0 -1
  155. package/script/deps/jsr.io/@std/io/0.225.2/to_writable_stream.js +0 -47
@@ -1,488 +0,0 @@
1
- // Copyright 2018-2025 the Deno authors. MIT license.
2
- // This module is browser compatible.
3
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
4
- if (kind === "m") throw new TypeError("Private method is not writable");
5
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
6
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
7
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
8
- };
9
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
10
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
11
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
12
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
13
- };
14
- var _Buffer_instances, _Buffer_buf, _Buffer_off, _Buffer_tryGrowByReslice, _Buffer_reslice, _Buffer_grow;
15
- import { copy } from "../../bytes/1.0.5/copy.js";
16
- // MIN_READ is the minimum ArrayBuffer size passed to a read call by
17
- // buffer.ReadFrom. As long as the Buffer has at least MIN_READ bytes beyond
18
- // what is required to hold the contents of r, readFrom() will not grow the
19
- // underlying buffer.
20
- const MIN_READ = 32 * 1024;
21
- const MAX_SIZE = 2 ** 32 - 2;
22
- /**
23
- * A variable-sized buffer of bytes with `read()` and `write()` methods.
24
- *
25
- * Buffer is almost always used with some I/O like files and sockets. It allows
26
- * one to buffer up a download from a socket. Buffer grows and shrinks as
27
- * necessary.
28
- *
29
- * Buffer is NOT the same thing as Node's Buffer. Node's Buffer was created in
30
- * 2009 before JavaScript had the concept of ArrayBuffers. It's simply a
31
- * non-standard ArrayBuffer.
32
- *
33
- * ArrayBuffer is a fixed memory allocation. Buffer is implemented on top of
34
- * ArrayBuffer.
35
- *
36
- * Based on {@link https://golang.org/pkg/bytes/#Buffer | Go Buffer}.
37
- *
38
- * @example Usage
39
- * ```ts
40
- * import { Buffer } from "@std/io/buffer";
41
- * import { assertEquals } from "@std/assert/equals";
42
- *
43
- * const buf = new Buffer();
44
- * await buf.write(new TextEncoder().encode("Hello, "));
45
- * await buf.write(new TextEncoder().encode("world!"));
46
- *
47
- * const data = new Uint8Array(13);
48
- * await buf.read(data);
49
- *
50
- * assertEquals(new TextDecoder().decode(data), "Hello, world!");
51
- * ```
52
- */
53
- export class Buffer {
54
- /**
55
- * Constructs a new instance with the specified {@linkcode ArrayBuffer} as its
56
- * initial contents.
57
- *
58
- * @param ab The ArrayBuffer to use as the initial contents of the buffer.
59
- */
60
- constructor(ab) {
61
- _Buffer_instances.add(this);
62
- _Buffer_buf.set(this, void 0); // contents are the bytes buf[off : len(buf)]
63
- _Buffer_off.set(this, 0); // read at buf[off], write at buf[buf.byteLength]
64
- if (ab === undefined) {
65
- __classPrivateFieldSet(this, _Buffer_buf, new Uint8Array(0), "f");
66
- }
67
- else if (ab instanceof SharedArrayBuffer) {
68
- // Note: This is necessary to avoid type error
69
- __classPrivateFieldSet(this, _Buffer_buf, new Uint8Array(ab), "f");
70
- }
71
- else {
72
- __classPrivateFieldSet(this, _Buffer_buf, new Uint8Array(ab), "f");
73
- }
74
- }
75
- /**
76
- * Returns a slice holding the unread portion of the buffer.
77
- *
78
- * The slice is valid for use only until the next buffer modification (that
79
- * is, only until the next call to a method like `read()`, `write()`,
80
- * `reset()`, or `truncate()`). If `options.copy` is false the slice aliases the buffer content at
81
- * least until the next buffer modification, so immediate changes to the
82
- * slice will affect the result of future reads.
83
- *
84
- * @example Usage
85
- * ```ts
86
- * import { Buffer } from "@std/io/buffer";
87
- * import { assertEquals } from "@std/assert/equals";
88
- *
89
- * const buf = new Buffer();
90
- * await buf.write(new TextEncoder().encode("Hello, world!"));
91
- *
92
- * const slice = buf.bytes();
93
- * assertEquals(new TextDecoder().decode(slice), "Hello, world!");
94
- * ```
95
- *
96
- * @param options The options for the slice.
97
- * @returns A slice holding the unread portion of the buffer.
98
- */
99
- bytes(options = { copy: true }) {
100
- if (options.copy === false)
101
- return __classPrivateFieldGet(this, _Buffer_buf, "f").subarray(__classPrivateFieldGet(this, _Buffer_off, "f"));
102
- return __classPrivateFieldGet(this, _Buffer_buf, "f").slice(__classPrivateFieldGet(this, _Buffer_off, "f"));
103
- }
104
- /**
105
- * Returns whether the unread portion of the buffer is empty.
106
- *
107
- * @example Usage
108
- * ```ts
109
- * import { Buffer } from "@std/io/buffer";
110
- * import { assertEquals } from "@std/assert/equals";
111
- *
112
- * const buf = new Buffer();
113
- * assertEquals(buf.empty(), true);
114
- * await buf.write(new TextEncoder().encode("Hello, world!"));
115
- * assertEquals(buf.empty(), false);
116
- * ```
117
- *
118
- * @returns `true` if the unread portion of the buffer is empty, `false`
119
- * otherwise.
120
- */
121
- empty() {
122
- return __classPrivateFieldGet(this, _Buffer_buf, "f").byteLength <= __classPrivateFieldGet(this, _Buffer_off, "f");
123
- }
124
- /**
125
- * A read only number of bytes of the unread portion of the buffer.
126
- *
127
- * @example Usage
128
- * ```ts
129
- * import { Buffer } from "@std/io/buffer";
130
- * import { assertEquals } from "@std/assert/equals";
131
- *
132
- * const buf = new Buffer();
133
- * await buf.write(new TextEncoder().encode("Hello, world!"));
134
- *
135
- * assertEquals(buf.length, 13);
136
- * ```
137
- *
138
- * @returns The number of bytes of the unread portion of the buffer.
139
- */
140
- get length() {
141
- return __classPrivateFieldGet(this, _Buffer_buf, "f").byteLength - __classPrivateFieldGet(this, _Buffer_off, "f");
142
- }
143
- /**
144
- * The read only capacity of the buffer's underlying byte slice, that is,
145
- * the total space allocated for the buffer's data.
146
- *
147
- * @example Usage
148
- * ```ts
149
- * import { Buffer } from "@std/io/buffer";
150
- * import { assertEquals } from "@std/assert/equals";
151
- *
152
- * const buf = new Buffer();
153
- * assertEquals(buf.capacity, 0);
154
- * await buf.write(new TextEncoder().encode("Hello, world!"));
155
- * assertEquals(buf.capacity, 13);
156
- * ```
157
- *
158
- * @returns The capacity of the buffer.
159
- */
160
- get capacity() {
161
- return __classPrivateFieldGet(this, _Buffer_buf, "f").buffer.byteLength;
162
- }
163
- /**
164
- * Discards all but the first `n` unread bytes from the buffer but
165
- * continues to use the same allocated storage. It throws if `n` is
166
- * negative or greater than the length of the buffer.
167
- *
168
- * @example Usage
169
- * ```ts
170
- * import { Buffer } from "@std/io/buffer";
171
- * import { assertEquals } from "@std/assert/equals";
172
- *
173
- * const buf = new Buffer();
174
- * await buf.write(new TextEncoder().encode("Hello, world!"));
175
- * buf.truncate(6);
176
- * assertEquals(buf.length, 6);
177
- * ```
178
- *
179
- * @param n The number of bytes to keep.
180
- */
181
- truncate(n) {
182
- if (n === 0) {
183
- this.reset();
184
- return;
185
- }
186
- if (n < 0 || n > this.length) {
187
- throw new Error("Buffer truncation out of range");
188
- }
189
- __classPrivateFieldGet(this, _Buffer_instances, "m", _Buffer_reslice).call(this, __classPrivateFieldGet(this, _Buffer_off, "f") + n);
190
- }
191
- /**
192
- * Resets the contents
193
- *
194
- * @example Usage
195
- * ```ts
196
- * import { Buffer } from "@std/io/buffer";
197
- * import { assertEquals } from "@std/assert/equals";
198
- *
199
- * const buf = new Buffer();
200
- * await buf.write(new TextEncoder().encode("Hello, world!"));
201
- * buf.reset();
202
- * assertEquals(buf.length, 0);
203
- * ```
204
- */
205
- reset() {
206
- __classPrivateFieldGet(this, _Buffer_instances, "m", _Buffer_reslice).call(this, 0);
207
- __classPrivateFieldSet(this, _Buffer_off, 0, "f");
208
- }
209
- /**
210
- * Reads the next `p.length` bytes from the buffer or until the buffer is
211
- * drained. Returns the number of bytes read. If the buffer has no data to
212
- * return, the return is EOF (`null`).
213
- *
214
- * @example Usage
215
- * ```ts
216
- * import { Buffer } from "@std/io/buffer";
217
- * import { assertEquals } from "@std/assert/equals";
218
- *
219
- * const buf = new Buffer();
220
- * await buf.write(new TextEncoder().encode("Hello, world!"));
221
- *
222
- * const data = new Uint8Array(5);
223
- * const res = await buf.read(data);
224
- *
225
- * assertEquals(res, 5);
226
- * assertEquals(new TextDecoder().decode(data), "Hello");
227
- * ```
228
- *
229
- * @param p The buffer to read data into.
230
- * @returns The number of bytes read.
231
- */
232
- readSync(p) {
233
- if (this.empty()) {
234
- // Buffer is empty, reset to recover space.
235
- this.reset();
236
- if (p.byteLength === 0) {
237
- // this edge case is tested in 'bufferReadEmptyAtEOF' test
238
- return 0;
239
- }
240
- return null;
241
- }
242
- const nread = copy(__classPrivateFieldGet(this, _Buffer_buf, "f").subarray(__classPrivateFieldGet(this, _Buffer_off, "f")), p);
243
- __classPrivateFieldSet(this, _Buffer_off, __classPrivateFieldGet(this, _Buffer_off, "f") + nread, "f");
244
- return nread;
245
- }
246
- /**
247
- * Reads the next `p.length` bytes from the buffer or until the buffer is
248
- * drained. Resolves to the number of bytes read. If the buffer has no
249
- * data to return, resolves to EOF (`null`).
250
- *
251
- * NOTE: This methods reads bytes synchronously; it's provided for
252
- * compatibility with `Reader` interfaces.
253
- *
254
- * @example Usage
255
- * ```ts
256
- * import { Buffer } from "@std/io/buffer";
257
- * import { assertEquals } from "@std/assert/equals";
258
- *
259
- * const buf = new Buffer();
260
- * await buf.write(new TextEncoder().encode("Hello, world!"));
261
- *
262
- * const data = new Uint8Array(5);
263
- * const res = await buf.read(data);
264
- *
265
- * assertEquals(res, 5);
266
- * assertEquals(new TextDecoder().decode(data), "Hello");
267
- * ```
268
- *
269
- * @param p The buffer to read data into.
270
- * @returns The number of bytes read.
271
- */
272
- read(p) {
273
- const rr = this.readSync(p);
274
- return Promise.resolve(rr);
275
- }
276
- /**
277
- * Writes the given data to the buffer.
278
- *
279
- * @example Usage
280
- * ```ts
281
- * import { Buffer } from "@std/io/buffer";
282
- * import { assertEquals } from "@std/assert/equals";
283
- *
284
- * const buf = new Buffer();
285
- * const data = new TextEncoder().encode("Hello, world!");
286
- * buf.writeSync(data);
287
- *
288
- * const slice = buf.bytes();
289
- * assertEquals(new TextDecoder().decode(slice), "Hello, world!");
290
- * ```
291
- *
292
- * @param p The data to write to the buffer.
293
- * @returns The number of bytes written.
294
- */
295
- writeSync(p) {
296
- const m = __classPrivateFieldGet(this, _Buffer_instances, "m", _Buffer_grow).call(this, p.byteLength);
297
- return copy(p, __classPrivateFieldGet(this, _Buffer_buf, "f"), m);
298
- }
299
- /**
300
- * Writes the given data to the buffer. Resolves to the number of bytes
301
- * written.
302
- *
303
- * > [!NOTE]
304
- * > This methods writes bytes synchronously; it's provided for compatibility
305
- * > with the {@linkcode Writer} interface.
306
- *
307
- * @example Usage
308
- * ```ts
309
- * import { Buffer } from "@std/io/buffer";
310
- * import { assertEquals } from "@std/assert/equals";
311
- *
312
- * const buf = new Buffer();
313
- * const data = new TextEncoder().encode("Hello, world!");
314
- * await buf.write(data);
315
- *
316
- * const slice = buf.bytes();
317
- * assertEquals(new TextDecoder().decode(slice), "Hello, world!");
318
- * ```
319
- *
320
- * @param p The data to write to the buffer.
321
- * @returns The number of bytes written.
322
- */
323
- write(p) {
324
- const n = this.writeSync(p);
325
- return Promise.resolve(n);
326
- }
327
- /** Grows the buffer's capacity, if necessary, to guarantee space for
328
- * another `n` bytes. After `.grow(n)`, at least `n` bytes can be written to
329
- * the buffer without another allocation. If `n` is negative, `.grow()` will
330
- * throw. If the buffer can't grow it will throw an error.
331
- *
332
- * Based on Go Lang's
333
- * {@link https://golang.org/pkg/bytes/#Buffer.Grow | Buffer.Grow}.
334
- *
335
- * @example Usage
336
- * ```ts
337
- * import { Buffer } from "@std/io/buffer";
338
- * import { assertEquals } from "@std/assert/equals";
339
- *
340
- * const buf = new Buffer();
341
- * buf.grow(10);
342
- * assertEquals(buf.capacity, 10);
343
- * ```
344
- *
345
- * @param n The number of bytes to grow the buffer by.
346
- */
347
- grow(n) {
348
- if (n < 0) {
349
- throw new Error("Buffer growth cannot be negative");
350
- }
351
- const m = __classPrivateFieldGet(this, _Buffer_instances, "m", _Buffer_grow).call(this, n);
352
- __classPrivateFieldGet(this, _Buffer_instances, "m", _Buffer_reslice).call(this, m);
353
- }
354
- /**
355
- * Reads data from `r` until EOF (`null`) and appends it to the buffer,
356
- * growing the buffer as needed. It resolves to the number of bytes read.
357
- * If the buffer becomes too large, `.readFrom()` will reject with an error.
358
- *
359
- * Based on Go Lang's
360
- * {@link https://golang.org/pkg/bytes/#Buffer.ReadFrom | Buffer.ReadFrom}.
361
- *
362
- * @example Usage
363
- * ```ts
364
- * import { Buffer } from "@std/io/buffer";
365
- * import { assertEquals } from "@std/assert/equals";
366
- *
367
- * const buf = new Buffer();
368
- * const r = new Buffer(new TextEncoder().encode("Hello, world!"));
369
- * const n = await buf.readFrom(r);
370
- *
371
- * assertEquals(n, 13);
372
- * ```
373
- *
374
- * @param r The reader to read from.
375
- * @returns The number of bytes read.
376
- */
377
- async readFrom(r) {
378
- let n = 0;
379
- const tmp = new Uint8Array(MIN_READ);
380
- while (true) {
381
- const shouldGrow = this.capacity - this.length < MIN_READ;
382
- // read into tmp buffer if there's not enough room
383
- // otherwise read directly into the internal buffer
384
- const buf = shouldGrow
385
- ? tmp
386
- : new Uint8Array(__classPrivateFieldGet(this, _Buffer_buf, "f").buffer, this.length);
387
- const nread = await r.read(buf);
388
- if (nread === null) {
389
- return n;
390
- }
391
- // write will grow if needed
392
- if (shouldGrow)
393
- this.writeSync(buf.subarray(0, nread));
394
- else
395
- __classPrivateFieldGet(this, _Buffer_instances, "m", _Buffer_reslice).call(this, this.length + nread);
396
- n += nread;
397
- }
398
- }
399
- /** Reads data from `r` until EOF (`null`) and appends it to the buffer,
400
- * growing the buffer as needed. It returns the number of bytes read. If the
401
- * buffer becomes too large, `.readFromSync()` will throw an error.
402
- *
403
- * Based on Go Lang's
404
- * {@link https://golang.org/pkg/bytes/#Buffer.ReadFrom | Buffer.ReadFrom}.
405
- *
406
- * @example Usage
407
- * ```ts
408
- * import { Buffer } from "@std/io/buffer";
409
- * import { assertEquals } from "@std/assert/equals";
410
- *
411
- * const buf = new Buffer();
412
- * const r = new Buffer(new TextEncoder().encode("Hello, world!"));
413
- * const n = buf.readFromSync(r);
414
- *
415
- * assertEquals(n, 13);
416
- * ```
417
- *
418
- * @param r The reader to read from.
419
- * @returns The number of bytes read.
420
- */
421
- readFromSync(r) {
422
- let n = 0;
423
- const tmp = new Uint8Array(MIN_READ);
424
- while (true) {
425
- const shouldGrow = this.capacity - this.length < MIN_READ;
426
- // read into tmp buffer if there's not enough room
427
- // otherwise read directly into the internal buffer
428
- const buf = shouldGrow
429
- ? tmp
430
- : new Uint8Array(__classPrivateFieldGet(this, _Buffer_buf, "f").buffer, this.length);
431
- const nread = r.readSync(buf);
432
- if (nread === null) {
433
- return n;
434
- }
435
- // write will grow if needed
436
- if (shouldGrow)
437
- this.writeSync(buf.subarray(0, nread));
438
- else
439
- __classPrivateFieldGet(this, _Buffer_instances, "m", _Buffer_reslice).call(this, this.length + nread);
440
- n += nread;
441
- }
442
- }
443
- }
444
- _Buffer_buf = new WeakMap(), _Buffer_off = new WeakMap(), _Buffer_instances = new WeakSet(), _Buffer_tryGrowByReslice = function _Buffer_tryGrowByReslice(n) {
445
- const l = __classPrivateFieldGet(this, _Buffer_buf, "f").byteLength;
446
- if (n <= this.capacity - l) {
447
- __classPrivateFieldGet(this, _Buffer_instances, "m", _Buffer_reslice).call(this, l + n);
448
- return l;
449
- }
450
- return -1;
451
- }, _Buffer_reslice = function _Buffer_reslice(len) {
452
- if (len > __classPrivateFieldGet(this, _Buffer_buf, "f").buffer.byteLength) {
453
- throw new RangeError("Length is greater than buffer capacity");
454
- }
455
- __classPrivateFieldSet(this, _Buffer_buf, new Uint8Array(__classPrivateFieldGet(this, _Buffer_buf, "f").buffer, 0, len), "f");
456
- }, _Buffer_grow = function _Buffer_grow(n) {
457
- const m = this.length;
458
- // If buffer is empty, reset to recover space.
459
- if (m === 0 && __classPrivateFieldGet(this, _Buffer_off, "f") !== 0) {
460
- this.reset();
461
- }
462
- // Fast: Try to grow by means of a reslice.
463
- const i = __classPrivateFieldGet(this, _Buffer_instances, "m", _Buffer_tryGrowByReslice).call(this, n);
464
- if (i >= 0) {
465
- return i;
466
- }
467
- const c = this.capacity;
468
- if (n <= Math.floor(c / 2) - m) {
469
- // We can slide things down instead of allocating a new
470
- // ArrayBuffer. We only need m+n <= c to slide, but
471
- // we instead let capacity get twice as large so we
472
- // don't spend all our time copying.
473
- copy(__classPrivateFieldGet(this, _Buffer_buf, "f").subarray(__classPrivateFieldGet(this, _Buffer_off, "f")), __classPrivateFieldGet(this, _Buffer_buf, "f"));
474
- }
475
- else if (c + n > MAX_SIZE) {
476
- throw new Error(`The buffer cannot be grown beyond the maximum size of "${MAX_SIZE}"`);
477
- }
478
- else {
479
- // Not enough space anywhere, we need to allocate.
480
- const buf = new Uint8Array(Math.min(2 * c + n, MAX_SIZE));
481
- copy(__classPrivateFieldGet(this, _Buffer_buf, "f").subarray(__classPrivateFieldGet(this, _Buffer_off, "f")), buf);
482
- __classPrivateFieldSet(this, _Buffer_buf, buf, "f");
483
- }
484
- // Restore this.#off and len(this.#buf).
485
- __classPrivateFieldSet(this, _Buffer_off, 0, "f");
486
- __classPrivateFieldGet(this, _Buffer_instances, "m", _Buffer_reslice).call(this, Math.min(m + n, MAX_SIZE));
487
- return m;
488
- };
@@ -1,25 +0,0 @@
1
- import type { Reader, Writer } from "./types.js";
2
- /**
3
- * Copies from `src` to `dst` until either EOF (`null`) is read from `src` or
4
- * an error occurs. It resolves to the number of bytes copied or rejects with
5
- * the first error encountered while copying.
6
- *
7
- * @example Usage
8
- * ```ts ignore
9
- * import { copy } from "@std/io/copy";
10
- *
11
- * const source = await Deno.open("my_file.txt");
12
- * const bytesCopied1 = await copy(source, Deno.stdout);
13
- * const destination = await Deno.create("my_file_2.txt");
14
- * const bytesCopied2 = await copy(source, destination);
15
- * ```
16
- *
17
- * @param src The source to copy from
18
- * @param dst The destination to copy to
19
- * @param options Can be used to tune size of the buffer. Default size is 32kB
20
- * @returns Number of bytes copied
21
- */
22
- export declare function copy(src: Reader, dst: Writer, options?: {
23
- bufSize?: number;
24
- }): Promise<number>;
25
- //# sourceMappingURL=copy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"copy.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/io/0.225.2/copy.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,IAAI,CACxB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GACA,OAAO,CAAC,MAAM,CAAC,CAUjB"}
@@ -1,36 +0,0 @@
1
- // Copyright 2018-2025 the Deno authors. MIT license.
2
- // This module is browser compatible.
3
- import { DEFAULT_BUFFER_SIZE } from "./_constants.js";
4
- import { writeAll } from "./write_all.js";
5
- /**
6
- * Copies from `src` to `dst` until either EOF (`null`) is read from `src` or
7
- * an error occurs. It resolves to the number of bytes copied or rejects with
8
- * the first error encountered while copying.
9
- *
10
- * @example Usage
11
- * ```ts ignore
12
- * import { copy } from "@std/io/copy";
13
- *
14
- * const source = await Deno.open("my_file.txt");
15
- * const bytesCopied1 = await copy(source, Deno.stdout);
16
- * const destination = await Deno.create("my_file_2.txt");
17
- * const bytesCopied2 = await copy(source, destination);
18
- * ```
19
- *
20
- * @param src The source to copy from
21
- * @param dst The destination to copy to
22
- * @param options Can be used to tune size of the buffer. Default size is 32kB
23
- * @returns Number of bytes copied
24
- */
25
- export async function copy(src, dst, options) {
26
- let n = 0;
27
- const b = new Uint8Array(options?.bufSize ?? DEFAULT_BUFFER_SIZE);
28
- while (true) {
29
- const result = await src.read(b);
30
- if (result === null)
31
- break;
32
- await writeAll(dst, b.subarray(0, result));
33
- n += result;
34
- }
35
- return n;
36
- }
@@ -1,80 +0,0 @@
1
- import type { Reader, ReaderSync } from "./types.js";
2
- export type { Reader, ReaderSync };
3
- /**
4
- * Turns a {@linkcode Reader} into an async iterator.
5
- *
6
- * @example Usage
7
- * ```ts no-assert
8
- * import { iterateReader } from "@std/io/iterate-reader";
9
- *
10
- * using file = await Deno.open("README.md");
11
- * for await (const chunk of iterateReader(file)) {
12
- * console.log(chunk);
13
- * }
14
- * ```
15
- *
16
- * @example Usage with buffer size
17
- * ```ts no-assert
18
- * import { iterateReader } from "@std/io/iterate-reader";
19
- *
20
- * using file = await Deno.open("README.md");
21
- * const iter = iterateReader(file, {
22
- * bufSize: 1024 * 1024
23
- * });
24
- * for await (const chunk of iter) {
25
- * console.log(chunk);
26
- * }
27
- * ```
28
- *
29
- * @param reader The reader to read from
30
- * @param options The options
31
- * @param options.bufSize The size of the buffer to use
32
- * @returns The async iterator of Uint8Array chunks
33
- */
34
- export declare function iterateReader(reader: Reader, options?: {
35
- bufSize?: number;
36
- }): AsyncIterableIterator<Uint8Array>;
37
- /**
38
- * Turns a {@linkcode ReaderSync} into an iterator.
39
- *
40
- * @example Usage
41
- * ```ts
42
- * import { iterateReaderSync } from "@std/io/iterate-reader";
43
- * import { assert } from "@std/assert/assert"
44
- *
45
- * using file = Deno.openSync("README.md");
46
- * for (const chunk of iterateReaderSync(file)) {
47
- * assert(chunk instanceof Uint8Array);
48
- * }
49
- * ```
50
- *
51
- * Second argument can be used to tune size of a buffer.
52
- * Default size of the buffer is 32kB.
53
- *
54
- * @example Usage with buffer size
55
- * ```ts
56
- * import { iterateReaderSync } from "@std/io/iterate-reader";
57
- * import { assert } from "@std/assert/assert"
58
- *
59
- * using file = await Deno.open("README.md");
60
- * const iter = iterateReaderSync(file, {
61
- * bufSize: 1024 * 1024
62
- * });
63
- * for (const chunk of iter) {
64
- * assert(chunk instanceof Uint8Array);
65
- * }
66
- * ```
67
- *
68
- * Iterator uses an internal buffer of fixed size for efficiency; it returns
69
- * a view on that buffer on each iteration. It is therefore caller's
70
- * responsibility to copy contents of the buffer if needed; otherwise the
71
- * next iteration will overwrite contents of previously returned chunk.
72
- *
73
- * @param reader The reader to read from
74
- * @param options The options
75
- * @returns The iterator of Uint8Array chunks
76
- */
77
- export declare function iterateReaderSync(reader: ReaderSync, options?: {
78
- bufSize?: number;
79
- }): IterableIterator<Uint8Array>;
80
- //# sourceMappingURL=iterate_reader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"iterate_reader.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/io/0.225.2/iterate_reader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAErD,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAuB,aAAa,CAClC,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GACA,qBAAqB,CAAC,UAAU,CAAC,CAWnC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAiB,iBAAiB,CAChC,MAAM,EAAE,UAAU,EAClB,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GACA,gBAAgB,CAAC,UAAU,CAAC,CAW9B"}