@versori/run 0.1.0-alpha.11 → 0.1.0-alpha.13
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/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.d.ts +3 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.d.ts.map +1 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.js +28 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts +35 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts.map +1 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.js +328 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.d.ts +3 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.js +2 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.d.ts +2 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.d.ts.map +1 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.js +2 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts +9 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.js +2 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts +21 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/concat.js +32 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/copy.d.ts +41 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/copy.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/copy.js +50 -0
- package/{script/deps/jsr.io/@std/fmt/1.0.6 → esm/deps/jsr.io/@std/fmt/1.0.5}/colors.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/fs/{1.0.16 → 1.0.11}/exists.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/io/0.225.2/_common.d.ts +3 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/_common.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/_common.js +8 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/_constants.d.ts +3 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/_constants.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/_constants.js +4 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/buffer.d.ts +321 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/buffer.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/buffer.js +488 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/copy.d.ts +25 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/copy.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/copy.js +36 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/iterate_reader.d.ts +80 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/iterate_reader.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/iterate_reader.js +96 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/mod.d.ts +25 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/mod.js +25 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/read_all.d.ts +42 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/read_all.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/read_all.js +72 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.d.ts +20 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.js +36 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/to_readable_stream.d.ts +40 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/to_readable_stream.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/to_readable_stream.js +54 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/to_writable_stream.d.ts +27 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/to_writable_stream.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/to_writable_stream.js +44 -0
- package/esm/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts +21 -0
- package/esm/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/log/0.224.14/console_handler.js +1 -1
- package/esm/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.js +1 -1
- package/esm/src/context/Context.d.ts +14 -4
- package/esm/src/context/Context.d.ts.map +1 -1
- package/esm/src/context/Context.js +16 -10
- package/esm/src/context/ContextProvider.d.ts +3 -4
- package/esm/src/context/ContextProvider.d.ts.map +1 -1
- package/esm/src/context/ContextProvider.js +5 -5
- package/esm/src/dsl/http/versori/platformapi.d.ts +2 -1
- package/esm/src/dsl/http/versori/platformapi.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/platformapi.js +12 -1
- package/esm/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/roundtripper.js +32 -35
- package/esm/src/dsl/triggers/WebhookTrigger.d.ts +45 -3
- package/esm/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/esm/src/dsl/triggers/WebhookTrigger.js +10 -6
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +6 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +67 -5
- package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/webhook.js +106 -32
- package/esm/src/kv/nats/NatsKeyValueProvider.d.ts +2 -1
- package/esm/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
- package/esm/src/kv/nats/NatsKeyValueProvider.js +1 -1
- package/package.json +2 -1
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.d.ts +3 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.d.ts.map +1 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.js +31 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts +35 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts.map +1 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.js +333 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.d.ts +3 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.d.ts.map +1 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.js +20 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.d.ts +2 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.d.ts.map +1 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.js +5 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts +9 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/_types.js +3 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts +21 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/concat.js +35 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/copy.d.ts +41 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/copy.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/copy.js +53 -0
- package/{esm/deps/jsr.io/@std/fmt/1.0.6 → script/deps/jsr.io/@std/fmt/1.0.5}/colors.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/fs/{1.0.16 → 1.0.11}/exists.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/io/0.225.2/_common.d.ts +3 -0
- package/script/deps/jsr.io/@std/io/0.225.2/_common.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/_common.js +11 -0
- package/script/deps/jsr.io/@std/io/0.225.2/_constants.d.ts +3 -0
- package/script/deps/jsr.io/@std/io/0.225.2/_constants.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/_constants.js +7 -0
- package/script/deps/jsr.io/@std/io/0.225.2/buffer.d.ts +321 -0
- package/script/deps/jsr.io/@std/io/0.225.2/buffer.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/buffer.js +492 -0
- package/script/deps/jsr.io/@std/io/0.225.2/copy.d.ts +25 -0
- package/script/deps/jsr.io/@std/io/0.225.2/copy.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/copy.js +39 -0
- package/script/deps/jsr.io/@std/io/0.225.2/iterate_reader.d.ts +80 -0
- package/script/deps/jsr.io/@std/io/0.225.2/iterate_reader.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/iterate_reader.js +100 -0
- package/script/deps/jsr.io/@std/io/0.225.2/mod.d.ts +25 -0
- package/script/deps/jsr.io/@std/io/0.225.2/mod.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/mod.js +41 -0
- package/script/deps/jsr.io/@std/io/0.225.2/read_all.d.ts +42 -0
- package/script/deps/jsr.io/@std/io/0.225.2/read_all.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/read_all.js +76 -0
- package/script/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.d.ts +20 -0
- package/script/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.js +39 -0
- package/script/deps/jsr.io/@std/io/0.225.2/to_readable_stream.d.ts +40 -0
- package/script/deps/jsr.io/@std/io/0.225.2/to_readable_stream.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/to_readable_stream.js +57 -0
- package/script/deps/jsr.io/@std/io/0.225.2/to_writable_stream.d.ts +27 -0
- package/script/deps/jsr.io/@std/io/0.225.2/to_writable_stream.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/to_writable_stream.js +47 -0
- package/script/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts +21 -0
- package/script/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/log/0.224.14/console_handler.js +1 -1
- package/script/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.js +1 -1
- package/script/src/context/Context.d.ts +14 -4
- package/script/src/context/Context.d.ts.map +1 -1
- package/script/src/context/Context.js +16 -10
- package/script/src/context/ContextProvider.d.ts +3 -4
- package/script/src/context/ContextProvider.d.ts.map +1 -1
- package/script/src/context/ContextProvider.js +5 -5
- package/script/src/dsl/http/versori/platformapi.d.ts +2 -1
- package/script/src/dsl/http/versori/platformapi.d.ts.map +1 -1
- package/script/src/dsl/http/versori/platformapi.js +12 -1
- package/script/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/script/src/dsl/http/versori/roundtripper.js +32 -35
- package/script/src/dsl/triggers/WebhookTrigger.d.ts +45 -3
- package/script/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/script/src/dsl/triggers/WebhookTrigger.js +10 -6
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts +6 -1
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +67 -5
- package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/webhook.js +109 -32
- package/script/src/kv/nats/NatsKeyValueProvider.d.ts +2 -1
- package/script/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
- package/script/src/kv/nats/NatsKeyValueProvider.js +3 -3
- /package/esm/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.5}/colors.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.5}/colors.js +0 -0
- /package/esm/deps/jsr.io/@std/fs/{1.0.16 → 1.0.11}/exists.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/fs/{1.0.16 → 1.0.11}/exists.js +0 -0
- /package/script/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.5}/colors.d.ts +0 -0
- /package/script/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.5}/colors.js +0 -0
- /package/script/deps/jsr.io/@std/fs/{1.0.16 → 1.0.11}/exists.d.ts +0 -0
- /package/script/deps/jsr.io/@std/fs/{1.0.16 → 1.0.11}/exists.js +0 -0
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import type { Reader, ReaderSync, Writer, WriterSync } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* A variable-sized buffer of bytes with `read()` and `write()` methods.
|
|
4
|
+
*
|
|
5
|
+
* Buffer is almost always used with some I/O like files and sockets. It allows
|
|
6
|
+
* one to buffer up a download from a socket. Buffer grows and shrinks as
|
|
7
|
+
* necessary.
|
|
8
|
+
*
|
|
9
|
+
* Buffer is NOT the same thing as Node's Buffer. Node's Buffer was created in
|
|
10
|
+
* 2009 before JavaScript had the concept of ArrayBuffers. It's simply a
|
|
11
|
+
* non-standard ArrayBuffer.
|
|
12
|
+
*
|
|
13
|
+
* ArrayBuffer is a fixed memory allocation. Buffer is implemented on top of
|
|
14
|
+
* ArrayBuffer.
|
|
15
|
+
*
|
|
16
|
+
* Based on {@link https://golang.org/pkg/bytes/#Buffer | Go Buffer}.
|
|
17
|
+
*
|
|
18
|
+
* @example Usage
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { Buffer } from "@std/io/buffer";
|
|
21
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
22
|
+
*
|
|
23
|
+
* const buf = new Buffer();
|
|
24
|
+
* await buf.write(new TextEncoder().encode("Hello, "));
|
|
25
|
+
* await buf.write(new TextEncoder().encode("world!"));
|
|
26
|
+
*
|
|
27
|
+
* const data = new Uint8Array(13);
|
|
28
|
+
* await buf.read(data);
|
|
29
|
+
*
|
|
30
|
+
* assertEquals(new TextDecoder().decode(data), "Hello, world!");
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare class Buffer implements Writer, WriterSync, Reader, ReaderSync {
|
|
34
|
+
#private;
|
|
35
|
+
/**
|
|
36
|
+
* Constructs a new instance with the specified {@linkcode ArrayBuffer} as its
|
|
37
|
+
* initial contents.
|
|
38
|
+
*
|
|
39
|
+
* @param ab The ArrayBuffer to use as the initial contents of the buffer.
|
|
40
|
+
*/
|
|
41
|
+
constructor(ab?: ArrayBufferLike | ArrayLike<number>);
|
|
42
|
+
/**
|
|
43
|
+
* Returns a slice holding the unread portion of the buffer.
|
|
44
|
+
*
|
|
45
|
+
* The slice is valid for use only until the next buffer modification (that
|
|
46
|
+
* is, only until the next call to a method like `read()`, `write()`,
|
|
47
|
+
* `reset()`, or `truncate()`). If `options.copy` is false the slice aliases the buffer content at
|
|
48
|
+
* least until the next buffer modification, so immediate changes to the
|
|
49
|
+
* slice will affect the result of future reads.
|
|
50
|
+
*
|
|
51
|
+
* @example Usage
|
|
52
|
+
* ```ts
|
|
53
|
+
* import { Buffer } from "@std/io/buffer";
|
|
54
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
55
|
+
*
|
|
56
|
+
* const buf = new Buffer();
|
|
57
|
+
* await buf.write(new TextEncoder().encode("Hello, world!"));
|
|
58
|
+
*
|
|
59
|
+
* const slice = buf.bytes();
|
|
60
|
+
* assertEquals(new TextDecoder().decode(slice), "Hello, world!");
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @param options The options for the slice.
|
|
64
|
+
* @returns A slice holding the unread portion of the buffer.
|
|
65
|
+
*/
|
|
66
|
+
bytes(options?: {
|
|
67
|
+
copy: boolean;
|
|
68
|
+
}): Uint8Array;
|
|
69
|
+
/**
|
|
70
|
+
* Returns whether the unread portion of the buffer is empty.
|
|
71
|
+
*
|
|
72
|
+
* @example Usage
|
|
73
|
+
* ```ts
|
|
74
|
+
* import { Buffer } from "@std/io/buffer";
|
|
75
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
76
|
+
*
|
|
77
|
+
* const buf = new Buffer();
|
|
78
|
+
* assertEquals(buf.empty(), true);
|
|
79
|
+
* await buf.write(new TextEncoder().encode("Hello, world!"));
|
|
80
|
+
* assertEquals(buf.empty(), false);
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @returns `true` if the unread portion of the buffer is empty, `false`
|
|
84
|
+
* otherwise.
|
|
85
|
+
*/
|
|
86
|
+
empty(): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* A read only number of bytes of the unread portion of the buffer.
|
|
89
|
+
*
|
|
90
|
+
* @example Usage
|
|
91
|
+
* ```ts
|
|
92
|
+
* import { Buffer } from "@std/io/buffer";
|
|
93
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
94
|
+
*
|
|
95
|
+
* const buf = new Buffer();
|
|
96
|
+
* await buf.write(new TextEncoder().encode("Hello, world!"));
|
|
97
|
+
*
|
|
98
|
+
* assertEquals(buf.length, 13);
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* @returns The number of bytes of the unread portion of the buffer.
|
|
102
|
+
*/
|
|
103
|
+
get length(): number;
|
|
104
|
+
/**
|
|
105
|
+
* The read only capacity of the buffer's underlying byte slice, that is,
|
|
106
|
+
* the total space allocated for the buffer's data.
|
|
107
|
+
*
|
|
108
|
+
* @example Usage
|
|
109
|
+
* ```ts
|
|
110
|
+
* import { Buffer } from "@std/io/buffer";
|
|
111
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
112
|
+
*
|
|
113
|
+
* const buf = new Buffer();
|
|
114
|
+
* assertEquals(buf.capacity, 0);
|
|
115
|
+
* await buf.write(new TextEncoder().encode("Hello, world!"));
|
|
116
|
+
* assertEquals(buf.capacity, 13);
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* @returns The capacity of the buffer.
|
|
120
|
+
*/
|
|
121
|
+
get capacity(): number;
|
|
122
|
+
/**
|
|
123
|
+
* Discards all but the first `n` unread bytes from the buffer but
|
|
124
|
+
* continues to use the same allocated storage. It throws if `n` is
|
|
125
|
+
* negative or greater than the length 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
|
+
* buf.truncate(6);
|
|
135
|
+
* assertEquals(buf.length, 6);
|
|
136
|
+
* ```
|
|
137
|
+
*
|
|
138
|
+
* @param n The number of bytes to keep.
|
|
139
|
+
*/
|
|
140
|
+
truncate(n: number): void;
|
|
141
|
+
/**
|
|
142
|
+
* Resets the contents
|
|
143
|
+
*
|
|
144
|
+
* @example Usage
|
|
145
|
+
* ```ts
|
|
146
|
+
* import { Buffer } from "@std/io/buffer";
|
|
147
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
148
|
+
*
|
|
149
|
+
* const buf = new Buffer();
|
|
150
|
+
* await buf.write(new TextEncoder().encode("Hello, world!"));
|
|
151
|
+
* buf.reset();
|
|
152
|
+
* assertEquals(buf.length, 0);
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
reset(): void;
|
|
156
|
+
/**
|
|
157
|
+
* Reads the next `p.length` bytes from the buffer or until the buffer is
|
|
158
|
+
* drained. Returns the number of bytes read. If the buffer has no data to
|
|
159
|
+
* return, the return is EOF (`null`).
|
|
160
|
+
*
|
|
161
|
+
* @example Usage
|
|
162
|
+
* ```ts
|
|
163
|
+
* import { Buffer } from "@std/io/buffer";
|
|
164
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
165
|
+
*
|
|
166
|
+
* const buf = new Buffer();
|
|
167
|
+
* await buf.write(new TextEncoder().encode("Hello, world!"));
|
|
168
|
+
*
|
|
169
|
+
* const data = new Uint8Array(5);
|
|
170
|
+
* const res = await buf.read(data);
|
|
171
|
+
*
|
|
172
|
+
* assertEquals(res, 5);
|
|
173
|
+
* assertEquals(new TextDecoder().decode(data), "Hello");
|
|
174
|
+
* ```
|
|
175
|
+
*
|
|
176
|
+
* @param p The buffer to read data into.
|
|
177
|
+
* @returns The number of bytes read.
|
|
178
|
+
*/
|
|
179
|
+
readSync(p: Uint8Array): number | null;
|
|
180
|
+
/**
|
|
181
|
+
* Reads the next `p.length` bytes from the buffer or until the buffer is
|
|
182
|
+
* drained. Resolves to the number of bytes read. If the buffer has no
|
|
183
|
+
* data to return, resolves to EOF (`null`).
|
|
184
|
+
*
|
|
185
|
+
* NOTE: This methods reads bytes synchronously; it's provided for
|
|
186
|
+
* compatibility with `Reader` interfaces.
|
|
187
|
+
*
|
|
188
|
+
* @example Usage
|
|
189
|
+
* ```ts
|
|
190
|
+
* import { Buffer } from "@std/io/buffer";
|
|
191
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
192
|
+
*
|
|
193
|
+
* const buf = new Buffer();
|
|
194
|
+
* await buf.write(new TextEncoder().encode("Hello, world!"));
|
|
195
|
+
*
|
|
196
|
+
* const data = new Uint8Array(5);
|
|
197
|
+
* const res = await buf.read(data);
|
|
198
|
+
*
|
|
199
|
+
* assertEquals(res, 5);
|
|
200
|
+
* assertEquals(new TextDecoder().decode(data), "Hello");
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* @param p The buffer to read data into.
|
|
204
|
+
* @returns The number of bytes read.
|
|
205
|
+
*/
|
|
206
|
+
read(p: Uint8Array): Promise<number | null>;
|
|
207
|
+
/**
|
|
208
|
+
* Writes the given data to the buffer.
|
|
209
|
+
*
|
|
210
|
+
* @example Usage
|
|
211
|
+
* ```ts
|
|
212
|
+
* import { Buffer } from "@std/io/buffer";
|
|
213
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
214
|
+
*
|
|
215
|
+
* const buf = new Buffer();
|
|
216
|
+
* const data = new TextEncoder().encode("Hello, world!");
|
|
217
|
+
* buf.writeSync(data);
|
|
218
|
+
*
|
|
219
|
+
* const slice = buf.bytes();
|
|
220
|
+
* assertEquals(new TextDecoder().decode(slice), "Hello, world!");
|
|
221
|
+
* ```
|
|
222
|
+
*
|
|
223
|
+
* @param p The data to write to the buffer.
|
|
224
|
+
* @returns The number of bytes written.
|
|
225
|
+
*/
|
|
226
|
+
writeSync(p: Uint8Array): number;
|
|
227
|
+
/**
|
|
228
|
+
* Writes the given data to the buffer. Resolves to the number of bytes
|
|
229
|
+
* written.
|
|
230
|
+
*
|
|
231
|
+
* > [!NOTE]
|
|
232
|
+
* > This methods writes bytes synchronously; it's provided for compatibility
|
|
233
|
+
* > with the {@linkcode Writer} interface.
|
|
234
|
+
*
|
|
235
|
+
* @example Usage
|
|
236
|
+
* ```ts
|
|
237
|
+
* import { Buffer } from "@std/io/buffer";
|
|
238
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
239
|
+
*
|
|
240
|
+
* const buf = new Buffer();
|
|
241
|
+
* const data = new TextEncoder().encode("Hello, world!");
|
|
242
|
+
* await buf.write(data);
|
|
243
|
+
*
|
|
244
|
+
* const slice = buf.bytes();
|
|
245
|
+
* assertEquals(new TextDecoder().decode(slice), "Hello, world!");
|
|
246
|
+
* ```
|
|
247
|
+
*
|
|
248
|
+
* @param p The data to write to the buffer.
|
|
249
|
+
* @returns The number of bytes written.
|
|
250
|
+
*/
|
|
251
|
+
write(p: Uint8Array): Promise<number>;
|
|
252
|
+
/** Grows the buffer's capacity, if necessary, to guarantee space for
|
|
253
|
+
* another `n` bytes. After `.grow(n)`, at least `n` bytes can be written to
|
|
254
|
+
* the buffer without another allocation. If `n` is negative, `.grow()` will
|
|
255
|
+
* throw. If the buffer can't grow it will throw an error.
|
|
256
|
+
*
|
|
257
|
+
* Based on Go Lang's
|
|
258
|
+
* {@link https://golang.org/pkg/bytes/#Buffer.Grow | Buffer.Grow}.
|
|
259
|
+
*
|
|
260
|
+
* @example Usage
|
|
261
|
+
* ```ts
|
|
262
|
+
* import { Buffer } from "@std/io/buffer";
|
|
263
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
264
|
+
*
|
|
265
|
+
* const buf = new Buffer();
|
|
266
|
+
* buf.grow(10);
|
|
267
|
+
* assertEquals(buf.capacity, 10);
|
|
268
|
+
* ```
|
|
269
|
+
*
|
|
270
|
+
* @param n The number of bytes to grow the buffer by.
|
|
271
|
+
*/
|
|
272
|
+
grow(n: number): void;
|
|
273
|
+
/**
|
|
274
|
+
* Reads data from `r` until EOF (`null`) and appends it to the buffer,
|
|
275
|
+
* growing the buffer as needed. It resolves to the number of bytes read.
|
|
276
|
+
* If the buffer becomes too large, `.readFrom()` will reject with an error.
|
|
277
|
+
*
|
|
278
|
+
* Based on Go Lang's
|
|
279
|
+
* {@link https://golang.org/pkg/bytes/#Buffer.ReadFrom | Buffer.ReadFrom}.
|
|
280
|
+
*
|
|
281
|
+
* @example Usage
|
|
282
|
+
* ```ts
|
|
283
|
+
* import { Buffer } from "@std/io/buffer";
|
|
284
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
285
|
+
*
|
|
286
|
+
* const buf = new Buffer();
|
|
287
|
+
* const r = new Buffer(new TextEncoder().encode("Hello, world!"));
|
|
288
|
+
* const n = await buf.readFrom(r);
|
|
289
|
+
*
|
|
290
|
+
* assertEquals(n, 13);
|
|
291
|
+
* ```
|
|
292
|
+
*
|
|
293
|
+
* @param r The reader to read from.
|
|
294
|
+
* @returns The number of bytes read.
|
|
295
|
+
*/
|
|
296
|
+
readFrom(r: Reader): Promise<number>;
|
|
297
|
+
/** Reads data from `r` until EOF (`null`) and appends it to the buffer,
|
|
298
|
+
* growing the buffer as needed. It returns the number of bytes read. If the
|
|
299
|
+
* buffer becomes too large, `.readFromSync()` will throw an error.
|
|
300
|
+
*
|
|
301
|
+
* Based on Go Lang's
|
|
302
|
+
* {@link https://golang.org/pkg/bytes/#Buffer.ReadFrom | Buffer.ReadFrom}.
|
|
303
|
+
*
|
|
304
|
+
* @example Usage
|
|
305
|
+
* ```ts
|
|
306
|
+
* import { Buffer } from "@std/io/buffer";
|
|
307
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
308
|
+
*
|
|
309
|
+
* const buf = new Buffer();
|
|
310
|
+
* const r = new Buffer(new TextEncoder().encode("Hello, world!"));
|
|
311
|
+
* const n = buf.readFromSync(r);
|
|
312
|
+
*
|
|
313
|
+
* assertEquals(n, 13);
|
|
314
|
+
* ```
|
|
315
|
+
*
|
|
316
|
+
* @param r The reader to read from.
|
|
317
|
+
* @returns The number of bytes read.
|
|
318
|
+
*/
|
|
319
|
+
readFromSync(r: ReaderSync): number;
|
|
320
|
+
}
|
|
321
|
+
//# sourceMappingURL=buffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/io/0.225.2/buffer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AASzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,MAAO,YAAW,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU;;IAInE;;;;;OAKG;gBACS,EAAE,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC,MAAM,CAAC;IAWpD;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,KAAK,CAAC,OAAO;;KAAiB,GAAG,UAAU;IAK3C;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,IAAI,OAAO;IAIhB;;;;;;;;;;;;;;;OAeG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,QAAQ,CAAC,CAAC,EAAE,MAAM;IAWlB;;;;;;;;;;;;;OAaG;IACH,KAAK;IAqBL;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,QAAQ,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI;IAetC;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,IAAI,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAK3C;;;;;;;;;;;;;;;;;;OAkBG;IACH,SAAS,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM;IAKhC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,KAAK,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAuCrC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,IAAI,CAAC,CAAC,EAAE,MAAM;IAQd;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAwB1C;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,YAAY,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM;CAuBpC"}
|