-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuilder.d.ts
134 lines (134 loc) · 4.2 KB
/
builder.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
export class UnicodeTrieBuilder {
/**
* Create a builder. Ideally this is called from tooling at build time,
* and is not included in your runtime. It is optimized for generating
* small output that can be looked up fast, once frozen.
*
* @param {number|string} initialValue Default value if none other specified.
* @param {number|string} errorValue Error value for out of range inputs.
* @param {string[]} [values=[]] Initial set of strings that are mapped to
* numbers.
*/
constructor(initialValue: number | string, errorValue: number | string, values?: string[] | undefined);
values: string[];
valueMap: {
[k: string]: number;
};
initialValue: number;
errorValue: number;
index1: Int32Array;
index2: Int32Array;
highStart: number;
data: Uint32Array;
dataCapacity: number;
firstFreeBlock: number;
isCompacted: boolean;
map: Int32Array;
dataNullOffset: number;
dataLength: number;
index2NullOffset: number;
index2Length: number;
/**
* Set a single codePoint's value.
*
* @param {number} codePoint
* @param {number|string} value
* @returns {this}
*/
set(codePoint: number, value: number | string): this;
/**
* Sets a value for a range of codePoints.
*
* @param {number} start
* @param {number} end
* @param {number|string} value
* @param {boolean} overwrite
* @returns {this}
*/
setRange(start: number, end: number, value: number | string, overwrite: boolean): this;
/**
* Get the value for a codePoint.
*
* @param {number} c CodePoint.
* @param {boolean} fromLSCP
* @returns {number}
*/
get(c: number, fromLSCP?: boolean): number;
/**
* Get the string associated with a codePoint.
*
* @param {number} c
* @returns {number|string}
*/
getString(c: number): number | string;
/**
* Compact the storage and prepare data for fast lookups.
*
* @returns {UnicodeTrie}
*/
freeze(): UnicodeTrie;
/**
* Generates a Uint8Array containing the serialized and compressed trie.
* Trie data is compressed using the brotli algorithm to minimize file size.
* Format:
* uint32_t highStart;
* uint32_t errorValue;
* uint32_t compressedDataLength;
* uint8_t trieData[compressedDataLength];
* uint8_t compressedJSONstringValuesArray[];
* @returns {Uint8Array}
*/
toBuffer(): Uint8Array;
/**
* @typedef {object} ModuleOptions
* @prop {string=} [version] Version of the source file, usually the Unicode
* version.
* @prop {string=} [date] Date the source file was created. Can be parsed
* from most UCD files.
* @prop {string} [name="Trie"] Name exported from the module with the Trie
* instance.
* @prop {string} [quot='"'] Quote. Should be single or double.
* @prop {string} [semi=";"] Include semicolons? Pass in "" to disable.
* @prop {string} [pkg="@cto.af/unicode-trie"] Package name for this
* package. Mostly useful for internal tooling.
*/
/**
* Create a string version of a JS module that will reconstitute this trie.
* Suitable for saving to a .mjs file.
*
* @param {ModuleOptions} [opts={}]
* @returns {string}
*/
toModule(opts?: {
/**
* Version of the source file, usually the Unicode
* version.
*/
version?: string | undefined;
/**
* Date the source file was created. Can be parsed
* from most UCD files.
*/
date?: string | undefined;
/**
* Name exported from the module with the Trie
* instance.
*/
name?: string | undefined;
/**
* Quote. Should be single or double.
*/
quot?: string | undefined;
/**
* Include semicolons? Pass in "" to disable.
*/
semi?: string | undefined;
/**
* Package name for this
* package. Mostly useful for internal tooling.
*/
pkg?: string | undefined;
} | undefined): string;
#private;
}
import { UnicodeTrie } from './index.js';