@noldova/context.text 0.0.0-stage → 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Noldova
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,51 @@
1
+ THIRD-PARTY NOTICES
2
+
3
+ This package includes tables generated from the Unicode Character Database,
4
+ in services/unicode-code-point.service.js:
5
+
6
+ - Unicode 15.1 ID_Start and ID_Continue properties, from
7
+ https://www.unicode.org/Public/15.1.0/ucd/DerivedCoreProperties.txt
8
+
9
+ They are used under the Unicode License v3, whose text follows.
10
+
11
+ --------------------------------------------------------------------------------
12
+
13
+ UNICODE LICENSE V3
14
+
15
+ COPYRIGHT AND PERMISSION NOTICE
16
+
17
+ Copyright © 1991-2026 Unicode, Inc.
18
+
19
+ NOTICE TO USER: Carefully read the following legal agreement. BY
20
+ DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR
21
+ SOFTWARE, YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
22
+ TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT
23
+ DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.
24
+
25
+ Permission is hereby granted, free of charge, to any person obtaining a
26
+ copy of data files and any associated documentation (the "Data Files") or
27
+ software and any associated documentation (the "Software") to deal in the
28
+ Data Files or Software without restriction, including without limitation
29
+ the rights to use, copy, modify, merge, publish, distribute, and/or sell
30
+ copies of the Data Files or Software, and to permit persons to whom the
31
+ Data Files or Software are furnished to do so, provided that either (a)
32
+ this copyright and permission notice appear with all copies of the Data
33
+ Files or Software, or (b) this copyright and permission notice appear in
34
+ associated Documentation.
35
+
36
+ THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
37
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
38
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
39
+ THIRD PARTY RIGHTS.
40
+
41
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE
42
+ BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,
43
+ OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44
+ WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45
+ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA
46
+ FILES OR SOFTWARE.
47
+
48
+ Except as contained in this notice, the name of a copyright holder shall
49
+ not be used in advertising or otherwise to promote the sale, use or other
50
+ dealings in these Data Files or Software without prior written
51
+ authorization of the copyright holder.
package/api/index.d.ts ADDED
@@ -0,0 +1,460 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+
9
+ import "@noldova/context.core";
10
+
11
+ declare global {
12
+ /**
13
+ * Text operations added to the global `String` constructor.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import "@noldova/context.text";
18
+ *
19
+ * String.isAsciiBinaryDigit("1"); // true
20
+ * String.isAsciiBinaryDigit("2"); // false
21
+ * String.isAsciiOctalDigit("7"); // true
22
+ * String.isAsciiOctalDigit("8"); // false
23
+ * String.isAsciiOctalDigit("07"); // false: not one character.
24
+ * ```
25
+ */
26
+ interface StringConstructor {
27
+ /**
28
+ * Identifies a single ASCII binary digit.
29
+ *
30
+ * @param character The complete string to classify; no trimming or numeric
31
+ * conversion is performed.
32
+ * @returns True only for `"0"` or `"1"`. Empty strings, longer strings,
33
+ * and non-ASCII digits return false.
34
+ * @example
35
+ * ```ts
36
+ * import "@noldova/context.text";
37
+ *
38
+ * String.isAsciiBinaryDigit("1"); // true
39
+ * String.isAsciiBinaryDigit("10"); // false: not one character.
40
+ * ```
41
+ */
42
+ isAsciiBinaryDigit(character: string): boolean;
43
+
44
+ /**
45
+ * Identifies a single ASCII octal digit.
46
+ *
47
+ * @param character The complete string to classify; no trimming or numeric
48
+ * conversion is performed.
49
+ * @returns True only for one character from `"0"` through `"7"`. Empty
50
+ * strings, longer strings, and non-ASCII digits return false.
51
+ * @example
52
+ * ```ts
53
+ * import "@noldova/context.text";
54
+ *
55
+ * String.isAsciiOctalDigit("7"); // true
56
+ * String.isAsciiOctalDigit("8"); // false
57
+ * ```
58
+ */
59
+ isAsciiOctalDigit(character: string): boolean;
60
+ }
61
+ }
62
+
63
+ /**
64
+ * Defines a language's line-terminator policy for UTF-16 text.
65
+ * Sequence recognition and single-code-unit classification are distinct operations.
66
+ * This contract does not select the host operating system's newline convention.
67
+ *
68
+ * @see {@link EcmaScriptLineTerminator} for a concrete policy and examples.
69
+ */
70
+ export declare abstract class LineTerminator {
71
+ /**
72
+ * Examines the sequence beginning at one UTF-16 position.
73
+ *
74
+ * @param value The complete text to inspect, without changing or normalizing it.
75
+ * @param index The zero-based UTF-16 offset to inspect. Must be an integer
76
+ * between zero and `value.length`, inclusive.
77
+ * @returns The recognized sequence's length in code units, or zero for an
78
+ * ordinary position or the end of the string.
79
+ * @example
80
+ * ```ts
81
+ * import { EcmaScriptLineTerminator, LineTerminator } from "@noldova/context.text";
82
+ *
83
+ * const terminator: LineTerminator = new EcmaScriptLineTerminator();
84
+ * terminator.getLength("a\r\nb", 1); // 2: CRLF.
85
+ * terminator.getLength("ab", 1); // 0: an ordinary position.
86
+ * ```
87
+ */
88
+ public abstract getLength(value: string, index: number): 0 | 1 | 2;
89
+
90
+ /**
91
+ * Classifies one complete code unit as a line terminator.
92
+ *
93
+ * @param character The whole string to classify, not a position within a
94
+ * larger string. Only a one-code-unit string can qualify.
95
+ * @returns True when that code unit is a line terminator under this policy.
96
+ * Empty strings and multi-code-unit strings return false.
97
+ * @example
98
+ * ```ts
99
+ * import { EcmaScriptLineTerminator, LineTerminator } from "@noldova/context.text";
100
+ *
101
+ * const terminator: LineTerminator = new EcmaScriptLineTerminator();
102
+ * terminator.isLineTerminator("\n"); // true
103
+ * terminator.isLineTerminator(""); // false
104
+ * ```
105
+ */
106
+ public abstract isLineTerminator(character: string): boolean;
107
+ }
108
+
109
+ /**
110
+ * Recognizes the ECMAScript sequences CRLF, CR, LF, U+2028, and U+2029.
111
+ * It does not treat U+0085 as a line terminator.
112
+ *
113
+ * @example
114
+ * ```ts
115
+ * import { EcmaScriptLineTerminator } from "@noldova/context.text";
116
+ *
117
+ * const terminator = new EcmaScriptLineTerminator();
118
+ * terminator.getLength("a\r\nb", 1); // 2: CRLF.
119
+ * terminator.getLength("a\r\nb", 2); // 1: LF at the requested position.
120
+ * terminator.getLength("", 0); // 0: end of text.
121
+ * terminator.isLineTerminator("\u2028"); // true
122
+ * terminator.isLineTerminator("\r\n"); // false: two code units.
123
+ * ```
124
+ */
125
+ export declare class EcmaScriptLineTerminator extends LineTerminator {
126
+ /**
127
+ * Recognizes a line-terminator sequence at the requested position.
128
+ *
129
+ * @param value The complete text to inspect without modifying it.
130
+ * @param index The zero-based UTF-16 offset. An offset equal to the string's
131
+ * length is valid and represents the end of text.
132
+ * @returns Two for CRLF; one for CR, LF, U+2028, or U+2029; otherwise zero.
133
+ * Recognition starts exactly at `index` and does not look behind it.
134
+ * @throws {ArgumentOutOfRangeException} Synchronously, when the index is
135
+ * non-integer, negative, or greater than the string's length.
136
+ * @example
137
+ * ```ts
138
+ * import { EcmaScriptLineTerminator } from "@noldova/context.text";
139
+ *
140
+ * const terminator = new EcmaScriptLineTerminator();
141
+ * terminator.getLength("a\rb", 1); // 1: CR alone.
142
+ * terminator.getLength("a", 1); // 0: the end of text.
143
+ * terminator.getLength("a", 2); // Throws ArgumentOutOfRangeException.
144
+ * ```
145
+ */
146
+ public override getLength(value: string, index: number): 0 | 1 | 2;
147
+
148
+ /**
149
+ * Classifies a single ECMAScript line-terminator code unit.
150
+ *
151
+ * @param character The whole string to classify. It is not trimmed,
152
+ * split, or normalized.
153
+ * @returns True only for CR, LF, U+2028, or U+2029. In particular, CRLF
154
+ * returns false here; use {@link EcmaScriptLineTerminator.getLength} for sequences.
155
+ * @example
156
+ * ```ts
157
+ * import { EcmaScriptLineTerminator } from "@noldova/context.text";
158
+ *
159
+ * const terminator = new EcmaScriptLineTerminator();
160
+ * terminator.isLineTerminator(""); // true
161
+ * terminator.isLineTerminator("\u0085"); // false: NEL is not an ECMAScript line terminator.
162
+ * ```
163
+ */
164
+ public override isLineTerminator(character: string): boolean;
165
+ }
166
+
167
+ /**
168
+ * An immutable UTF-16 view backed by an existing string.
169
+ *
170
+ * Creating or slicing a span creates a view object without copying its
171
+ * represented characters. The view retains its backing source string, even
172
+ * when it represents only a small or empty range of a large source.
173
+ * Indexes and lengths count code units, not Unicode code points or displayed
174
+ * characters; a view may include only one half of a surrogate pair.
175
+ *
176
+ * @example
177
+ * ```ts
178
+ * import { ReadOnlyStringSpan } from "@noldova/context.text";
179
+ *
180
+ * const span = new ReadOnlyStringSpan("hello world", 6, 5);
181
+ * span.toString(); // "world"
182
+ * span.get(0); // "w": indexes are relative to the span.
183
+ * span.slice(1, 3).toString(); // "orl"
184
+ * span.slice(span.length).isEmpty; // true
185
+ * new ReadOnlyStringSpan("😀").length; // 2 UTF-16 code units.
186
+ * ```
187
+ */
188
+ export declare class ReadOnlyStringSpan {
189
+ /**
190
+ * A reusable zero-length span backed by an empty string.
191
+ */
192
+ public static readonly empty: ReadOnlyStringSpan;
193
+
194
+ /**
195
+ * The number of UTF-16 code units visible through this span.
196
+ */
197
+ public readonly length: number;
198
+
199
+ /**
200
+ * Whether this span has zero visible code units.
201
+ */
202
+ public readonly isEmpty: boolean;
203
+
204
+ /**
205
+ * Creates a view of the complete source or one contained range.
206
+ *
207
+ * @param source The backing string retained by this span. Empty strings
208
+ * and unpaired UTF-16 surrogate code units are allowed.
209
+ * @param start The zero-based source offset in code units; defaults to zero.
210
+ * An offset equal to `source.length` is valid for an empty view.
211
+ * @param length The number of code units in the view; defaults to all
212
+ * remaining source units from `start`. Zero is allowed.
213
+ * @throws {ArgumentOutOfRangeException} Synchronously, when start or length
214
+ * is non-integer or negative, start exceeds the source length, or the range
215
+ * extends past its end.
216
+ * @example
217
+ * ```ts
218
+ * import { ReadOnlyStringSpan } from "@noldova/context.text";
219
+ *
220
+ * new ReadOnlyStringSpan("hello").toString(); // "hello"
221
+ * new ReadOnlyStringSpan("hello", 1, 3).toString(); // "ell"
222
+ * new ReadOnlyStringSpan("hello", 5).isEmpty; // true
223
+ * new ReadOnlyStringSpan("hello", 2, 4); // Throws ArgumentOutOfRangeException.
224
+ * ```
225
+ */
226
+ public constructor(source: string, start?: number, length?: number);
227
+
228
+ /**
229
+ * Reads one code unit relative to this span.
230
+ *
231
+ * @param index The zero-based span offset, from zero through
232
+ * `length - 1`. No index is valid for an empty span.
233
+ * @returns A string containing exactly one UTF-16 code unit. A surrogate
234
+ * is returned as that code unit, without combining it with its neighbor.
235
+ * @throws {IndexOutOfRangeException} Synchronously, when the index is
236
+ * non-integer, negative, or greater than or equal to the span's length.
237
+ * @example
238
+ * ```ts
239
+ * import { ReadOnlyStringSpan } from "@noldova/context.text";
240
+ *
241
+ * const span = new ReadOnlyStringSpan("hello", 1, 3);
242
+ * span.get(0); // "e": indexes are relative to the span.
243
+ * span.get(3); // Throws IndexOutOfRangeException.
244
+ * ```
245
+ */
246
+ public get(index: number): string;
247
+
248
+ /**
249
+ * Creates a new view contained within this span.
250
+ *
251
+ * @param start The zero-based offset relative to this span, not its backing
252
+ * source. An offset equal to `length` is valid for an empty slice.
253
+ * @param length The number of code units to expose; defaults to the remainder
254
+ * of this span. Zero is allowed.
255
+ * @returns A new span sharing the original backing string. The current span
256
+ * is unchanged, and the result cannot expose text outside its parent.
257
+ * @throws {ArgumentOutOfRangeException} Synchronously, when start or length
258
+ * is non-integer or negative, or the requested range is outside this span.
259
+ * @example
260
+ * ```ts
261
+ * import { ReadOnlyStringSpan } from "@noldova/context.text";
262
+ *
263
+ * const span = new ReadOnlyStringSpan("hello world", 6);
264
+ * span.slice(1, 3).toString(); // "orl"
265
+ * span.slice(span.length).isEmpty; // true
266
+ * span.slice(4, 2); // Throws ArgumentOutOfRangeException.
267
+ * ```
268
+ */
269
+ public slice(start: number, length?: number): ReadOnlyStringSpan;
270
+
271
+ /**
272
+ * Produces the text represented by the view.
273
+ *
274
+ * @returns The visible code units in order, or an empty string for an empty
275
+ * span. The operation does not consume or alter the span.
276
+ * @example
277
+ * ```ts
278
+ * import { ReadOnlyStringSpan } from "@noldova/context.text";
279
+ *
280
+ * new ReadOnlyStringSpan("hello world", 6, 5).toString(); // "world"
281
+ * ReadOnlyStringSpan.empty.toString(); // ""
282
+ * ```
283
+ */
284
+ public toString(): string;
285
+ }
286
+
287
+ /**
288
+ * Collects string fragments and materializes their combined UTF-16 text on demand.
289
+ * Fragments remain retained until {@link StringBuilder.clear} or the builder
290
+ * itself becomes unreachable. Materializing a string does not clear the builder.
291
+ *
292
+ * @example
293
+ * ```ts
294
+ * import { StringBuilder } from "@noldova/context.text";
295
+ *
296
+ * const builder = new StringBuilder();
297
+ * builder.append("hello").append(" ").append("world");
298
+ * builder.length; // 11
299
+ * const first = builder.toString(); // "hello world"
300
+ * builder.append("!");
301
+ * builder.toString(); // "hello world!"
302
+ * first; // Still "hello world".
303
+ * builder.clear();
304
+ * builder.length; // 0
305
+ * builder.toString(); // ""
306
+ * builder.append("again").toString(); // "again": the builder is reusable.
307
+ * ```
308
+ */
309
+ export declare class StringBuilder {
310
+ /**
311
+ * The total number of UTF-16 code units in the retained fragments.
312
+ */
313
+ public get length(): number;
314
+
315
+ /**
316
+ * Appends a string exactly as supplied.
317
+ *
318
+ * @param value The entire fragment to retain. Empty strings have no effect.
319
+ * Newlines and surrogate code units are neither inserted, replaced, nor normalized.
320
+ * @returns This same builder, allowing further appends to be chained.
321
+ *
322
+ * @example
323
+ * ```ts
324
+ * import { StringBuilder } from "@noldova/context.text";
325
+ *
326
+ * const builder = new StringBuilder();
327
+ * builder.append("a\r").append("\nb");
328
+ * builder.toString(); // "a\r\nb": preserves the exact supplied newline.
329
+ * ```
330
+ */
331
+ public append(value: string): this;
332
+
333
+ /**
334
+ * Releases this builder's references to its fragments and sets its length to zero.
335
+ * The builder can be reused, and strings previously returned by
336
+ * {@link StringBuilder.toString} remain unchanged.
337
+ *
338
+ * @example
339
+ * ```ts
340
+ * import { StringBuilder } from "@noldova/context.text";
341
+ *
342
+ * const builder = new StringBuilder().append("draft");
343
+ * builder.clear();
344
+ * builder.length; // 0
345
+ * builder.append("final").toString(); // "final"
346
+ * ```
347
+ */
348
+ public clear(): void;
349
+
350
+ /**
351
+ * Joins the retained fragments without consuming them.
352
+ *
353
+ * @returns The combined code units, or an empty string when no content has
354
+ * been appended. Subsequent changes to the builder do not change this string.
355
+ *
356
+ * @remarks
357
+ * Each call joins the current fragments again; the result is not cached.
358
+ * Materialize after accumulation rather than after every append.
359
+ * @example
360
+ * ```ts
361
+ * import { StringBuilder } from "@noldova/context.text";
362
+ *
363
+ * const builder = new StringBuilder();
364
+ * builder.toString(); // ""
365
+ * builder.append("a").append("b").toString(); // "ab"
366
+ * ```
367
+ */
368
+ public toString(): string;
369
+ }
370
+
371
+ /**
372
+ * Classifies numeric code points using the pinned Unicode 15.1 identifier data.
373
+ * This is Unicode classification, not a complete language-identifier policy:
374
+ * a language may add characters such as ECMAScript's dollar sign.
375
+ * The host's Unicode version does not select these results.
376
+ *
377
+ * @example
378
+ * ```ts
379
+ * import { UnicodeCodePointService } from "@noldova/context.text";
380
+ *
381
+ * UnicodeCodePointService.isIdentifierStart(0x41); // true: A.
382
+ * UnicodeCodePointService.isIdentifierStart(0x30); // false: 0.
383
+ * UnicodeCodePointService.isIdentifierContinue(0x30); // true: 0 can continue.
384
+ * UnicodeCodePointService.isIdentifierStart(0x24); // false: dollar sign.
385
+ * UnicodeCodePointService.isIdentifierStart(0x2EBF0); // true: Unicode 15.1 addition.
386
+ * UnicodeCodePointService.isIdentifierStart(0x10D50); // false: absent from this profile.
387
+ * UnicodeCodePointService.isIdentifierContinue(Number.NaN); // false
388
+ * ```
389
+ */
390
+ export declare class UnicodeCodePointService {
391
+ /**
392
+ * Tests the Unicode 15.1 `ID_Start` property, including its
393
+ * `Other_ID_Start` contributions.
394
+ *
395
+ * @param value The numeric code point to classify, not a string index.
396
+ * @returns True for a code point in the pinned start set. Non-integers,
397
+ * negative values, values above U+10FFFF, and all other code points return false.
398
+ * @example
399
+ * ```ts
400
+ * import { UnicodeCodePointService } from "@noldova/context.text";
401
+ *
402
+ * UnicodeCodePointService.isIdentifierStart(0x41); // true: A.
403
+ * UnicodeCodePointService.isIdentifierStart(0x30); // false: 0.
404
+ * UnicodeCodePointService.isIdentifierStart(0x110000); // false: past U+10FFFF.
405
+ * ```
406
+ */
407
+ public static isIdentifierStart(value: number): boolean;
408
+
409
+ /**
410
+ * Tests the Unicode 15.1 `ID_Continue` property.
411
+ *
412
+ * @param value The numeric code point to classify, not a string index.
413
+ * @returns True for a code point in the pinned continuation set. Non-integers,
414
+ * negative values, values above U+10FFFF, and all other code points return false.
415
+ * @example
416
+ * ```ts
417
+ * import { UnicodeCodePointService } from "@noldova/context.text";
418
+ *
419
+ * UnicodeCodePointService.isIdentifierContinue(0x30); // true: 0 can continue.
420
+ * UnicodeCodePointService.isIdentifierContinue(0x2D); // false: hyphen-minus.
421
+ * UnicodeCodePointService.isIdentifierContinue(1.5); // false: not an integer.
422
+ * ```
423
+ */
424
+ public static isIdentifierContinue(value: number): boolean;
425
+
426
+ /**
427
+ * Identifies a UTF-16 leading-surrogate code unit by its numeric value.
428
+ *
429
+ * @param value The integer code-unit value to classify.
430
+ * @returns True from U+D800 through U+DBFF, inclusive; false for every other
431
+ * value, including non-integers. Surrogates are not Unicode scalar values.
432
+ *
433
+ * @example
434
+ * ```ts
435
+ * import { UnicodeCodePointService } from "@noldova/context.text";
436
+ *
437
+ * UnicodeCodePointService.isLeadingSurrogate(0xD83D); // true
438
+ * UnicodeCodePointService.isTrailingSurrogate(0xDE00); // true
439
+ * UnicodeCodePointService.isLeadingSurrogate(0xDE00); // false
440
+ * UnicodeCodePointService.isTrailingSurrogate(0xE000); // false: past the range.
441
+ * ```
442
+ */
443
+ public static isLeadingSurrogate(value: number): boolean;
444
+
445
+ /**
446
+ * Identifies a UTF-16 trailing-surrogate code unit by its numeric value.
447
+ *
448
+ * @param value The integer code-unit value to classify.
449
+ * @returns True from U+DC00 through U+DFFF, inclusive; false for every other
450
+ * value, including non-integers. Surrogates are not Unicode scalar values.
451
+ * @example
452
+ * ```ts
453
+ * import { UnicodeCodePointService } from "@noldova/context.text";
454
+ *
455
+ * UnicodeCodePointService.isTrailingSurrogate(0xDE00); // true
456
+ * UnicodeCodePointService.isTrailingSurrogate(0xD83D); // false: a leading surrogate.
457
+ * ```
458
+ */
459
+ public static isTrailingSurrogate(value: number): boolean;
460
+ }
package/api/index.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import "../extensions/string.extensions.js";
9
+ export { ReadOnlyStringSpan } from "../models/read-only-string-span.js";
10
+ export { EcmaScriptLineTerminator } from "../services/line-terminators/ecma-script-line-terminator.js";
11
+ export { LineTerminator } from "../services/line-terminators/line-terminator.js";
12
+ export { StringBuilder } from "../services/string-builder.js";
13
+ export { UnicodeCodePointService } from "../services/unicode-code-point.service.js";
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/noldova.context.text/src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,oCAAoC,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,6DAA6D,CAAC;AACvG,OAAO,EAAE,cAAc,EAAE,MAAM,iDAAiD,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import { nameof } from "@noldova/context.core";
9
+ import { Resources } from "../resources.js";
10
+ function isAsciiBinaryDigit(character) {
11
+ return character === Resources.asciiDigitZero || character === Resources.asciiDigitOne;
12
+ }
13
+ function isAsciiOctalDigit(character) {
14
+ if (character.length !== 1)
15
+ return false;
16
+ return character >= Resources.asciiDigitZero && character <= Resources.asciiDigitSeven;
17
+ }
18
+ Object.defineProperty(String, nameof(t => t.isAsciiBinaryDigit), { value: isAsciiBinaryDigit, writable: false, enumerable: false, configurable: false });
19
+ Object.defineProperty(String, nameof(t => t.isAsciiOctalDigit), { value: isAsciiOctalDigit, writable: false, enumerable: false, configurable: false });
20
+ export {};
21
+ //# sourceMappingURL=string.extensions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.extensions.js","sourceRoot":"","sources":["../../../../src/noldova.context.text/src/extensions/string.extensions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAS5C,SAAS,kBAAkB,CAAC,SAAiB;IAC3C,OAAO,SAAS,KAAK,SAAS,CAAC,cAAc,IAAI,SAAS,KAAK,SAAS,CAAC,aAAa,CAAC;AACzF,CAAC;AAED,SAAS,iBAAiB,CAAC,SAAiB;IAC1C,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QACxB,OAAO,KAAK,CAAC;IAEf,OAAO,SAAS,IAAI,SAAS,CAAC,cAAc,IAAI,SAAS,IAAI,SAAS,CAAC,eAAe,CAAC;AACzF,CAAC;AAED,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,kBAAkB,CAAC,EAAE,EAAE,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;AAC5K,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,EAAE,EAAE,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;AAE1K,OAAO,EAAG,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import "@noldova/context.core";
9
+ import { ArgumentOutOfRangeException, IndexOutOfRangeException } from "@noldova/context.exceptions";
10
+ import { Resources } from "../resources.js";
11
+ export class ReadOnlyStringSpan {
12
+ static empty = new ReadOnlyStringSpan(String.empty);
13
+ source;
14
+ start;
15
+ length;
16
+ isEmpty;
17
+ constructor(source, start = 0, length) {
18
+ const spanLength = length ?? source.length - start;
19
+ ReadOnlyStringSpan.validateRange(start, spanLength, source.length);
20
+ this.source = source;
21
+ this.start = start;
22
+ this.length = spanLength;
23
+ this.isEmpty = this.length === 0;
24
+ }
25
+ get(index) {
26
+ if (!Number.isInteger(index) || index < 0 || index >= this.length)
27
+ throw new IndexOutOfRangeException(Resources.indexOutOfRange);
28
+ return this.source.charAt(this.start + index);
29
+ }
30
+ slice(start, length) {
31
+ const spanLength = length ?? this.length - start;
32
+ ReadOnlyStringSpan.validateRange(start, spanLength, this.length);
33
+ return new ReadOnlyStringSpan(this.source, this.start + start, spanLength);
34
+ }
35
+ toString() {
36
+ return this.source.slice(this.start, this.start + this.length);
37
+ }
38
+ static validateRange(start, length, sourceLength) {
39
+ if (!Number.isInteger(start) || start < 0 || start > sourceLength)
40
+ throw new ArgumentOutOfRangeException(Resources.startParameterName, start, Resources.startInvalid);
41
+ if (!Number.isInteger(length) || length < 0)
42
+ throw new ArgumentOutOfRangeException(Resources.lengthParameterName, length, Resources.lengthInvalid);
43
+ if (start + length > sourceLength)
44
+ throw new ArgumentOutOfRangeException(Resources.lengthParameterName, length, Resources.spanOutOfRange);
45
+ }
46
+ }
47
+ //# sourceMappingURL=read-only-string-span.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-only-string-span.js","sourceRoot":"","sources":["../../../../src/noldova.context.text/src/models/read-only-string-span.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,EAAE,2BAA2B,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAEpG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,OAAO,kBAAkB;IACtB,MAAM,CAAU,KAAK,GAAuB,IAAI,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEvE,MAAM,CAAS;IACf,KAAK,CAAS;IAEf,MAAM,CAAS;IACf,OAAO,CAAU;IAEjC,YAAmB,MAAc,EAAE,KAAK,GAAW,CAAC,EAAE,MAAe;QACnE,MAAM,UAAU,GAAG,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC;QACnD,kBAAkB,CAAC,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QAEnE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC;IACnC,CAAC;IAEM,GAAG,CAAC,KAAa;QACtB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,MAAM;YAC/D,MAAM,IAAI,wBAAwB,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;QAEhE,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC;IAChD,CAAC;IAEM,KAAK,CAAC,KAAa,EAAE,MAAe;QACzC,MAAM,UAAU,GAAG,MAAM,IAAI,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACjD,kBAAkB,CAAC,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAEjE,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,GAAG,KAAK,EAAE,UAAU,CAAC,CAAC;IAC7E,CAAC;IAEM,QAAQ;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IACjE,CAAC;IAEO,MAAM,CAAC,aAAa,CAAC,KAAa,EAAE,MAAc,EAAE,YAAoB;QAC9E,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,YAAY;YAC/D,MAAM,IAAI,2BAA2B,CAAC,SAAS,CAAC,kBAAkB,EAAE,KAAK,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC;QAErG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC;YACzC,MAAM,IAAI,2BAA2B,CAAC,SAAS,CAAC,mBAAmB,EAAE,MAAM,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC;QAExG,IAAI,KAAK,GAAG,MAAM,GAAG,YAAY;YAC/B,MAAM,IAAI,2BAA2B,CAAC,SAAS,CAAC,mBAAmB,EAAE,MAAM,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3G,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,26 @@
1
1
  {
2
2
  "name": "@noldova/context.text",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "main": "api/index.js",
6
+ "types": "api/index.d.ts",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/noldova-com/context.git",
11
+ "directory": "src/noldova.context.text"
12
+ },
13
+ "homepage": "https://github.com/noldova-com/context#readme",
14
+ "bugs": {
15
+ "url": "https://github.com/noldova-com/context/issues"
16
+ },
17
+ "publishConfig": {
18
+ "access": "public",
19
+ "registry": "https://registry.npmjs.org/"
20
+ },
21
+ "dependencies": {
22
+ "@noldova/context.collections": "0.0.1",
23
+ "@noldova/context.core": "0.0.1",
24
+ "@noldova/context.exceptions": "0.0.1"
25
+ }
26
+ }