@noldova/context.text 0.0.1 → 0.0.3

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 (2) hide show
  1. package/README.md +40 -0
  2. package/package.json +4 -4
package/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # noldova.context.text
2
+
3
+ Text building blocks for CONTEXT libraries and parsers: a read-only view of part
4
+ of a string, a string builder, line-terminator rules, Unicode identifier
5
+ classification, and `String` additions that importing the package installs.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @noldova/context.text
11
+ ```
12
+
13
+ ## Use
14
+
15
+ ```ts
16
+ import { EcmaScriptLineTerminator, ReadOnlyStringSpan, StringBuilder, UnicodeCodePointService } from "@noldova/context.text";
17
+
18
+ const span = new ReadOnlyStringSpan("hello world", 6, 5);
19
+ span.toString(); // "world"
20
+ span.slice(1, 3).toString(); // "orl"; indexes are relative to the span.
21
+
22
+ const builder = new StringBuilder();
23
+ builder.append("hello").append(" ").append("world");
24
+ builder.toString(); // "hello world"
25
+
26
+ const terminator = new EcmaScriptLineTerminator();
27
+ terminator.getLength("a\r\nb", 1); // 2: CRLF.
28
+
29
+ UnicodeCodePointService.isIdentifierStart("a".codePointAt(0)!); // true
30
+ String.isAsciiOctalDigit("7"); // true
31
+ ```
32
+
33
+ Lengths and offsets count UTF-16 code units, as JavaScript strings do. The
34
+ declaration file `api/index.d.ts` documents every member with its contract and
35
+ examples.
36
+
37
+ ## License
38
+
39
+ MIT; see `LICENSE`. The Unicode identifier tables come from the Unicode
40
+ Character Database, under the Unicode License v3 in `THIRD-PARTY-NOTICES.txt`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noldova/context.text",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "main": "api/index.js",
6
6
  "types": "api/index.d.ts",
@@ -19,8 +19,8 @@
19
19
  "registry": "https://registry.npmjs.org/"
20
20
  },
21
21
  "dependencies": {
22
- "@noldova/context.collections": "0.0.1",
23
- "@noldova/context.core": "0.0.1",
24
- "@noldova/context.exceptions": "0.0.1"
22
+ "@noldova/context.collections": "0.0.3",
23
+ "@noldova/context.core": "0.0.3",
24
+ "@noldova/context.exceptions": "0.0.3"
25
25
  }
26
26
  }