@bitbybit-dev/base 1.2.0 → 1.3.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.
- package/lib/api/GlobalCDNProvider.js +1 -1
- package/lib/api/inputs/base-inputs.d.ts +13 -12
- package/lib/api/inputs/color-inputs.d.ts +97 -48
- package/lib/api/inputs/color-inputs.js +95 -46
- package/lib/api/inputs/dates-inputs.d.ts +67 -26
- package/lib/api/inputs/dates-inputs.js +57 -16
- package/lib/api/inputs/io-inputs.d.ts +13 -15
- package/lib/api/inputs/io-inputs.js +7 -8
- package/lib/api/inputs/line-inputs.d.ts +88 -33
- package/lib/api/inputs/line-inputs.js +61 -11
- package/lib/api/inputs/lists-inputs.d.ts +207 -96
- package/lib/api/inputs/lists-inputs.js +153 -45
- package/lib/api/inputs/logic-inputs.d.ts +52 -22
- package/lib/api/inputs/logic-inputs.js +41 -12
- package/lib/api/inputs/math-inputs.d.ts +113 -52
- package/lib/api/inputs/math-inputs.js +112 -51
- package/lib/api/inputs/mesh-inputs.d.ts +30 -11
- package/lib/api/inputs/mesh-inputs.js +21 -3
- package/lib/api/inputs/point-inputs.d.ts +240 -107
- package/lib/api/inputs/point-inputs.js +199 -73
- package/lib/api/inputs/polyline-inputs.d.ts +68 -28
- package/lib/api/inputs/polyline-inputs.js +48 -13
- package/lib/api/inputs/text-inputs.d.ts +117 -46
- package/lib/api/inputs/text-inputs.js +111 -41
- package/lib/api/inputs/transforms-inputs.d.ts +65 -23
- package/lib/api/inputs/transforms-inputs.js +64 -22
- package/lib/api/inputs/vector-inputs.d.ts +154 -76
- package/lib/api/inputs/vector-inputs.js +132 -57
- package/lib/api/models/point/hex-grid-data.d.ts +1 -1
- package/lib/api/models/point/hex-grid-data.js +1 -1
- package/lib/api/services/color.d.ts +149 -70
- package/lib/api/services/color.js +149 -70
- package/lib/api/services/dates.d.ts +313 -150
- package/lib/api/services/dates.js +313 -150
- package/lib/api/services/line.d.ts +138 -68
- package/lib/api/services/line.js +138 -68
- package/lib/api/services/lists.d.ts +357 -177
- package/lib/api/services/lists.js +357 -177
- package/lib/api/services/logic.d.ts +98 -45
- package/lib/api/services/logic.js +98 -45
- package/lib/api/services/math.d.ts +363 -211
- package/lib/api/services/math.js +363 -211
- package/lib/api/services/mesh.d.ts +73 -31
- package/lib/api/services/mesh.js +73 -31
- package/lib/api/services/point.d.ts +367 -147
- package/lib/api/services/point.js +367 -147
- package/lib/api/services/polyline.d.ts +146 -71
- package/lib/api/services/polyline.js +146 -71
- package/lib/api/services/text.d.ts +320 -165
- package/lib/api/services/text.js +320 -165
- package/lib/api/services/transforms.d.ts +145 -58
- package/lib/api/services/transforms.js +145 -58
- package/lib/api/services/vector.d.ts +381 -156
- package/lib/api/services/vector.js +381 -156
- package/package.json +1 -1
|
@@ -2,369 +2,524 @@ import * as Inputs from "../inputs";
|
|
|
2
2
|
import * as Models from "../models";
|
|
3
3
|
import { Point } from "./point";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Working with text: splitting, joining, searching, trimming, padding, changing case, regular
|
|
6
|
+
* expressions and formatting with placeholders. `vectorChar` and `vectorText` turn text into line
|
|
7
|
+
* paths drawn with a simple stroke font, so words can become geometry. Positions in text count from
|
|
8
|
+
* 0.
|
|
6
9
|
*/
|
|
7
10
|
export declare class TextBitByBit {
|
|
8
11
|
private readonly point;
|
|
9
12
|
constructor(point: Point);
|
|
10
13
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* @
|
|
14
|
+
* Passes a text through unchanged, so a value can be given a name and reused.
|
|
15
|
+
*
|
|
16
|
+
* Example: 'Hello World' -> 'Hello World'
|
|
17
|
+
* @param inputs - The text
|
|
18
|
+
* @returns The same text
|
|
15
19
|
* @group create
|
|
16
20
|
* @shortname text
|
|
17
21
|
* @drawable false
|
|
18
22
|
*/
|
|
19
23
|
create(inputs: Inputs.Text.TextDto): string;
|
|
20
24
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
* Cuts a text into pieces wherever a separator occurs; the separator itself is dropped.
|
|
26
|
+
*
|
|
27
|
+
* Example: 'apple,banana,cherry' split by ',' -> ['apple', 'banana', 'cherry']
|
|
28
|
+
* @param inputs - The text and the separator
|
|
29
|
+
* @returns The pieces, in order
|
|
30
|
+
* @group transform
|
|
31
|
+
* @shortname split
|
|
32
|
+
* @drawable false
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const parts = bitbybit.text.split({ text: "apple,banana,cherry", separator: "," });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
29
38
|
split(inputs: Inputs.Text.TextSplitDto): string[];
|
|
30
39
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
* Replaces every occurrence of a search text with another text.
|
|
41
|
+
*
|
|
42
|
+
* Example: 'hello hello' replacing 'hello' with 'hi' -> 'hi hi'
|
|
43
|
+
* @param inputs - The text, what to search for and what to put in its place
|
|
44
|
+
* @returns The text with the replacements made
|
|
45
|
+
* @group transform
|
|
46
|
+
* @shortname replaceAll
|
|
47
|
+
* @drawable false
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const greeting = bitbybit.text.replaceAll({ text: "hello hello", search: "hello", replaceWith: "hi" });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
39
53
|
replaceAll(inputs: Inputs.Text.TextReplaceDto): string;
|
|
40
54
|
/**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
55
|
+
* Joins a list of texts into one, with a separator between neighbors.
|
|
56
|
+
*
|
|
57
|
+
* Example: ['apple', 'banana', 'cherry'] joined by ', ' -> 'apple, banana, cherry'
|
|
58
|
+
* @param inputs - The texts and the separator
|
|
59
|
+
* @returns The joined text
|
|
60
|
+
* @group transform
|
|
61
|
+
* @shortname join
|
|
62
|
+
* @drawable false
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const line = bitbybit.text.join({ list: ["apple", "banana"], separator: ", " });
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
49
68
|
join(inputs: Inputs.Text.TextJoinDto): string;
|
|
50
69
|
/**
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
70
|
+
* Turns any value into text, the way JavaScript prints it.
|
|
71
|
+
*
|
|
72
|
+
* Example: 42 -> '42', [1, 2] -> '1,2'
|
|
73
|
+
* @param inputs - The value
|
|
74
|
+
* @returns The value as text
|
|
75
|
+
* @group transform
|
|
76
|
+
* @shortname to string
|
|
77
|
+
* @drawable false
|
|
78
|
+
*/
|
|
58
79
|
toString<T>(inputs: Inputs.Text.ToStringDto<T>): string;
|
|
59
80
|
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
81
|
+
* Turns every item of a list into text, the way JavaScript prints it.
|
|
82
|
+
*
|
|
83
|
+
* Example: [1, 2.5, true] -> ['1', '2.5', 'true']
|
|
84
|
+
* @param inputs - The list of values
|
|
85
|
+
* @returns One text per item, in order
|
|
86
|
+
* @group transform
|
|
87
|
+
* @shortname to strings
|
|
88
|
+
* @drawable false
|
|
89
|
+
*/
|
|
67
90
|
toStringEach<T>(inputs: Inputs.Text.ToStringEachDto<T>): string[];
|
|
68
91
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
92
|
+
* Fills numbered placeholders in a text with values: `{0}` takes the first value, `{1}` the
|
|
93
|
+
* second, and so on.
|
|
94
|
+
*
|
|
95
|
+
* A placeholder without a value is left as it is.
|
|
96
|
+
* Example: 'Point: ({0}, {1})' with [10, 5] -> 'Point: (10, 5)'
|
|
97
|
+
* @param inputs - The text with placeholders and the values to fill in
|
|
98
|
+
* @returns The filled-in text
|
|
73
99
|
* @group transform
|
|
74
100
|
* @shortname format
|
|
75
101
|
* @drawable false
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* const label = bitbybit.text.format({ text: "Point: ({0}, {1})", values: ["10", "5"] });
|
|
105
|
+
* ```
|
|
76
106
|
*/
|
|
77
107
|
format(inputs: Inputs.Text.TextFormatDto): string;
|
|
78
108
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* @
|
|
109
|
+
* Tells whether a text contains a search text.
|
|
110
|
+
*
|
|
111
|
+
* Example: 'hello world' includes 'world' -> true
|
|
112
|
+
* @param inputs - The text and what to look for
|
|
113
|
+
* @returns True when the search text occurs in it
|
|
83
114
|
* @group query
|
|
84
115
|
* @shortname includes
|
|
85
116
|
* @drawable false
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* const has = bitbybit.text.includes({ text: "hello world", search: "world" });
|
|
120
|
+
* ```
|
|
86
121
|
*/
|
|
87
122
|
includes(inputs: Inputs.Text.TextSearchDto): boolean;
|
|
88
123
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* @
|
|
124
|
+
* Tells whether a text begins with a search text.
|
|
125
|
+
*
|
|
126
|
+
* Example: 'hello world' starts with 'hello' -> true
|
|
127
|
+
* @param inputs - The text and what to look for at its start
|
|
128
|
+
* @returns True when the text begins with it
|
|
93
129
|
* @group query
|
|
94
130
|
* @shortname starts with
|
|
95
131
|
* @drawable false
|
|
132
|
+
* @example
|
|
133
|
+
* ```typescript
|
|
134
|
+
* const starts = bitbybit.text.startsWith({ text: "hello world", search: "hello" });
|
|
135
|
+
* ```
|
|
96
136
|
*/
|
|
97
137
|
startsWith(inputs: Inputs.Text.TextSearchDto): boolean;
|
|
98
138
|
/**
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* @
|
|
139
|
+
* Tells whether a text ends with a search text.
|
|
140
|
+
*
|
|
141
|
+
* Example: 'hello world' ends with 'world' -> true
|
|
142
|
+
* @param inputs - The text and what to look for at its end
|
|
143
|
+
* @returns True when the text ends with it
|
|
103
144
|
* @group query
|
|
104
145
|
* @shortname ends with
|
|
105
146
|
* @drawable false
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* const ends = bitbybit.text.endsWith({ text: "hello world", search: "world" });
|
|
150
|
+
* ```
|
|
106
151
|
*/
|
|
107
152
|
endsWith(inputs: Inputs.Text.TextSearchDto): boolean;
|
|
108
153
|
/**
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
154
|
+
* Finds where a search text first occurs, counting characters from 0, or -1 when it does not
|
|
155
|
+
* occur.
|
|
156
|
+
*
|
|
157
|
+
* Example: 'hello world' finding 'world' -> 6
|
|
158
|
+
* @param inputs - The text and what to look for
|
|
159
|
+
* @returns The position of the first occurrence, or -1
|
|
113
160
|
* @group query
|
|
114
161
|
* @shortname index of
|
|
115
162
|
* @drawable false
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* const at = bitbybit.text.indexOf({ text: "hello world", search: "world" });
|
|
166
|
+
* ```
|
|
116
167
|
*/
|
|
117
168
|
indexOf(inputs: Inputs.Text.TextSearchDto): number;
|
|
118
169
|
/**
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
170
|
+
* Finds where a search text last occurs, counting characters from 0, or -1 when it does not
|
|
171
|
+
* occur.
|
|
172
|
+
*
|
|
173
|
+
* Example: 'hello world hello' finding 'hello' -> 12
|
|
174
|
+
* @param inputs - The text and what to look for
|
|
175
|
+
* @returns The position of the last occurrence, or -1
|
|
123
176
|
* @group query
|
|
124
177
|
* @shortname last index of
|
|
125
178
|
* @drawable false
|
|
179
|
+
* @example
|
|
180
|
+
* ```typescript
|
|
181
|
+
* const at = bitbybit.text.lastIndexOf({ text: "hello world hello", search: "hello" });
|
|
182
|
+
* ```
|
|
126
183
|
*/
|
|
127
184
|
lastIndexOf(inputs: Inputs.Text.TextSearchDto): number;
|
|
128
185
|
/**
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
186
|
+
* Takes the characters from a start position up to, but not including, an end position.
|
|
187
|
+
*
|
|
188
|
+
* A start larger than the end swaps the two, and negative positions count as 0.
|
|
189
|
+
* Example: 'hello world' from 0 to 5 -> 'hello'
|
|
190
|
+
* @param inputs - The text and the start and end positions
|
|
191
|
+
* @returns The characters in that range
|
|
133
192
|
* @group transform
|
|
134
193
|
* @shortname substring
|
|
135
194
|
* @drawable false
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* const word = bitbybit.text.substring({ text: "hello world", start: 0, end: 5 });
|
|
198
|
+
* ```
|
|
136
199
|
*/
|
|
137
200
|
substring(inputs: Inputs.Text.TextSubstringDto): string;
|
|
138
201
|
/**
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
202
|
+
* Takes the characters from a start position up to, but not including, an end position.
|
|
203
|
+
*
|
|
204
|
+
* Unlike `substring`, a negative position counts from the end of the text.
|
|
205
|
+
* Example: 'hello world' from 0 to 5 -> 'hello'; from -5 -> 'world'
|
|
206
|
+
* @param inputs - The text and the start and end positions
|
|
207
|
+
* @returns The characters in that range
|
|
143
208
|
* @group transform
|
|
144
209
|
* @shortname slice
|
|
145
210
|
* @drawable false
|
|
211
|
+
* @example
|
|
212
|
+
* ```typescript
|
|
213
|
+
* const tail = bitbybit.text.slice({ text: "hello world", start: 6, end: 11 });
|
|
214
|
+
* ```
|
|
146
215
|
*/
|
|
147
216
|
slice(inputs: Inputs.Text.TextSubstringDto): string;
|
|
148
217
|
/**
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
* @
|
|
218
|
+
* Reads the character at a position, counting from 0.
|
|
219
|
+
*
|
|
220
|
+
* Example: 'hello' at 1 -> 'e'
|
|
221
|
+
* @param inputs - The text and the position
|
|
222
|
+
* @returns The character, or an empty text when the position is outside the text
|
|
153
223
|
* @group query
|
|
154
224
|
* @shortname char at
|
|
155
225
|
* @drawable false
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* const second = bitbybit.text.charAt({ text: "hello", index: 1 });
|
|
229
|
+
* ```
|
|
156
230
|
*/
|
|
157
231
|
charAt(inputs: Inputs.Text.TextIndexDto): string;
|
|
158
232
|
/**
|
|
159
|
-
* Removes
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* @
|
|
233
|
+
* Removes spaces, tabs and line breaks from both ends of a text.
|
|
234
|
+
*
|
|
235
|
+
* Example: ' hello ' -> 'hello'
|
|
236
|
+
* @param inputs - The text
|
|
237
|
+
* @returns The trimmed text
|
|
163
238
|
* @group transform
|
|
164
239
|
* @shortname trim
|
|
165
240
|
* @drawable false
|
|
166
241
|
*/
|
|
167
242
|
trim(inputs: Inputs.Text.TextDto): string;
|
|
168
243
|
/**
|
|
169
|
-
* Removes
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
* @
|
|
244
|
+
* Removes spaces, tabs and line breaks from the start of a text.
|
|
245
|
+
*
|
|
246
|
+
* Example: ' hello ' -> 'hello '
|
|
247
|
+
* @param inputs - The text
|
|
248
|
+
* @returns The text without leading whitespace
|
|
173
249
|
* @group transform
|
|
174
250
|
* @shortname trim start
|
|
175
251
|
* @drawable false
|
|
176
252
|
*/
|
|
177
253
|
trimStart(inputs: Inputs.Text.TextDto): string;
|
|
178
254
|
/**
|
|
179
|
-
* Removes
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
* @
|
|
255
|
+
* Removes spaces, tabs and line breaks from the end of a text.
|
|
256
|
+
*
|
|
257
|
+
* Example: ' hello ' -> ' hello'
|
|
258
|
+
* @param inputs - The text
|
|
259
|
+
* @returns The text without trailing whitespace
|
|
183
260
|
* @group transform
|
|
184
261
|
* @shortname trim end
|
|
185
262
|
* @drawable false
|
|
186
263
|
*/
|
|
187
264
|
trimEnd(inputs: Inputs.Text.TextDto): string;
|
|
188
265
|
/**
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
266
|
+
* Adds a filler text in front until the text reaches a length; a text already that long is left
|
|
267
|
+
* alone.
|
|
268
|
+
*
|
|
269
|
+
* Example: 'x' to length 3 with 'a' -> 'aax'
|
|
270
|
+
* @param inputs - The text, the length to reach and the filler
|
|
271
|
+
* @returns The padded text
|
|
193
272
|
* @group transform
|
|
194
273
|
* @shortname pad start
|
|
195
274
|
* @drawable false
|
|
275
|
+
* @example
|
|
276
|
+
* ```typescript
|
|
277
|
+
* const padded = bitbybit.text.padStart({ text: "7", length: 3, padString: "0" });
|
|
278
|
+
* ```
|
|
196
279
|
*/
|
|
197
280
|
padStart(inputs: Inputs.Text.TextPadDto): string;
|
|
198
281
|
/**
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
282
|
+
* Adds a filler text behind until the text reaches a length; a text already that long is left
|
|
283
|
+
* alone.
|
|
284
|
+
*
|
|
285
|
+
* Example: 'x' to length 3 with 'a' -> 'xaa'
|
|
286
|
+
* @param inputs - The text, the length to reach and the filler
|
|
287
|
+
* @returns The padded text
|
|
203
288
|
* @group transform
|
|
204
289
|
* @shortname pad end
|
|
205
290
|
* @drawable false
|
|
291
|
+
* @example
|
|
292
|
+
* ```typescript
|
|
293
|
+
* const padded = bitbybit.text.padEnd({ text: "x", length: 3, padString: "a" });
|
|
294
|
+
* ```
|
|
206
295
|
*/
|
|
207
296
|
padEnd(inputs: Inputs.Text.TextPadDto): string;
|
|
208
297
|
/**
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
* @
|
|
298
|
+
* Turns every letter into a capital.
|
|
299
|
+
*
|
|
300
|
+
* Example: 'hello' -> 'HELLO'
|
|
301
|
+
* @param inputs - The text
|
|
302
|
+
* @returns The text in capitals
|
|
213
303
|
* @group transform
|
|
214
304
|
* @shortname to upper case
|
|
215
305
|
* @drawable false
|
|
216
306
|
*/
|
|
217
307
|
toUpperCase(inputs: Inputs.Text.TextDto): string;
|
|
218
308
|
/**
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
* @
|
|
309
|
+
* Turns every letter into lower case.
|
|
310
|
+
*
|
|
311
|
+
* Example: 'HELLO' -> 'hello'
|
|
312
|
+
* @param inputs - The text
|
|
313
|
+
* @returns The text in lower case
|
|
223
314
|
* @group transform
|
|
224
315
|
* @shortname to lower case
|
|
225
316
|
* @drawable false
|
|
226
317
|
*/
|
|
227
318
|
toLowerCase(inputs: Inputs.Text.TextDto): string;
|
|
228
319
|
/**
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
* @
|
|
320
|
+
* Turns the first character into a capital and leaves the rest as it is.
|
|
321
|
+
*
|
|
322
|
+
* Example: 'hello world' -> 'Hello world'
|
|
323
|
+
* @param inputs - The text
|
|
324
|
+
* @returns The text with its first character capitalized
|
|
233
325
|
* @group transform
|
|
234
326
|
* @shortname capitalize first
|
|
235
327
|
* @drawable false
|
|
236
328
|
*/
|
|
237
329
|
toUpperCaseFirst(inputs: Inputs.Text.TextDto): string;
|
|
238
330
|
/**
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
* @
|
|
331
|
+
* Turns the first character into lower case and leaves the rest as it is.
|
|
332
|
+
*
|
|
333
|
+
* Example: 'Hello World' -> 'hello World'
|
|
334
|
+
* @param inputs - The text
|
|
335
|
+
* @returns The text with its first character in lower case
|
|
243
336
|
* @group transform
|
|
244
337
|
* @shortname uncapitalize first
|
|
245
338
|
* @drawable false
|
|
246
339
|
*/
|
|
247
340
|
toLowerCaseFirst(inputs: Inputs.Text.TextDto): string;
|
|
248
341
|
/**
|
|
249
|
-
* Repeats text a
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
* @
|
|
342
|
+
* Repeats a text a number of times, end to end.
|
|
343
|
+
*
|
|
344
|
+
* Example: 'ha' three times -> 'hahaha'
|
|
345
|
+
* @param inputs - The text and how many times to repeat it
|
|
346
|
+
* @returns The repeated text
|
|
253
347
|
* @group transform
|
|
254
348
|
* @shortname repeat
|
|
255
349
|
* @drawable false
|
|
350
|
+
* @example
|
|
351
|
+
* ```typescript
|
|
352
|
+
* const laugh = bitbybit.text.repeat({ text: "ha", count: 3 });
|
|
353
|
+
* ```
|
|
256
354
|
*/
|
|
257
355
|
repeat(inputs: Inputs.Text.TextRepeatDto): string;
|
|
258
356
|
/**
|
|
259
|
-
* Reverses the
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
* @
|
|
357
|
+
* Reverses the order of the characters.
|
|
358
|
+
*
|
|
359
|
+
* Example: 'hello' -> 'olleh'
|
|
360
|
+
* @param inputs - The text
|
|
361
|
+
* @returns The reversed text
|
|
263
362
|
* @group transform
|
|
264
363
|
* @shortname reverse
|
|
265
364
|
* @drawable false
|
|
266
365
|
*/
|
|
267
366
|
reverse(inputs: Inputs.Text.TextDto): string;
|
|
268
367
|
/**
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
* @
|
|
368
|
+
* Counts the characters in a text.
|
|
369
|
+
*
|
|
370
|
+
* Example: 'hello' -> 5
|
|
371
|
+
* @param inputs - The text
|
|
372
|
+
* @returns The number of characters
|
|
273
373
|
* @group query
|
|
274
374
|
* @shortname length
|
|
275
375
|
* @drawable false
|
|
276
376
|
*/
|
|
277
377
|
length(inputs: Inputs.Text.TextDto): number;
|
|
278
378
|
/**
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
* @
|
|
379
|
+
* Tells whether a text is empty or holds only whitespace.
|
|
380
|
+
*
|
|
381
|
+
* Example: ' ' -> true, 'a' -> false
|
|
382
|
+
* @param inputs - The text
|
|
383
|
+
* @returns True when there is nothing but whitespace
|
|
283
384
|
* @group query
|
|
284
385
|
* @shortname is empty
|
|
285
386
|
* @drawable false
|
|
286
387
|
*/
|
|
287
388
|
isEmpty(inputs: Inputs.Text.TextDto): boolean;
|
|
288
389
|
/**
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
* @
|
|
390
|
+
* Joins several texts into one with nothing between them.
|
|
391
|
+
*
|
|
392
|
+
* Example: ['hello', ' ', 'world'] -> 'hello world'
|
|
393
|
+
* @param inputs - The texts to join
|
|
394
|
+
* @returns The joined text
|
|
293
395
|
* @group transform
|
|
294
396
|
* @shortname concat
|
|
295
397
|
* @drawable false
|
|
398
|
+
* @example
|
|
399
|
+
* ```typescript
|
|
400
|
+
* const sentence = bitbybit.text.concat({ texts: ["hello", " ", "world"] });
|
|
401
|
+
* ```
|
|
296
402
|
*/
|
|
297
403
|
concat(inputs: Inputs.Text.TextConcatDto): string;
|
|
298
404
|
/**
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
* @
|
|
405
|
+
* Tells whether a regular expression matches somewhere in a text.
|
|
406
|
+
*
|
|
407
|
+
* Example: 'hello123' against '[0-9]+' -> true
|
|
408
|
+
* @param inputs - The text, the pattern and the flags
|
|
409
|
+
* @returns True when the pattern matches
|
|
303
410
|
* @group regex
|
|
304
411
|
* @shortname test regex
|
|
305
412
|
* @drawable false
|
|
413
|
+
* @example
|
|
414
|
+
* ```typescript
|
|
415
|
+
* const hasDigits = bitbybit.text.regexTest({ text: "hello123", pattern: "[0-9]+", flags: "" });
|
|
416
|
+
* ```
|
|
306
417
|
*/
|
|
307
418
|
regexTest(inputs: Inputs.Text.TextRegexDto): boolean;
|
|
308
419
|
/**
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
420
|
+
* Finds the parts of a text that a regular expression matches.
|
|
421
|
+
*
|
|
422
|
+
* With the `g` flag every match is listed; without it only the first match and its capture
|
|
423
|
+
* groups. No match gives null.
|
|
424
|
+
* Example: 'hello123world456' against '[0-9]+' with 'g' -> ['123', '456']
|
|
425
|
+
* @param inputs - The text, the pattern and the flags
|
|
426
|
+
* @returns The matches, or null when there are none
|
|
313
427
|
* @group regex
|
|
314
428
|
* @shortname regex match
|
|
315
429
|
* @drawable false
|
|
430
|
+
* @example
|
|
431
|
+
* ```typescript
|
|
432
|
+
* const numbers = bitbybit.text.regexMatch({ text: "hello123world456", pattern: "[0-9]+", flags: "g" });
|
|
433
|
+
* ```
|
|
316
434
|
*/
|
|
317
435
|
regexMatch(inputs: Inputs.Text.TextRegexDto): string[] | null;
|
|
318
436
|
/**
|
|
319
|
-
* Replaces
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
437
|
+
* Replaces what a regular expression matches with another text.
|
|
438
|
+
*
|
|
439
|
+
* With the `g` flag every match is replaced; without it only the first.
|
|
440
|
+
* Example: 'hello123world456' against '[0-9]+' with 'g', replaced by 'X' -> 'helloXworldX'
|
|
441
|
+
* @param inputs - The text, the pattern, the flags and the replacement
|
|
442
|
+
* @returns The text with the replacements made
|
|
323
443
|
* @group regex
|
|
324
444
|
* @shortname regex replace
|
|
325
445
|
* @drawable false
|
|
446
|
+
* @example
|
|
447
|
+
* ```typescript
|
|
448
|
+
* const clean = bitbybit.text.regexReplace({ text: "hello123world456", pattern: "[0-9]+", flags: "g", replaceWith: "X" });
|
|
449
|
+
* ```
|
|
326
450
|
*/
|
|
327
451
|
regexReplace(inputs: Inputs.Text.TextRegexReplaceDto): string;
|
|
328
452
|
/**
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
453
|
+
* Finds where a regular expression first matches, counting characters from 0, or -1 when it
|
|
454
|
+
* does not match.
|
|
455
|
+
*
|
|
456
|
+
* Example: 'hello123' against '[0-9]+' -> 5
|
|
457
|
+
* @param inputs - The text, the pattern and the flags
|
|
458
|
+
* @returns The position of the first match, or -1
|
|
333
459
|
* @group regex
|
|
334
460
|
* @shortname regex search
|
|
335
461
|
* @drawable false
|
|
462
|
+
* @example
|
|
463
|
+
* ```typescript
|
|
464
|
+
* const at = bitbybit.text.regexSearch({ text: "hello123", pattern: "[0-9]+", flags: "" });
|
|
465
|
+
* ```
|
|
336
466
|
*/
|
|
337
467
|
regexSearch(inputs: Inputs.Text.TextRegexDto): number;
|
|
338
468
|
/**
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
469
|
+
* Cuts a text into pieces wherever a regular expression matches; the matches themselves are
|
|
470
|
+
* dropped.
|
|
471
|
+
*
|
|
472
|
+
* Example: 'a1b2c3' split by '[0-9]+' -> ['a', 'b', 'c', '']
|
|
473
|
+
* @param inputs - The text, the pattern and the flags
|
|
474
|
+
* @returns The pieces, in order
|
|
343
475
|
* @group regex
|
|
344
476
|
* @shortname regex split
|
|
345
477
|
* @drawable false
|
|
478
|
+
* @example
|
|
479
|
+
* ```typescript
|
|
480
|
+
* const letters = bitbybit.text.regexSplit({ text: "a1b2c3", pattern: "[0-9]+", flags: "" });
|
|
481
|
+
* ```
|
|
346
482
|
*/
|
|
347
483
|
regexSplit(inputs: Inputs.Text.TextRegexDto): string[];
|
|
348
484
|
/**
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
485
|
+
* Draws one character as line paths with a simple stroke font.
|
|
486
|
+
*
|
|
487
|
+
* The paths lie flat on the XZ plane, scaled so the character is `height` tall, and are
|
|
488
|
+
* returned with the character's width and height. An unknown character is drawn as a question
|
|
489
|
+
* mark.
|
|
490
|
+
* Example: 'A' at height 10 -> the strokes of an A, 10 units tall
|
|
491
|
+
* @param inputs - The character, its height and its offsets
|
|
492
|
+
* @returns The character's width, height and stroke paths as lists of points
|
|
354
493
|
* @group vector
|
|
355
494
|
* @shortname vector char
|
|
356
495
|
* @drawable false
|
|
496
|
+
* @example
|
|
497
|
+
* ```typescript
|
|
498
|
+
* const letter = bitbybit.text.vectorChar({ char: "A", height: 10, xOffset: 0, yOffset: 0, extrudeOffset: 0 });
|
|
499
|
+
* ```
|
|
357
500
|
*/
|
|
358
501
|
vectorChar(inputs: Inputs.Text.VectorCharDto): Models.Text.VectorCharData;
|
|
359
502
|
/**
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
*
|
|
503
|
+
* Draws a text, with line breaks, as line paths with a simple stroke font.
|
|
504
|
+
*
|
|
505
|
+
* Each line comes back as its characters with their paths, laid out flat on the XZ plane with
|
|
506
|
+
* the given height, spacing and alignment; `centerOnOrigin` puts the middle of the block at the
|
|
507
|
+
* origin.
|
|
508
|
+
* Example: 'Hello' at height 10 -> five characters with their strokes
|
|
509
|
+
* @param inputs - The text and how to lay it out
|
|
510
|
+
* @returns One entry per line, each with its characters and their stroke paths
|
|
365
511
|
* @group vector
|
|
366
512
|
* @shortname vector text
|
|
367
513
|
* @drawable false
|
|
514
|
+
* @example
|
|
515
|
+
* ```typescript
|
|
516
|
+
* const lines = bitbybit.text.vectorText({
|
|
517
|
+
* text: "Hello\nWorld",
|
|
518
|
+
* height: 10,
|
|
519
|
+
* align: Bit.Inputs.Base.horizontalAlignEnum.center,
|
|
520
|
+
* centerOnOrigin: true,
|
|
521
|
+
* });
|
|
522
|
+
* ```
|
|
368
523
|
*/
|
|
369
524
|
vectorText(inputs: Inputs.Text.VectorTextDto): Models.Text.VectorTextData[];
|
|
370
525
|
private vectorParamsChar;
|