@bytebury/toolkit 1.9.0 → 2.1.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/README.md +11 -2
- package/esm/deps/jsr.io/@std/internal/{1.0.13 → 1.0.14}/build_message.d.ts.map +1 -1
- package/{script/deps/jsr.io/@std/internal/1.0.13 → esm/deps/jsr.io/@std/internal/1.0.14}/diff.d.ts.map +1 -1
- package/{script/deps/jsr.io/@std/internal/1.0.13 → esm/deps/jsr.io/@std/internal/1.0.14}/diff_str.d.ts.map +1 -1
- package/{script/deps/jsr.io/@std/internal/1.0.13 → esm/deps/jsr.io/@std/internal/1.0.14}/format.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/internal/{1.0.13 → 1.0.14}/styles.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/internal/{1.0.13 → 1.0.14}/types.d.ts.map +1 -1
- package/esm/mod.d.ts +1 -0
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +1 -0
- package/esm/src/core.d.ts +151 -26
- package/esm/src/core.d.ts.map +1 -1
- package/esm/src/core.js +226 -30
- package/esm/src/dates.d.ts +14 -0
- package/esm/src/dates.d.ts.map +1 -1
- package/esm/src/dates.js +18 -0
- package/esm/src/numbers.d.ts +63 -0
- package/esm/src/numbers.d.ts.map +1 -1
- package/esm/src/numbers.js +80 -0
- package/esm/src/objects.d.ts +90 -0
- package/esm/src/objects.d.ts.map +1 -0
- package/esm/src/objects.js +129 -0
- package/esm/src/objects_test.d.ts.map +1 -0
- package/esm/src/strings.d.ts +70 -0
- package/esm/src/strings.d.ts.map +1 -1
- package/esm/src/strings.js +93 -0
- package/package.json +30 -1
- package/script/deps/jsr.io/@std/internal/{1.0.13 → 1.0.14}/build_message.d.ts.map +1 -1
- package/{esm/deps/jsr.io/@std/internal/1.0.13 → script/deps/jsr.io/@std/internal/1.0.14}/diff.d.ts.map +1 -1
- package/{esm/deps/jsr.io/@std/internal/1.0.13 → script/deps/jsr.io/@std/internal/1.0.14}/diff_str.d.ts.map +1 -1
- package/{esm/deps/jsr.io/@std/internal/1.0.13 → script/deps/jsr.io/@std/internal/1.0.14}/format.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/internal/{1.0.13 → 1.0.14}/styles.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/internal/{1.0.13 → 1.0.14}/types.d.ts.map +1 -1
- package/script/mod.d.ts +1 -0
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +1 -0
- package/script/src/core.d.ts +151 -26
- package/script/src/core.d.ts.map +1 -1
- package/script/src/core.js +240 -32
- package/script/src/dates.d.ts +14 -0
- package/script/src/dates.d.ts.map +1 -1
- package/script/src/dates.js +20 -0
- package/script/src/numbers.d.ts +63 -0
- package/script/src/numbers.d.ts.map +1 -1
- package/script/src/numbers.js +85 -0
- package/script/src/objects.d.ts +90 -0
- package/script/src/objects.d.ts.map +1 -0
- package/script/src/objects.js +137 -0
- package/script/src/objects_test.d.ts.map +1 -0
- package/script/src/strings.d.ts +70 -0
- package/script/src/strings.d.ts.map +1 -1
- package/script/src/strings.js +99 -0
package/esm/src/dates.js
CHANGED
|
@@ -207,3 +207,21 @@ export function isInFuture(date) {
|
|
|
207
207
|
export function isToday(date) {
|
|
208
208
|
return !isInFuture(date) && !isInPast(date);
|
|
209
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Determines if the date is yesterday.
|
|
212
|
+
*
|
|
213
|
+
* @remarks
|
|
214
|
+
* this is date specific. Time of day is ignored.
|
|
215
|
+
*/
|
|
216
|
+
export function isYesterday(date) {
|
|
217
|
+
return date >= yesterday() && date < today();
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Determines if the date is tomorrow.
|
|
221
|
+
*
|
|
222
|
+
* @remarks
|
|
223
|
+
* this is date specific. Time of day is ignored.
|
|
224
|
+
*/
|
|
225
|
+
export function isTomorrow(date) {
|
|
226
|
+
return date >= tomorrow() && date < addDays(tomorrow(), 1);
|
|
227
|
+
}
|
package/esm/src/numbers.d.ts
CHANGED
|
@@ -139,4 +139,67 @@ export declare function sum(nums: number[]): number;
|
|
|
139
139
|
* ```
|
|
140
140
|
*/
|
|
141
141
|
export declare function average(nums: number[]): number;
|
|
142
|
+
/**
|
|
143
|
+
* Clamps a number between a minimum and maximum value.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```ts
|
|
147
|
+
* clamp(5, 0, 10); // 5
|
|
148
|
+
* clamp(-1, 0, 10); // 0
|
|
149
|
+
* clamp(15, 0, 10); // 10
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
export declare function clamp(num: number, min: number, max: number): number;
|
|
153
|
+
/**
|
|
154
|
+
* Returns the median value from a list of numbers.
|
|
155
|
+
*
|
|
156
|
+
* @remarks
|
|
157
|
+
* If you pass an empty list, this will return `0`.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```ts
|
|
161
|
+
* median([]); // 0
|
|
162
|
+
* median([1, 2, 3]); // 2
|
|
163
|
+
* median([1, 2, 3, 4]); // 2.5
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
export declare function median(nums: number[]): number;
|
|
167
|
+
/**
|
|
168
|
+
* Rounds a number to the given number of decimal places.
|
|
169
|
+
*
|
|
170
|
+
* @remarks
|
|
171
|
+
* This is `null | undefined` safe. If you pass `null | undefined` this will return `0`.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```ts
|
|
175
|
+
* roundTo(1.235, 2); // 1.24
|
|
176
|
+
* roundTo(1.5, 0); // 2
|
|
177
|
+
* roundTo(1234.5, -2); // 1200
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
export declare function roundTo(num: number, decimals: number): number;
|
|
181
|
+
/**
|
|
182
|
+
* Gives a random number in the given range. The first parameter is inclusive
|
|
183
|
+
* and the second one is exclusive. Therefore, it will work with lists out of
|
|
184
|
+
* the box.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```ts
|
|
188
|
+
* random(0, 10); // 0 -> 9
|
|
189
|
+
* random(3, 7); // 3 -> 6
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
export declare function random(start: number, end: number): number;
|
|
193
|
+
/**
|
|
194
|
+
* Returns true if the given value is within the given range (inclusive on both ends).
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```ts
|
|
198
|
+
* inRange(5, 0, 10); // true
|
|
199
|
+
* inRange(0, 0, 10); // true
|
|
200
|
+
* inRange(10, 0, 10); // true
|
|
201
|
+
* inRange(11, 0, 10); // false
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
export declare function inRange(value: number, min: number, max: number): boolean;
|
|
142
205
|
//# sourceMappingURL=numbers.d.ts.map
|
package/esm/src/numbers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numbers.d.ts","sourceRoot":"","sources":["../../src/src/numbers.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE3C;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE1C;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAiB9C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAG1C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAG1C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAG1C;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAG9C"}
|
|
1
|
+
{"version":3,"file":"numbers.d.ts","sourceRoot":"","sources":["../../src/src/numbers.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE3C;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE1C;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAiB9C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAG1C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAG1C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAG1C;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAG9C;AAED;;;;;;;;;GASG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAO7C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG7D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAExE"}
|
package/esm/src/numbers.js
CHANGED
|
@@ -177,3 +177,83 @@ export function average(nums) {
|
|
|
177
177
|
return 0;
|
|
178
178
|
return sum(nums) / nums.length;
|
|
179
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* Clamps a number between a minimum and maximum value.
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```ts
|
|
185
|
+
* clamp(5, 0, 10); // 5
|
|
186
|
+
* clamp(-1, 0, 10); // 0
|
|
187
|
+
* clamp(15, 0, 10); // 10
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
export function clamp(num, min, max) {
|
|
191
|
+
return Math.min(Math.max(num, min), max);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Returns the median value from a list of numbers.
|
|
195
|
+
*
|
|
196
|
+
* @remarks
|
|
197
|
+
* If you pass an empty list, this will return `0`.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```ts
|
|
201
|
+
* median([]); // 0
|
|
202
|
+
* median([1, 2, 3]); // 2
|
|
203
|
+
* median([1, 2, 3, 4]); // 2.5
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
export function median(nums) {
|
|
207
|
+
if (isEmpty(nums))
|
|
208
|
+
return 0;
|
|
209
|
+
const sorted = [...nums].sort((a, b) => a - b);
|
|
210
|
+
const mid = Math.floor(sorted.length / 2);
|
|
211
|
+
return sorted.length % 2 === 0
|
|
212
|
+
? (sorted[mid - 1] + sorted[mid]) / 2
|
|
213
|
+
: sorted[mid];
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Rounds a number to the given number of decimal places.
|
|
217
|
+
*
|
|
218
|
+
* @remarks
|
|
219
|
+
* This is `null | undefined` safe. If you pass `null | undefined` this will return `0`.
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```ts
|
|
223
|
+
* roundTo(1.235, 2); // 1.24
|
|
224
|
+
* roundTo(1.5, 0); // 2
|
|
225
|
+
* roundTo(1234.5, -2); // 1200
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
export function roundTo(num, decimals) {
|
|
229
|
+
const factor = Math.pow(10, decimals);
|
|
230
|
+
return Math.round((num || 0) * factor) / factor;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Gives a random number in the given range. The first parameter is inclusive
|
|
234
|
+
* and the second one is exclusive. Therefore, it will work with lists out of
|
|
235
|
+
* the box.
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* ```ts
|
|
239
|
+
* random(0, 10); // 0 -> 9
|
|
240
|
+
* random(3, 7); // 3 -> 6
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
export function random(start, end) {
|
|
244
|
+
return Math.floor(Math.random() * (end - start)) + start;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Returns true if the given value is within the given range (inclusive on both ends).
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```ts
|
|
251
|
+
* inRange(5, 0, 10); // true
|
|
252
|
+
* inRange(0, 0, 10); // true
|
|
253
|
+
* inRange(10, 0, 10); // true
|
|
254
|
+
* inRange(11, 0, 10); // false
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
export function inRange(value, min, max) {
|
|
258
|
+
return value >= min && value <= max;
|
|
259
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { None } from "./utility_types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Returns a strongly-typed array of an object's own enumerable keys.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* This is `None` safe. If you pass `null | undefined` then this will return an empty array.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* keys({ a: 1, b: 2 }); // ["a", "b"]
|
|
11
|
+
* keys({}); // []
|
|
12
|
+
* keys(null); // []
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function keys<T extends Record<string, unknown>>(obj: T | None): (keyof T)[];
|
|
16
|
+
/**
|
|
17
|
+
* Returns a strongly-typed array of an object's own enumerable `[key, value]` pairs.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* This is `None` safe. If you pass `null | undefined` then this will return an empty array.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* entries({ a: 1, b: 2 }); // [["a", 1], ["b", 2]]
|
|
25
|
+
* entries({}); // []
|
|
26
|
+
* entries(null); // []
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function entries<T extends Record<string, unknown>>(obj: T | None): [keyof T, T[keyof T]][];
|
|
30
|
+
/**
|
|
31
|
+
* Returns a new object containing only the specified keys. Keys that are not
|
|
32
|
+
* present on the source object are silently ignored.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* This is `None` safe. If you pass `null | undefined` then this will return an empty object.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* pick({ a: 1, b: 2, c: 3 }, ["a", "c"]); // { a: 1, c: 3 }
|
|
40
|
+
* pick({ a: 1, b: 2 }, []); // {}
|
|
41
|
+
* pick(null, ["a"]); // {}
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function pick<T extends Record<string, unknown>, K extends keyof T>(obj: T | None, keys: K[]): Pick<T, K>;
|
|
45
|
+
/**
|
|
46
|
+
* Returns a new object with the specified keys excluded.
|
|
47
|
+
*
|
|
48
|
+
* @remarks
|
|
49
|
+
* This is `None` safe. If you pass `null | undefined` then this will return an empty object.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* omit({ a: 1, b: 2, c: 3 }, ["a"]); // { b: 2, c: 3 }
|
|
54
|
+
* omit({ a: 1, b: 2 }, []); // { a: 1, b: 2 }
|
|
55
|
+
* omit(null, ["a"]); // {}
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T | None, keys: K[]): Omit<T, K>;
|
|
59
|
+
/**
|
|
60
|
+
* Returns a new object with the same keys, where each value is transformed by `fn`.
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* This is `None` safe. If you pass `null | undefined` then this will return an empty object.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* mapValues({ a: 1, b: 2 }, (v) => v * 2); // { a: 2, b: 4 }
|
|
68
|
+
* mapValues({ a: 1, b: 2 }, (v, k) => `${k}=${v}`); // { a: "a=1", b: "b=2" }
|
|
69
|
+
* mapValues(null, (v) => v); // {}
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare function mapValues<T extends Record<string, unknown>, V>(obj: T | None, fn: (value: T[keyof T], key: keyof T) => V): {
|
|
73
|
+
[K in keyof T]: V;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Returns a new object with each key transformed by `fn`. Values are unchanged.
|
|
77
|
+
* If `fn` produces duplicate keys, later entries overwrite earlier ones.
|
|
78
|
+
*
|
|
79
|
+
* @remarks
|
|
80
|
+
* This is `None` safe. If you pass `null | undefined` then this will return an empty object.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* mapKeys({ a: 1, b: 2 }, (k) => k.toUpperCase()); // { A: 1, B: 2 }
|
|
85
|
+
* mapKeys({ first: "Bob", last: "Lee" }, (k) => `user_${k}`); // { user_first: "Bob", user_last: "Lee" }
|
|
86
|
+
* mapKeys(null, (k) => k); // {}
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export declare function mapKeys<T extends Record<string, unknown>>(obj: T | None, fn: (key: keyof T, value: T[keyof T]) => string): Record<string, T[keyof T]>;
|
|
90
|
+
//# sourceMappingURL=objects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../src/src/objects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;;;;;;;;;;;GAYG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpD,GAAG,EAAE,CAAC,GAAG,IAAI,GACZ,CAAC,MAAM,CAAC,CAAC,EAAE,CAGb;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvD,GAAG,EAAE,CAAC,GAAG,IAAI,GACZ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAGzB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,EACvE,GAAG,EAAE,CAAC,GAAG,IAAI,EACb,IAAI,EAAE,CAAC,EAAE,GACR,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAOZ;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,EACvE,GAAG,EAAE,CAAC,GAAG,IAAI,EACb,IAAI,EAAE,CAAC,EAAE,GACR,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAQZ;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,EAC5D,GAAG,EAAE,CAAC,GAAG,IAAI,EACb,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,GACzC;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC;CAAE,CAOvB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvD,GAAG,EAAE,CAAC,GAAG,IAAI,EACb,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,MAAM,GAC9C,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAO5B"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a strongly-typed array of an object's own enumerable keys.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This is `None` safe. If you pass `null | undefined` then this will return an empty array.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* keys({ a: 1, b: 2 }); // ["a", "b"]
|
|
10
|
+
* keys({}); // []
|
|
11
|
+
* keys(null); // []
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export function keys(obj) {
|
|
15
|
+
if (obj == null)
|
|
16
|
+
return [];
|
|
17
|
+
return Object.keys(obj);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Returns a strongly-typed array of an object's own enumerable `[key, value]` pairs.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* This is `None` safe. If you pass `null | undefined` then this will return an empty array.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* entries({ a: 1, b: 2 }); // [["a", 1], ["b", 2]]
|
|
28
|
+
* entries({}); // []
|
|
29
|
+
* entries(null); // []
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export function entries(obj) {
|
|
33
|
+
if (obj == null)
|
|
34
|
+
return [];
|
|
35
|
+
return Object.entries(obj);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Returns a new object containing only the specified keys. Keys that are not
|
|
39
|
+
* present on the source object are silently ignored.
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
42
|
+
* This is `None` safe. If you pass `null | undefined` then this will return an empty object.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* pick({ a: 1, b: 2, c: 3 }, ["a", "c"]); // { a: 1, c: 3 }
|
|
47
|
+
* pick({ a: 1, b: 2 }, []); // {}
|
|
48
|
+
* pick(null, ["a"]); // {}
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export function pick(obj, keys) {
|
|
52
|
+
if (obj == null)
|
|
53
|
+
return {};
|
|
54
|
+
const result = {};
|
|
55
|
+
for (const key of keys) {
|
|
56
|
+
if (key in obj)
|
|
57
|
+
result[key] = obj[key];
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Returns a new object with the specified keys excluded.
|
|
63
|
+
*
|
|
64
|
+
* @remarks
|
|
65
|
+
* This is `None` safe. If you pass `null | undefined` then this will return an empty object.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* omit({ a: 1, b: 2, c: 3 }, ["a"]); // { b: 2, c: 3 }
|
|
70
|
+
* omit({ a: 1, b: 2 }, []); // { a: 1, b: 2 }
|
|
71
|
+
* omit(null, ["a"]); // {}
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export function omit(obj, keys) {
|
|
75
|
+
if (obj == null)
|
|
76
|
+
return {};
|
|
77
|
+
const excluded = new Set(keys);
|
|
78
|
+
const result = {};
|
|
79
|
+
for (const key of Object.keys(obj)) {
|
|
80
|
+
if (!excluded.has(key))
|
|
81
|
+
result[key] = obj[key];
|
|
82
|
+
}
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Returns a new object with the same keys, where each value is transformed by `fn`.
|
|
87
|
+
*
|
|
88
|
+
* @remarks
|
|
89
|
+
* This is `None` safe. If you pass `null | undefined` then this will return an empty object.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* mapValues({ a: 1, b: 2 }, (v) => v * 2); // { a: 2, b: 4 }
|
|
94
|
+
* mapValues({ a: 1, b: 2 }, (v, k) => `${k}=${v}`); // { a: "a=1", b: "b=2" }
|
|
95
|
+
* mapValues(null, (v) => v); // {}
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export function mapValues(obj, fn) {
|
|
99
|
+
if (obj == null)
|
|
100
|
+
return {};
|
|
101
|
+
const result = {};
|
|
102
|
+
for (const key of Object.keys(obj)) {
|
|
103
|
+
result[key] = fn(obj[key], key);
|
|
104
|
+
}
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Returns a new object with each key transformed by `fn`. Values are unchanged.
|
|
109
|
+
* If `fn` produces duplicate keys, later entries overwrite earlier ones.
|
|
110
|
+
*
|
|
111
|
+
* @remarks
|
|
112
|
+
* This is `None` safe. If you pass `null | undefined` then this will return an empty object.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* mapKeys({ a: 1, b: 2 }, (k) => k.toUpperCase()); // { A: 1, B: 2 }
|
|
117
|
+
* mapKeys({ first: "Bob", last: "Lee" }, (k) => `user_${k}`); // { user_first: "Bob", user_last: "Lee" }
|
|
118
|
+
* mapKeys(null, (k) => k); // {}
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export function mapKeys(obj, fn) {
|
|
122
|
+
if (obj == null)
|
|
123
|
+
return {};
|
|
124
|
+
const result = {};
|
|
125
|
+
for (const key of Object.keys(obj)) {
|
|
126
|
+
result[fn(key, obj[key])] = obj[key];
|
|
127
|
+
}
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objects_test.d.ts","sourceRoot":"","sources":["../../src/src/objects_test.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC"}
|
package/esm/src/strings.d.ts
CHANGED
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
17
|
export declare function isWhitespace(text: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Alias for `isWhitespace`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isNoneOrWhitespace(text: string): boolean;
|
|
18
22
|
/**
|
|
19
23
|
* Determines if the given text contains any non-whitespace characters.
|
|
20
24
|
*
|
|
@@ -29,6 +33,10 @@ export declare function isWhitespace(text: string): boolean;
|
|
|
29
33
|
* ```
|
|
30
34
|
*/
|
|
31
35
|
export declare function isNotWhitespace(text: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Alias for `isNotWhitespace`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isNotNoneOrWhitespace(text: string): boolean;
|
|
32
40
|
/**
|
|
33
41
|
* Trims the whitespace from the beginning and the end. This is an
|
|
34
42
|
* alias for `.trim()`. Useful for when you're mapping over lists.
|
|
@@ -163,4 +171,66 @@ export declare function keepAlphanumeric(text: string): string;
|
|
|
163
171
|
* ```
|
|
164
172
|
*/
|
|
165
173
|
export declare function keepNumeric(text: string): string;
|
|
174
|
+
/**
|
|
175
|
+
* Converts the string to `camelCase` by removing punctuation, trimming extra
|
|
176
|
+
* spaces, and lowercasing the first word with subsequent words capitalized.
|
|
177
|
+
*
|
|
178
|
+
* @remarks
|
|
179
|
+
* This is `None` safe. If you pass `null | undefined` then this will return an Empty String.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```ts
|
|
183
|
+
* camel(null); // ""
|
|
184
|
+
* camel("Hello World"); // "helloWorld"
|
|
185
|
+
* camel("user_profile_page"); // "userProfilePage"
|
|
186
|
+
* camel("HELLO-WORLD"); // "helloWorld"
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
export declare function camel(text: string): string;
|
|
190
|
+
/**
|
|
191
|
+
* Converts the string to `PascalCase` by removing punctuation, trimming extra
|
|
192
|
+
* spaces, and capitalizing every word.
|
|
193
|
+
*
|
|
194
|
+
* @remarks
|
|
195
|
+
* This is `None` safe. If you pass `null | undefined` then this will return an Empty String.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```ts
|
|
199
|
+
* pascal(null); // ""
|
|
200
|
+
* pascal("hello world"); // "HelloWorld"
|
|
201
|
+
* pascal("user_profile_page"); // "UserProfilePage"
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
export declare function pascal(text: string): string;
|
|
205
|
+
/**
|
|
206
|
+
* Truncates a string to the given length. If truncation occurs, the suffix is
|
|
207
|
+
* appended and counted toward the total length.
|
|
208
|
+
*
|
|
209
|
+
* @remarks
|
|
210
|
+
* This is `None` safe. If you pass `null | undefined` then this will return an Empty String.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```ts
|
|
214
|
+
* truncate(null, 10); // ""
|
|
215
|
+
* truncate("Hello World", 5); // "He..."
|
|
216
|
+
* truncate("Hello World", 20); // "Hello World"
|
|
217
|
+
* truncate("Hello World", 8, "…"); // "Hello W…"
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
export declare function truncate(text: string, length: number, suffix?: string): string;
|
|
221
|
+
/**
|
|
222
|
+
* Converts a string to a URL-safe slug. Diacritics are stripped, punctuation is
|
|
223
|
+
* removed, and whitespace is replaced with hyphens.
|
|
224
|
+
*
|
|
225
|
+
* @remarks
|
|
226
|
+
* This is `None` safe. If you pass `null | undefined` then this will return an Empty String.
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```ts
|
|
230
|
+
* slugify(null); // ""
|
|
231
|
+
* slugify("Hello World!"); // "hello-world"
|
|
232
|
+
* slugify("Café à la Carte"); // "cafe-a-la-carte"
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
export declare function slugify(text: string): string;
|
|
166
236
|
//# sourceMappingURL=strings.d.ts.map
|
package/esm/src/strings.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/src/strings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM1C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAErD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAErD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAIrD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAErD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD"}
|
|
1
|
+
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/src/strings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE3D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM1C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAErD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAErD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAIrD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAErD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK1C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM3C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAQ,GAAG,MAAM,CAI7E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5C"}
|
package/esm/src/strings.js
CHANGED
|
@@ -17,6 +17,12 @@
|
|
|
17
17
|
export function isWhitespace(text) {
|
|
18
18
|
return trim(text).length === 0;
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Alias for `isWhitespace`.
|
|
22
|
+
*/
|
|
23
|
+
export function isNoneOrWhitespace(text) {
|
|
24
|
+
return isWhitespace(text);
|
|
25
|
+
}
|
|
20
26
|
/**
|
|
21
27
|
* Determines if the given text contains any non-whitespace characters.
|
|
22
28
|
*
|
|
@@ -33,6 +39,12 @@ export function isWhitespace(text) {
|
|
|
33
39
|
export function isNotWhitespace(text) {
|
|
34
40
|
return !isWhitespace(text);
|
|
35
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Alias for `isNotWhitespace`.
|
|
44
|
+
*/
|
|
45
|
+
export function isNotNoneOrWhitespace(text) {
|
|
46
|
+
return isNotWhitespace(text);
|
|
47
|
+
}
|
|
36
48
|
/**
|
|
37
49
|
* Trims the whitespace from the beginning and the end. This is an
|
|
38
50
|
* alias for `.trim()`. Useful for when you're mapping over lists.
|
|
@@ -189,6 +201,87 @@ export function keepAlphanumeric(text) {
|
|
|
189
201
|
export function keepNumeric(text) {
|
|
190
202
|
return (text || "").replace(/[^\d]/g, "");
|
|
191
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Converts the string to `camelCase` by removing punctuation, trimming extra
|
|
206
|
+
* spaces, and lowercasing the first word with subsequent words capitalized.
|
|
207
|
+
*
|
|
208
|
+
* @remarks
|
|
209
|
+
* This is `None` safe. If you pass `null | undefined` then this will return an Empty String.
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```ts
|
|
213
|
+
* camel(null); // ""
|
|
214
|
+
* camel("Hello World"); // "helloWorld"
|
|
215
|
+
* camel("user_profile_page"); // "userProfilePage"
|
|
216
|
+
* camel("HELLO-WORLD"); // "helloWorld"
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
export function camel(text) {
|
|
220
|
+
const parts = kebab(text).split("-").filter(Boolean);
|
|
221
|
+
if (parts.length === 0)
|
|
222
|
+
return "";
|
|
223
|
+
return parts[0] +
|
|
224
|
+
parts.slice(1).map((p) => upper(p[0]) + p.slice(1)).join("");
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Converts the string to `PascalCase` by removing punctuation, trimming extra
|
|
228
|
+
* spaces, and capitalizing every word.
|
|
229
|
+
*
|
|
230
|
+
* @remarks
|
|
231
|
+
* This is `None` safe. If you pass `null | undefined` then this will return an Empty String.
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```ts
|
|
235
|
+
* pascal(null); // ""
|
|
236
|
+
* pascal("hello world"); // "HelloWorld"
|
|
237
|
+
* pascal("user_profile_page"); // "UserProfilePage"
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
export function pascal(text) {
|
|
241
|
+
return kebab(text)
|
|
242
|
+
.split("-")
|
|
243
|
+
.filter(Boolean)
|
|
244
|
+
.map((p) => upper(p[0]) + p.slice(1))
|
|
245
|
+
.join("");
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Truncates a string to the given length. If truncation occurs, the suffix is
|
|
249
|
+
* appended and counted toward the total length.
|
|
250
|
+
*
|
|
251
|
+
* @remarks
|
|
252
|
+
* This is `None` safe. If you pass `null | undefined` then this will return an Empty String.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```ts
|
|
256
|
+
* truncate(null, 10); // ""
|
|
257
|
+
* truncate("Hello World", 5); // "He..."
|
|
258
|
+
* truncate("Hello World", 20); // "Hello World"
|
|
259
|
+
* truncate("Hello World", 8, "…"); // "Hello W…"
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
262
|
+
export function truncate(text, length, suffix = "...") {
|
|
263
|
+
const t = text || "";
|
|
264
|
+
if (t.length <= length)
|
|
265
|
+
return t;
|
|
266
|
+
return t.slice(0, Math.max(0, length - suffix.length)) + suffix;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Converts a string to a URL-safe slug. Diacritics are stripped, punctuation is
|
|
270
|
+
* removed, and whitespace is replaced with hyphens.
|
|
271
|
+
*
|
|
272
|
+
* @remarks
|
|
273
|
+
* This is `None` safe. If you pass `null | undefined` then this will return an Empty String.
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* ```ts
|
|
277
|
+
* slugify(null); // ""
|
|
278
|
+
* slugify("Hello World!"); // "hello-world"
|
|
279
|
+
* slugify("Café à la Carte"); // "cafe-a-la-carte"
|
|
280
|
+
* ```
|
|
281
|
+
*/
|
|
282
|
+
export function slugify(text) {
|
|
283
|
+
return kebab(text);
|
|
284
|
+
}
|
|
192
285
|
function removePunctuation(text) {
|
|
193
286
|
return text
|
|
194
287
|
.normalize("NFKD")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytebury/toolkit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "TypeScript utility library to help energize your projects with useful functions for any size project. Save yourself some time and focus on shipping features.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,12 +13,41 @@
|
|
|
13
13
|
".": {
|
|
14
14
|
"import": "./esm/mod.js",
|
|
15
15
|
"require": "./script/mod.js"
|
|
16
|
+
},
|
|
17
|
+
"./core": {
|
|
18
|
+
"import": "./esm/src/core.js",
|
|
19
|
+
"require": "./script/src/core.js"
|
|
20
|
+
},
|
|
21
|
+
"./dates": {
|
|
22
|
+
"import": "./esm/src/dates.js",
|
|
23
|
+
"require": "./script/src/dates.js"
|
|
24
|
+
},
|
|
25
|
+
"./duration": {
|
|
26
|
+
"import": "./esm/src/duration.js",
|
|
27
|
+
"require": "./script/src/duration.js"
|
|
28
|
+
},
|
|
29
|
+
"./numbers": {
|
|
30
|
+
"import": "./esm/src/numbers.js",
|
|
31
|
+
"require": "./script/src/numbers.js"
|
|
32
|
+
},
|
|
33
|
+
"./objects": {
|
|
34
|
+
"import": "./esm/src/objects.js",
|
|
35
|
+
"require": "./script/src/objects.js"
|
|
36
|
+
},
|
|
37
|
+
"./strings": {
|
|
38
|
+
"import": "./esm/src/strings.js",
|
|
39
|
+
"require": "./script/src/strings.js"
|
|
40
|
+
},
|
|
41
|
+
"./utility-types": {
|
|
42
|
+
"import": "./esm/src/utility_types.js",
|
|
43
|
+
"require": "./script/src/utility_types.js"
|
|
16
44
|
}
|
|
17
45
|
},
|
|
18
46
|
"scripts": {
|
|
19
47
|
"test": "node test_runner.js"
|
|
20
48
|
},
|
|
21
49
|
"private": false,
|
|
50
|
+
"sideEffects": false,
|
|
22
51
|
"devDependencies": {
|
|
23
52
|
"@types/node": "^20.9.0",
|
|
24
53
|
"picocolors": "^1.0.0",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_message.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.
|
|
1
|
+
{"version":3,"file":"build_message.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.14/build_message.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEvD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,QAAQ;AAClB;;;GAGG;AACH,UAAU,UAAQ,GACjB,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAWvB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CASrD;AAED,4CAA4C;AAC5C,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAC7C,OAAO,GAAE,mBAAwB,EACjC,YAAY,CAAC,EAAE,CACb,UAAU,EAAE,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAC7C,UAAU,EAAE,OAAO,EACnB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,KAC1B,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,GACrC,MAAM,EAAE,CA8BV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.14/diff.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEvD,2DAA2D;AAC3D,MAAM,WAAW,aAAa;IAC5B,qCAAqC;IACrC,CAAC,EAAE,MAAM,CAAC;IACV,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAC;CACZ;AAMD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAanD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,aAAa,CAWvE;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,SAAS,CAAC,CAAC,EACzB,CAAC,EAAE,CAAC,EAAE,EACN,CAAC,EAAE,CAAC,EAAE,EACN,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,WAAW,EACnB,kBAAkB,EAAE,MAAM,GACzB,KAAK,CAAC;IACP,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,CAAC,CAAC;CACV,CAAC,CAiCD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,QAAQ,CACtB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,MAAM,EAAE,WAAW,EACnB,kBAAkB,EAAE,MAAM,EAC1B,GAAG,EAAE,MAAM,EACX,KAAK,CAAC,EAAE,aAAa,EACrB,IAAI,CAAC,EAAE,aAAa,GACnB,aAAa,CAsBf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,CAwEvD"}
|