anonyma 1.0.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.
@@ -0,0 +1,76 @@
1
+ import { A as AnonymizeOptions, a as AnonymizeResult, T as TokenizeOptions, b as TokenizeResult } from './types-D-9HzVuy.cjs';
2
+
3
+ /**
4
+ * @module stream
5
+ * @description Streaming support for anonyma via the WHATWG Streams API.
6
+ *
7
+ * Provides `TransformStream`-based wrappers so anonyma can be used in
8
+ * Node.js stream pipelines and browser fetch-response chains.
9
+ *
10
+ * Requires Node ≥ 18 (global `TransformStream`) or a browser with Streams API.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import { createAnonymizeStream } from "anonyma/stream";
15
+ * import { createReadStream, createWriteStream } from "node:fs";
16
+ *
17
+ * const readable = ReadableStream.from(lines);
18
+ * const anonymized = readable.pipeThrough(createAnonymizeStream());
19
+ * for await (const chunk of anonymized) {
20
+ * process.stdout.write(chunk);
21
+ * }
22
+ * ```
23
+ */
24
+
25
+ /**
26
+ * Create a `TransformStream` that anonymizes each string chunk it receives.
27
+ *
28
+ * Input chunks are expected to be complete text strings (e.g. lines or
29
+ * paragraphs). For true streaming over arbitrary byte chunks, split on
30
+ * line boundaries before piping.
31
+ *
32
+ * @param options - Anonymization options forwarded to {@link anonymize}.
33
+ * @returns A `TransformStream<string, AnonymizeResult>`.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * const stream = createAnonymizeStream({ defaultStrategy: { strategy: "mask" } });
38
+ * const reader = readable.pipeThrough(stream).getReader();
39
+ * const { value } = await reader.read();
40
+ * // value: { text: "****", matches: [] }
41
+ * ```
42
+ */
43
+ declare function createAnonymizeStream(options?: AnonymizeOptions): TransformStream<string, AnonymizeResult>;
44
+ /**
45
+ * Create an async-capable `TransformStream` that anonymizes each string chunk.
46
+ * Supports `hash`, `encrypt`, and other async strategies.
47
+ *
48
+ * @param options - Anonymization options forwarded to {@link anonymizeAsync}.
49
+ * @returns A `TransformStream<string, AnonymizeResult>`.
50
+ */
51
+ declare function createAnonymizeStreamAsync(options?: AnonymizeOptions): TransformStream<string, AnonymizeResult>;
52
+ /**
53
+ * Create a `TransformStream` that tokenizes each string chunk it receives.
54
+ *
55
+ * Note: each chunk gets its **own** token map. If you need a shared map across
56
+ * all chunks, manage the tokenization externally and feed results manually.
57
+ *
58
+ * @param options - Tokenization options forwarded to {@link tokenize}.
59
+ * @returns A `TransformStream<string, TokenizeResult>`.
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * const stream = createTokenizeStream({ categories: ["email"] });
64
+ * const writer = stream.writable.getWriter();
65
+ * const reader = stream.readable.getReader();
66
+ *
67
+ * writer.write("Contact alice@example.com");
68
+ * writer.close();
69
+ *
70
+ * const { value } = await reader.read();
71
+ * // value: { text: "Contact [EMAIL_0001]", mapping: Map { ... } }
72
+ * ```
73
+ */
74
+ declare function createTokenizeStream(options?: TokenizeOptions): TransformStream<string, TokenizeResult>;
75
+
76
+ export { createAnonymizeStream, createAnonymizeStreamAsync, createTokenizeStream };
@@ -0,0 +1,76 @@
1
+ import { A as AnonymizeOptions, a as AnonymizeResult, T as TokenizeOptions, b as TokenizeResult } from './types-D-9HzVuy.js';
2
+
3
+ /**
4
+ * @module stream
5
+ * @description Streaming support for anonyma via the WHATWG Streams API.
6
+ *
7
+ * Provides `TransformStream`-based wrappers so anonyma can be used in
8
+ * Node.js stream pipelines and browser fetch-response chains.
9
+ *
10
+ * Requires Node ≥ 18 (global `TransformStream`) or a browser with Streams API.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import { createAnonymizeStream } from "anonyma/stream";
15
+ * import { createReadStream, createWriteStream } from "node:fs";
16
+ *
17
+ * const readable = ReadableStream.from(lines);
18
+ * const anonymized = readable.pipeThrough(createAnonymizeStream());
19
+ * for await (const chunk of anonymized) {
20
+ * process.stdout.write(chunk);
21
+ * }
22
+ * ```
23
+ */
24
+
25
+ /**
26
+ * Create a `TransformStream` that anonymizes each string chunk it receives.
27
+ *
28
+ * Input chunks are expected to be complete text strings (e.g. lines or
29
+ * paragraphs). For true streaming over arbitrary byte chunks, split on
30
+ * line boundaries before piping.
31
+ *
32
+ * @param options - Anonymization options forwarded to {@link anonymize}.
33
+ * @returns A `TransformStream<string, AnonymizeResult>`.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * const stream = createAnonymizeStream({ defaultStrategy: { strategy: "mask" } });
38
+ * const reader = readable.pipeThrough(stream).getReader();
39
+ * const { value } = await reader.read();
40
+ * // value: { text: "****", matches: [] }
41
+ * ```
42
+ */
43
+ declare function createAnonymizeStream(options?: AnonymizeOptions): TransformStream<string, AnonymizeResult>;
44
+ /**
45
+ * Create an async-capable `TransformStream` that anonymizes each string chunk.
46
+ * Supports `hash`, `encrypt`, and other async strategies.
47
+ *
48
+ * @param options - Anonymization options forwarded to {@link anonymizeAsync}.
49
+ * @returns A `TransformStream<string, AnonymizeResult>`.
50
+ */
51
+ declare function createAnonymizeStreamAsync(options?: AnonymizeOptions): TransformStream<string, AnonymizeResult>;
52
+ /**
53
+ * Create a `TransformStream` that tokenizes each string chunk it receives.
54
+ *
55
+ * Note: each chunk gets its **own** token map. If you need a shared map across
56
+ * all chunks, manage the tokenization externally and feed results manually.
57
+ *
58
+ * @param options - Tokenization options forwarded to {@link tokenize}.
59
+ * @returns A `TransformStream<string, TokenizeResult>`.
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * const stream = createTokenizeStream({ categories: ["email"] });
64
+ * const writer = stream.writable.getWriter();
65
+ * const reader = stream.readable.getReader();
66
+ *
67
+ * writer.write("Contact alice@example.com");
68
+ * writer.close();
69
+ *
70
+ * const { value } = await reader.read();
71
+ * // value: { text: "Contact [EMAIL_0001]", mapping: Map { ... } }
72
+ * ```
73
+ */
74
+ declare function createTokenizeStream(options?: TokenizeOptions): TransformStream<string, TokenizeResult>;
75
+
76
+ export { createAnonymizeStream, createAnonymizeStreamAsync, createTokenizeStream };