@tempots/std 0.9.2 → 0.9.5
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/README.md +3 -0
- package/package.json +2 -2
- package/dist/arrays.d.ts +0 -49
- package/dist/arrays.js +0 -249
- package/dist/async-result.d.ts +0 -37
- package/dist/async-result.js +0 -75
- package/dist/bigint.d.ts +0 -18
- package/dist/bigint.js +0 -110
- package/dist/booleans.d.ts +0 -23
- package/dist/booleans.js +0 -68
- package/dist/colors/cmyk.d.ts +0 -21
- package/dist/colors/cmyk.js +0 -54
- package/dist/colors/convert.d.ts +0 -283
- package/dist/colors/convert.js +0 -742
- package/dist/colors/hsl.d.ts +0 -24
- package/dist/colors/hsl.js +0 -56
- package/dist/colors/hsla.d.ts +0 -18
- package/dist/colors/hsla.js +0 -35
- package/dist/colors/hsluv.d.ts +0 -24
- package/dist/colors/hsluv.js +0 -56
- package/dist/colors/hsv.d.ts +0 -24
- package/dist/colors/hsv.js +0 -54
- package/dist/colors/lab.d.ts +0 -24
- package/dist/colors/lab.js +0 -54
- package/dist/colors/lch.d.ts +0 -19
- package/dist/colors/lch.js +0 -44
- package/dist/colors/luv.d.ts +0 -19
- package/dist/colors/luv.js +0 -45
- package/dist/colors/rgb.d.ts +0 -13
- package/dist/colors/rgb.js +0 -47
- package/dist/colors/rgba.d.ts +0 -12
- package/dist/colors/rgba.js +0 -44
- package/dist/colors/srgb.d.ts +0 -24
- package/dist/colors/srgb.js +0 -51
- package/dist/colors/xyz.d.ts +0 -19
- package/dist/colors/xyz.js +0 -41
- package/dist/edit.d.ts +0 -20
- package/dist/edit.js +0 -29
- package/dist/equals.d.ts +0 -3
- package/dist/equals.js +0 -122
- package/dist/functions.d.ts +0 -20
- package/dist/functions.js +0 -38
- package/dist/json.d.ts +0 -14
- package/dist/json.js +0 -33
- package/dist/match.d.ts +0 -16
- package/dist/match.js +0 -45
- package/dist/maybe.d.ts +0 -9
- package/dist/maybe.js +0 -25
- package/dist/memoize.d.ts +0 -1
- package/dist/memoize.js +0 -9
- package/dist/newtype.d.ts +0 -28
- package/dist/newtype.js +0 -29
- package/dist/numbers.d.ts +0 -104
- package/dist/numbers.js +0 -183
- package/dist/objects.d.ts +0 -9
- package/dist/objects.js +0 -33
- package/dist/ord.d.ts +0 -19
- package/dist/ord.js +0 -73
- package/dist/reg-exps.d.ts +0 -10
- package/dist/reg-exps.js +0 -43
- package/dist/result.d.ts +0 -31
- package/dist/result.js +0 -95
- package/dist/strings.d.ts +0 -314
- package/dist/strings.js +0 -685
- package/dist/types/assert.d.ts +0 -12
- package/dist/types/assert.js +0 -13
- package/dist/types/differentiate.d.ts +0 -13
- package/dist/types/differentiate.js +0 -14
- package/dist/types/functions.d.ts +0 -22
- package/dist/types/functions.js +0 -13
- package/dist/types/generic.d.ts +0 -9
- package/dist/types/generic.js +0 -13
- package/dist/types/objects.d.ts +0 -50
- package/dist/types/objects.js +0 -13
- package/dist/types/tuples.d.ts +0 -44
- package/dist/types/tuples.js +0 -24
- package/dist/types/utility.d.ts +0 -2
- package/dist/types/utility.js +0 -1
- package/dist/uuid.d.ts +0 -13
- package/dist/uuid.js +0 -56
- package/dist/validation.d.ts +0 -23
- package/dist/validation.js +0 -44
package/dist/strings.d.ts
DELETED
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility functions to manipulate string values.
|
|
3
|
-
*/
|
|
4
|
-
import { Ord } from './ord';
|
|
5
|
-
/**
|
|
6
|
-
* Replaces all occurrances of `placeholder` in `subject` with the value `replacement`.
|
|
7
|
-
* @param subject
|
|
8
|
-
* @param placeholder
|
|
9
|
-
* @param replacement
|
|
10
|
-
*/
|
|
11
|
-
export declare function replace(subject: string, placeholder: string, replacement: string): string;
|
|
12
|
-
/**
|
|
13
|
-
* `after` searches for the first occurrance of `searchFor` and returns the text after that.
|
|
14
|
-
* If `searchFor` is not found, an empty string is returned.
|
|
15
|
-
*/
|
|
16
|
-
export declare function after(value: string, searchFor: string): string;
|
|
17
|
-
/**
|
|
18
|
-
* `afterLast` searches for the last occurrance of `searchFor` and returns the text after that.
|
|
19
|
-
* If `searchFor` is not found, an empty string is returned.
|
|
20
|
-
*/
|
|
21
|
-
export declare function afterLast(value: string, searchFor: string): string;
|
|
22
|
-
/**
|
|
23
|
-
* `before` searches for the first occurrance of `searchFor` and returns the text before that.
|
|
24
|
-
* If `searchFor` is not found, an empty string is returned.
|
|
25
|
-
*/
|
|
26
|
-
export declare function before(value: string, searchFor: string): string;
|
|
27
|
-
/**
|
|
28
|
-
* `beforeLast` searches for the last occurrance of `searchFor` and returns the text before that.
|
|
29
|
-
* If `searchFor` is not found, an empty string is returned.
|
|
30
|
-
*/
|
|
31
|
-
export declare function beforeLast(value: string, searchFor: string): string;
|
|
32
|
-
/**
|
|
33
|
-
* `capitalize` returns a string with the first character convert to upper case.
|
|
34
|
-
*/
|
|
35
|
-
export declare function capitalize(s: string): string;
|
|
36
|
-
/**
|
|
37
|
-
* Capitalize the first letter of every word in `value`. If `whiteSpaceOnly` is set to `true`
|
|
38
|
-
* the process is limited to whitespace separated words.
|
|
39
|
-
*/
|
|
40
|
-
export declare function capitalizeWords(value: string, whiteSpaceOnly?: boolean): string;
|
|
41
|
-
/**
|
|
42
|
-
* Replaces occurrances of `\r\n`, `\n\r`, `\r` with `\n`
|
|
43
|
-
*/
|
|
44
|
-
export declare function canonicalizeNewlines(value: string): string;
|
|
45
|
-
/**
|
|
46
|
-
* Compares two strings ignoring their case.
|
|
47
|
-
*/
|
|
48
|
-
export declare function compareCaseInsensitive(a: string, b: string): number;
|
|
49
|
-
export declare function endsWith(s: string, end: string): boolean;
|
|
50
|
-
export declare function endsWithCaseInsensitive(s: string, end: string): boolean;
|
|
51
|
-
export declare function startsWith(s: string, start: string): boolean;
|
|
52
|
-
export declare function startsWithCaseInsensitive(s: string, start: string): boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Compares a string `s` with many `values` and see if one of them matches its end ignoring their case.
|
|
55
|
-
*/
|
|
56
|
-
export declare function endsWithAnyCaseInsensitive(s: string, values: string[]): boolean;
|
|
57
|
-
/**
|
|
58
|
-
* Compares a string `s` with many `values` and see if one of them matches its beginning ignoring their case.
|
|
59
|
-
*/
|
|
60
|
-
export declare function startsWithAnyCaseInsensitive(s: string, values: string[]): boolean;
|
|
61
|
-
/**
|
|
62
|
-
* It cleans up all the whitespaces in the passed `value`. `collapse` does the following:
|
|
63
|
-
* - remove trailing/leading whitespaces
|
|
64
|
-
* - within the string, it collapses seqeunces of whitespaces into a single space character
|
|
65
|
-
* For whitespaces in this description, it is intended to be anything that is matched by the regular expression `\s`.
|
|
66
|
-
*/
|
|
67
|
-
export declare function collapse(value: string): string;
|
|
68
|
-
/**
|
|
69
|
-
* It compares to string and it returns a negative number if `a` is inferior to `b`, zero if they are the same,
|
|
70
|
-
* or otherwise a positive non-sero number.
|
|
71
|
-
*/
|
|
72
|
-
export declare function compare(a: string, b: string): number;
|
|
73
|
-
export declare const order: Ord<string>;
|
|
74
|
-
/**
|
|
75
|
-
* `contains` returns `true` if `s` contains one or more occurrences of `test` regardless of the text case.
|
|
76
|
-
*/
|
|
77
|
-
export declare function containsCaseInsensitive(s: string, test: string): boolean;
|
|
78
|
-
/**
|
|
79
|
-
* `contains` returns `true` if `s` contains one or more occurrences of `test`.
|
|
80
|
-
*/
|
|
81
|
-
export declare function contains(s: string, test: string): boolean;
|
|
82
|
-
/**
|
|
83
|
-
* Return the number of occurances of `test` in `s`.
|
|
84
|
-
*/
|
|
85
|
-
export declare function count(s: string, test: string): number;
|
|
86
|
-
/**
|
|
87
|
-
* `contains` returns `true` if `s` contains any of the strings in `tests` regardless of the text case
|
|
88
|
-
*/
|
|
89
|
-
export declare function containsAnyCaseInsensitive(s: string, tests: string[]): boolean;
|
|
90
|
-
/**
|
|
91
|
-
* `contains` returns `true` if `s` contains any of the strings in `tests`
|
|
92
|
-
*/
|
|
93
|
-
export declare function containsAny(s: string, tests: string[]): boolean;
|
|
94
|
-
/**
|
|
95
|
-
* `contains` returns `true` if `s` contains all of the strings in `tests` regardless of the text case
|
|
96
|
-
*/
|
|
97
|
-
export declare function containsAllCaseInsensitive(s: string, tests: string[]): boolean;
|
|
98
|
-
/**
|
|
99
|
-
* `contains` returns `true` if `s` contains all of the strings in `tests`
|
|
100
|
-
*/
|
|
101
|
-
export declare function containsAll(s: string, tests: string[]): boolean;
|
|
102
|
-
/**
|
|
103
|
-
* `dasherize` replaces all the occurrances of `_` with `-`
|
|
104
|
-
*/
|
|
105
|
-
export declare function dasherize(s: string): string;
|
|
106
|
-
/**
|
|
107
|
-
* Compares strings `a` and `b` and returns the position where they differ.
|
|
108
|
-
* ```ts
|
|
109
|
-
* diffIndex('abcdef', 'abc123') // returns 3
|
|
110
|
-
* ```
|
|
111
|
-
*/
|
|
112
|
-
export declare function diffIndex(a: string, b: string): number;
|
|
113
|
-
/**
|
|
114
|
-
* `ellipsis` truncates `s` at len `maxlen` replaces the last characters with the content
|
|
115
|
-
* of `symbol`.
|
|
116
|
-
* ```ts
|
|
117
|
-
* ellipsis('tempo is a nice library', 9) // returns 'tempo is …'
|
|
118
|
-
* ```
|
|
119
|
-
*/
|
|
120
|
-
export declare function ellipsis(s: string, maxlen?: number, symbol?: string): string;
|
|
121
|
-
/**
|
|
122
|
-
* Same as `ellipsis` but puts the symbol in the middle of the string and not to the end.
|
|
123
|
-
* ```ts
|
|
124
|
-
* ellipsisMiddle('tempo is a nice library', 18) // returns 'tempo is … library'
|
|
125
|
-
* ```
|
|
126
|
-
*/
|
|
127
|
-
export declare function ellipsisMiddle(s: string, maxlen?: number, symbol?: string): string;
|
|
128
|
-
/**
|
|
129
|
-
* Returns `true` if `s` ends with any of the values in `values`.
|
|
130
|
-
*/
|
|
131
|
-
export declare function endsWithAny(s: string, values: string[]): boolean;
|
|
132
|
-
/**
|
|
133
|
-
* `filter` applies `predicate` character by character to `s` and it returns a filtered
|
|
134
|
-
* version of the string.
|
|
135
|
-
*/
|
|
136
|
-
export declare function filter(s: string, predicate: (s: string) => boolean): string;
|
|
137
|
-
/**
|
|
138
|
-
* Same as `filter` but `predicate` operates on integer char codes instead of string characters.
|
|
139
|
-
*/
|
|
140
|
-
export declare function filterCharcode(s: string, predicate: (n: number) => boolean): string;
|
|
141
|
-
/**
|
|
142
|
-
* `from` searches for the first occurrance of `searchFor` and returns the text from that point on.
|
|
143
|
-
* If `searchFor` is not found, an empty string is returned.
|
|
144
|
-
*/
|
|
145
|
-
export declare function from(value: string, searchFor: string): string;
|
|
146
|
-
export declare function hashCode(value: string, seed?: number): number;
|
|
147
|
-
/**
|
|
148
|
-
* Returns `true` if `value` is not `null` and contains at least one character.
|
|
149
|
-
*/
|
|
150
|
-
export declare function hasContent(value: string): boolean;
|
|
151
|
-
/**
|
|
152
|
-
* Works the same as `underscore` but also replaces underscores with whitespaces.
|
|
153
|
-
*/
|
|
154
|
-
export declare function humanize(s: string): string;
|
|
155
|
-
/**
|
|
156
|
-
* Checks if `s` contains only (and at least one) alphabetical characters.
|
|
157
|
-
*/
|
|
158
|
-
export declare function isAlpha(s: string): boolean;
|
|
159
|
-
/**
|
|
160
|
-
* `isAlphaNum` returns `true` if the string only contains alpha-numeric characters.
|
|
161
|
-
*/
|
|
162
|
-
export declare function isAlphaNum(value: string): boolean;
|
|
163
|
-
export declare function isBreakingWhitespace(value: string): boolean;
|
|
164
|
-
/**
|
|
165
|
-
* Returns `true` if the value string is composed of only lower cased characters
|
|
166
|
-
* or case neutral characters.
|
|
167
|
-
*/
|
|
168
|
-
export declare function isLowerCase(value: string): boolean;
|
|
169
|
-
/**
|
|
170
|
-
* Returns `true` if the value string is composed of only upper cased characters
|
|
171
|
-
* or case neutral characters.
|
|
172
|
-
*/
|
|
173
|
-
export declare function isUpperCase(value: string): boolean;
|
|
174
|
-
/**
|
|
175
|
-
* `ifEmpty` returns `value` if it is neither `null` or empty, otherwise it returns `alt`
|
|
176
|
-
*/
|
|
177
|
-
export declare function ifEmpty(value: string, alt: string): string;
|
|
178
|
-
/**
|
|
179
|
-
* `isDigitsOnly` returns `true` if the string only contains digits.
|
|
180
|
-
*/
|
|
181
|
-
export declare function isDigitsOnly(value: string): boolean;
|
|
182
|
-
/**
|
|
183
|
-
* `isEmpty` returns true if either `value` is null or is an empty string.
|
|
184
|
-
*/
|
|
185
|
-
export declare function isEmpty(value: string): boolean;
|
|
186
|
-
/**
|
|
187
|
-
* Convert first letter in `value` to lower case.
|
|
188
|
-
*/
|
|
189
|
-
export declare function lowerCaseFirst(value: string): string;
|
|
190
|
-
/**
|
|
191
|
-
* Returns a random substring from the `value` argument. The length of such value is by default `1`.
|
|
192
|
-
*/
|
|
193
|
-
export declare function random(value: string, length?: number): string;
|
|
194
|
-
/**
|
|
195
|
-
* Returns a random sampling of the specified length from the seed string.
|
|
196
|
-
*/
|
|
197
|
-
export declare function randomSequence(alphabet: string, length: number): string;
|
|
198
|
-
/**
|
|
199
|
-
* Like `randomSequence`, but automatically uses the base64 sequence as the seed string.
|
|
200
|
-
*/
|
|
201
|
-
export declare function randomSequence64(length: number): string;
|
|
202
|
-
/**
|
|
203
|
-
* It maps a string character by character using `callback`.
|
|
204
|
-
*/
|
|
205
|
-
export declare function map<T>(callback: (c: string) => T, value: string): T[];
|
|
206
|
-
/**
|
|
207
|
-
* If present, it removes all the occurrences of `toremove` from `value`.
|
|
208
|
-
*/
|
|
209
|
-
export declare function remove(value: string, toremove: string): string;
|
|
210
|
-
/**
|
|
211
|
-
* If present, it removes the `toremove` text from the end of `value`.
|
|
212
|
-
*/
|
|
213
|
-
export declare function removeAfter(value: string, toremove: string): string;
|
|
214
|
-
/**
|
|
215
|
-
* Removes a slice from `index` to `index + length` from `value`.
|
|
216
|
-
*/
|
|
217
|
-
export declare function removeAt(value: string, index: number, length: number): string;
|
|
218
|
-
/**
|
|
219
|
-
* If present, it removes the `toremove` text from the beginning of `value`.
|
|
220
|
-
*/
|
|
221
|
-
export declare function removeBefore(value: string, toremove: string): string;
|
|
222
|
-
/**
|
|
223
|
-
* If present, it removes the first occurrence of `toremove` from `value`.
|
|
224
|
-
*/
|
|
225
|
-
export declare function removeOne(value: string, toremove: string): string;
|
|
226
|
-
/**
|
|
227
|
-
* `repeat` builds a new string by repeating the argument `s`, n `times`.
|
|
228
|
-
* ```ts
|
|
229
|
-
* repeat('Xy', 3) // generates 'XyXyXy'
|
|
230
|
-
* ```
|
|
231
|
-
*/
|
|
232
|
-
export declare function repeat(s: string, times: number): string;
|
|
233
|
-
/**
|
|
234
|
-
* Returns a new string whose characters are in reverse order.
|
|
235
|
-
*/
|
|
236
|
-
export declare function reverse(s: string): string;
|
|
237
|
-
/**
|
|
238
|
-
* Converts a string in a quoted string.
|
|
239
|
-
*/
|
|
240
|
-
export declare function quote(s: string): string;
|
|
241
|
-
/**
|
|
242
|
-
* It only splits on the first occurrance of separator.
|
|
243
|
-
*/
|
|
244
|
-
export declare function splitOnce(s: string, separator: string): [string] | [string, string];
|
|
245
|
-
/**
|
|
246
|
-
* Returns `true` if `s` starts with any of the values in `values`.
|
|
247
|
-
*/
|
|
248
|
-
export declare function startsWithAny(s: string, values: string[]): boolean;
|
|
249
|
-
/**
|
|
250
|
-
* `stripTags` removes any HTML/XML markup from the string leaving only the concatenation
|
|
251
|
-
* of the existing text nodes.
|
|
252
|
-
*/
|
|
253
|
-
export declare function stripTags(s: string): string;
|
|
254
|
-
/**
|
|
255
|
-
* Surrounds a string with the contents of `left` and `right`. If `right` is omitted,
|
|
256
|
-
* `left` will be used on both sides
|
|
257
|
-
*/
|
|
258
|
-
export declare function surround(s: string, left: string, right?: string): string;
|
|
259
|
-
/**
|
|
260
|
-
* It transforms a string into an `Array` of characters.
|
|
261
|
-
*/
|
|
262
|
-
export declare function toArray(s: string): string[];
|
|
263
|
-
/**
|
|
264
|
-
* It transforms a string into an `Array` of char codes in integer format.
|
|
265
|
-
*/
|
|
266
|
-
export declare function toCharcodes(s: string): number[];
|
|
267
|
-
/**
|
|
268
|
-
* Returns an array of `string` whose elements are equally long (using `len`). If the string `s`
|
|
269
|
-
* is not exactly divisible by `len` the last element of the array will be shorter.
|
|
270
|
-
*/
|
|
271
|
-
export declare function toChunks(s: string, len: number): string[];
|
|
272
|
-
/**
|
|
273
|
-
* Returns an array of `string` split by line breaks.
|
|
274
|
-
*/
|
|
275
|
-
export declare function toLines(s: string): string[];
|
|
276
|
-
/**
|
|
277
|
-
* `trimChars` removes from the beginning and the end of the string any character that is present in `charlist`.
|
|
278
|
-
*/
|
|
279
|
-
export declare function trimChars(value: string, charlist: string): string;
|
|
280
|
-
/**
|
|
281
|
-
* `trimCharsLeft` removes from the beginning of the string any character that is present in `charlist`.
|
|
282
|
-
*/
|
|
283
|
-
export declare function trimCharsLeft(value: string, charlist: string): string;
|
|
284
|
-
/**
|
|
285
|
-
* `trimCharsRight` removes from the end of the string any character that is present in `charlist`.
|
|
286
|
-
*/
|
|
287
|
-
export declare function trimCharsRight(value: string, charlist: string): string;
|
|
288
|
-
/**
|
|
289
|
-
* `underscore` finds UpperCase characters and turns them into LowerCase and prepends them with a whtiespace.
|
|
290
|
-
* Sequences of more than one UpperCase character are left untouched.
|
|
291
|
-
*/
|
|
292
|
-
export declare function underscore(s: string): string;
|
|
293
|
-
/**
|
|
294
|
-
* Convert first letter in `value` to upper case.
|
|
295
|
-
*/
|
|
296
|
-
export declare function upperCaseFirst(value: string): string;
|
|
297
|
-
/**
|
|
298
|
-
* `upTo` searches for the first occurrance of `searchFor` and returns the text up to that point.
|
|
299
|
-
* If `searchFor` is not found, the entire string is returned.
|
|
300
|
-
*/
|
|
301
|
-
export declare function upTo(value: string, searchFor: string): string;
|
|
302
|
-
/**
|
|
303
|
-
* `wrapColumns` splits a long string into lines that are at most `columns` long.
|
|
304
|
-
* Words whose length exceeds `columns` are not split.
|
|
305
|
-
*/
|
|
306
|
-
export declare function wrapColumns(s: string, columns?: number, indent?: string, newline?: string): string;
|
|
307
|
-
export declare function isSpaceAt(s: string, pos: number): boolean;
|
|
308
|
-
export declare function encodeBase64(s: string): string;
|
|
309
|
-
export declare function decodeBase64(s: string): string;
|
|
310
|
-
export declare function wrapLine(s: string, columns: number, indent: string, newline: string): string;
|
|
311
|
-
export declare function lpad(s: string, char: string, length: number): string;
|
|
312
|
-
export declare function rpad(s: string, char: string, length: number): string;
|
|
313
|
-
export declare function splitOnLast(s: string, find: string): [string] | [string, string];
|
|
314
|
-
export declare function splitOnFirst(s: string, find: string): [string] | [string, string];
|