@splendidlabz/utils 1.12.0 → 1.13.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.
Files changed (62) hide show
  1. package/dist/cjs/dom/font-size.cjs +1 -1
  2. package/dist/cjs/dom/index.cjs +1 -1
  3. package/dist/cjs/lib/colors.cjs +39 -0
  4. package/dist/cjs/lib/date/index.cjs +1 -1
  5. package/dist/cjs/lib/date/time.cjs +1 -1
  6. package/dist/cjs/lib/http/index.cjs +100 -0
  7. package/dist/cjs/lib/http/status-text.cjs +98 -0
  8. package/dist/cjs/lib/index.cjs +584 -11
  9. package/dist/cjs/lib/numbers/index.cjs +12 -1
  10. package/dist/cjs/lib/numbers/random.cjs +35 -0
  11. package/dist/cjs/lib/numbers/split-unit.cjs +35 -0
  12. package/dist/cjs/lib/promises/index.cjs +72 -15
  13. package/dist/cjs/lib/promises/reject.cjs +72 -13
  14. package/dist/cjs/lib/strings/index.cjs +368 -6
  15. package/dist/cjs/lib/strings/pluralize.cjs +372 -14
  16. package/dist/cjs/lib/strings/query-string.cjs +0 -6
  17. package/dist/cjs/lib/style/index.cjs +35 -1
  18. package/dist/cjs/lib/style/scatter.cjs +60 -0
  19. package/dist/cjs/lib/style/to-style-string.cjs +64 -0
  20. package/dist/cjs/lib/svg/displace.cjs +94 -0
  21. package/dist/cjs/lib/svg/index.cjs +126 -0
  22. package/dist/cjs/lib/svg/noise.cjs +56 -0
  23. package/dist/esm/lib/colors.js +14 -0
  24. package/dist/esm/lib/http/index.js +1 -0
  25. package/dist/esm/lib/http/status-text.js +72 -0
  26. package/dist/esm/lib/index.js +3 -0
  27. package/dist/esm/lib/numbers/index.js +2 -10
  28. package/dist/esm/lib/numbers/random.js +10 -0
  29. package/dist/esm/lib/numbers/split-unit.js +10 -0
  30. package/dist/esm/lib/promises/reject.js +2 -2
  31. package/dist/esm/lib/strings/pluralize.js +366 -3
  32. package/dist/esm/lib/strings/query-string.js +0 -5
  33. package/dist/esm/lib/style/index.js +2 -12
  34. package/dist/esm/lib/style/scatter.js +25 -0
  35. package/dist/esm/lib/style/to-style-string.js +12 -0
  36. package/dist/esm/lib/svg/displace.js +68 -0
  37. package/dist/esm/lib/svg/index.js +2 -0
  38. package/dist/esm/lib/svg/noise.js +16 -0
  39. package/dist/types/dom/font-size.d.cts +1 -1
  40. package/dist/types/lib/colors.d.cts +12 -0
  41. package/dist/types/lib/http/index.d.cts +1 -0
  42. package/dist/types/lib/http/status-text.d.cts +73 -0
  43. package/dist/types/lib/index.d.cts +11 -5
  44. package/dist/types/lib/numbers/index.d.cts +2 -4
  45. package/dist/types/lib/numbers/random.d.cts +14 -0
  46. package/dist/types/lib/numbers/split-unit.d.cts +8 -0
  47. package/dist/types/lib/strings/index.d.cts +2 -2
  48. package/dist/types/lib/strings/pluralize.d.cts +24 -2
  49. package/dist/types/lib/strings/query-string.d.cts +1 -2
  50. package/dist/types/lib/style/index.d.cts +2 -3
  51. package/dist/types/lib/style/scatter.d.cts +48 -0
  52. package/dist/types/lib/style/to-style-string.d.cts +8 -0
  53. package/dist/types/lib/svg/displace.d.cts +54 -0
  54. package/dist/types/lib/svg/index.d.cts +2 -0
  55. package/dist/types/lib/svg/noise.d.cts +24 -0
  56. package/dist/types/node/dirname.d.cts +2 -2
  57. package/dist/types/node/file.d.cts +1 -1
  58. package/dist/types/node/hash.d.cts +1 -1
  59. package/dist/types/node/pkce.d.cts +4 -4
  60. package/dist/types/node/random-string.d.cts +1 -1
  61. package/dist/types/node/uuid.d.cts +1 -1
  62. package/package.json +3 -6
@@ -1,5 +1,368 @@
1
- import pluralizeLib from "pluralize";
2
- const pluralize = pluralizeLib;
1
+ function sanitizeRule(rule) {
2
+ if (typeof rule === "string") return new RegExp("^" + rule + "$", "i");
3
+ return rule;
4
+ }
5
+ function restoreCase(word, token) {
6
+ if (word === token) return token;
7
+ if (word === word.toLowerCase()) return token.toLowerCase();
8
+ if (word === word.toUpperCase()) return token.toUpperCase();
9
+ if (word[0] === word[0].toUpperCase()) {
10
+ return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();
11
+ }
12
+ return token.toLowerCase();
13
+ }
14
+ function interpolate(str, args) {
15
+ return str.replace(/\$(\d{1,2})/g, (match, index) => args[index] || "");
16
+ }
17
+ function replace(word, rule) {
18
+ return word.replace(rule[0], function(match, index) {
19
+ const result = interpolate(rule[1], arguments);
20
+ if (match === "") return restoreCase(word[index - 1], result);
21
+ return restoreCase(match, result);
22
+ });
23
+ }
24
+ function sanitizeWord(token, word, rules, uncountables) {
25
+ if (!token.length || uncountables.hasOwnProperty(token)) return word;
26
+ let len = rules.length;
27
+ while (len--) {
28
+ const rule = rules[len];
29
+ if (rule[0].test(word)) return replace(word, rule);
30
+ }
31
+ return word;
32
+ }
33
+ function replaceWord(replaceMap, keepMap, rules, uncountables) {
34
+ return function(word) {
35
+ const token = word.toLowerCase();
36
+ if (keepMap.hasOwnProperty(token)) return restoreCase(word, token);
37
+ if (replaceMap.hasOwnProperty(token)) {
38
+ return restoreCase(word, replaceMap[token]);
39
+ }
40
+ return sanitizeWord(token, word, rules, uncountables);
41
+ };
42
+ }
43
+ function checkWord(replaceMap, keepMap, rules, uncountables) {
44
+ return function(word) {
45
+ const token = word.toLowerCase();
46
+ if (keepMap.hasOwnProperty(token)) return true;
47
+ if (replaceMap.hasOwnProperty(token)) return false;
48
+ return sanitizeWord(token, token, rules, uncountables) === token;
49
+ };
50
+ }
51
+ const BASE_IRREGULAR = [
52
+ // Pronouns.
53
+ ["I", "we"],
54
+ ["me", "us"],
55
+ ["he", "they"],
56
+ ["she", "they"],
57
+ ["them", "them"],
58
+ ["myself", "ourselves"],
59
+ ["yourself", "yourselves"],
60
+ ["itself", "themselves"],
61
+ ["herself", "themselves"],
62
+ ["himself", "themselves"],
63
+ ["themself", "themselves"],
64
+ ["is", "are"],
65
+ ["was", "were"],
66
+ ["has", "have"],
67
+ ["this", "these"],
68
+ ["that", "those"],
69
+ // Words ending with a consonant and `o`.
70
+ ["echo", "echoes"],
71
+ ["dingo", "dingoes"],
72
+ ["volcano", "volcanoes"],
73
+ ["tornado", "tornadoes"],
74
+ ["torpedo", "torpedoes"],
75
+ // Ends with `us`.
76
+ ["genus", "genera"],
77
+ ["viscus", "viscera"],
78
+ // Ends with `ma`.
79
+ ["stigma", "stigmata"],
80
+ ["stoma", "stomata"],
81
+ ["dogma", "dogmata"],
82
+ ["lemma", "lemmata"],
83
+ ["schema", "schemata"],
84
+ ["anathema", "anathemata"],
85
+ // Other irregular rules.
86
+ ["ox", "oxen"],
87
+ ["axe", "axes"],
88
+ ["die", "dice"],
89
+ ["yes", "yeses"],
90
+ ["foot", "feet"],
91
+ ["eave", "eaves"],
92
+ ["goose", "geese"],
93
+ ["tooth", "teeth"],
94
+ ["quiz", "quizzes"],
95
+ ["human", "humans"],
96
+ ["proof", "proofs"],
97
+ ["carve", "carves"],
98
+ ["valve", "valves"],
99
+ ["looey", "looies"],
100
+ ["thief", "thieves"],
101
+ ["groove", "grooves"],
102
+ ["pickaxe", "pickaxes"],
103
+ ["passerby", "passersby"]
104
+ ];
105
+ const BASE_PLURAL = [
106
+ [/s?$/i, "s"],
107
+ // eslint-disable-next-line no-control-regex
108
+ [/[^\u0000-\u007F]$/i, "$0"],
109
+ [/([^aeiou]ese)$/i, "$1"],
110
+ [/(ax|test)is$/i, "$1es"],
111
+ [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, "$1es"],
112
+ [/(e[mn]u)s?$/i, "$1s"],
113
+ [/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, "$1"],
114
+ [
115
+ /(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,
116
+ "$1i"
117
+ ],
118
+ [/(alumn|alg|vertebr)(?:a|ae)$/i, "$1ae"],
119
+ [/(seraph|cherub)(?:im)?$/i, "$1im"],
120
+ [/(her|at|gr)o$/i, "$1oes"],
121
+ [
122
+ /(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,
123
+ "$1a"
124
+ ],
125
+ [
126
+ /(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,
127
+ "$1a"
128
+ ],
129
+ [/sis$/i, "ses"],
130
+ [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, "$1$2ves"],
131
+ [/([^aeiouy]|qu)y$/i, "$1ies"],
132
+ [/([^ch][ieo][ln])ey$/i, "$1ies"],
133
+ [/(x|ch|ss|sh|zz)$/i, "$1es"],
134
+ [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, "$1ices"],
135
+ [/\b((?:tit)?m|l)(?:ice|ouse)$/i, "$1ice"],
136
+ [/(pe)(?:rson|ople)$/i, "$1ople"],
137
+ [/(child)(?:ren)?$/i, "$1ren"],
138
+ [/eaux$/i, "$0"],
139
+ [/m[ae]n$/i, "men"],
140
+ ["thou", "you"]
141
+ ];
142
+ const BASE_SINGULAR = [
143
+ [/s$/i, ""],
144
+ [/(ss)$/i, "$1"],
145
+ [/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, "$1fe"],
146
+ [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, "$1f"],
147
+ [/ies$/i, "y"],
148
+ [
149
+ /\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,
150
+ "$1ie"
151
+ ],
152
+ [/\b(mon|smil)ies$/i, "$1ey"],
153
+ [/\b((?:tit)?m|l)ice$/i, "$1ouse"],
154
+ [/(seraph|cherub)im$/i, "$1"],
155
+ [
156
+ /(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,
157
+ "$1"
158
+ ],
159
+ [
160
+ /(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,
161
+ "$1sis"
162
+ ],
163
+ [/(movie|twelve|abuse|e[mn]u)s$/i, "$1"],
164
+ [/(test)(?:is|es)$/i, "$1is"],
165
+ [
166
+ /(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,
167
+ "$1us"
168
+ ],
169
+ [
170
+ /(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,
171
+ "$1um"
172
+ ],
173
+ [
174
+ /(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,
175
+ "$1on"
176
+ ],
177
+ [/(alumn|alg|vertebr)ae$/i, "$1a"],
178
+ [/(cod|mur|sil|vert|ind)ices$/i, "$1ex"],
179
+ [/(matr|append)ices$/i, "$1ix"],
180
+ [/(pe)(rson|ople)$/i, "$1rson"],
181
+ [/(child)ren$/i, "$1"],
182
+ [/(eau)x?$/i, "$1"],
183
+ [/men$/i, "man"]
184
+ ];
185
+ const BASE_UNCOUNTABLE = [
186
+ // Singular words with no plurals.
187
+ "adulthood",
188
+ "advice",
189
+ "agenda",
190
+ "aid",
191
+ "aircraft",
192
+ "alcohol",
193
+ "ammo",
194
+ "analytics",
195
+ "anime",
196
+ "athletics",
197
+ "audio",
198
+ "bison",
199
+ "blood",
200
+ "bream",
201
+ "buffalo",
202
+ "butter",
203
+ "carp",
204
+ "cash",
205
+ "chassis",
206
+ "chess",
207
+ "clothing",
208
+ "cod",
209
+ "commerce",
210
+ "cooperation",
211
+ "corps",
212
+ "debris",
213
+ "diabetes",
214
+ "digestion",
215
+ "elk",
216
+ "energy",
217
+ "equipment",
218
+ "excretion",
219
+ "expertise",
220
+ "firmware",
221
+ "flounder",
222
+ "fun",
223
+ "gallows",
224
+ "garbage",
225
+ "graffiti",
226
+ "hardware",
227
+ "headquarters",
228
+ "health",
229
+ "herpes",
230
+ "highjinks",
231
+ "homework",
232
+ "housework",
233
+ "information",
234
+ "jeans",
235
+ "justice",
236
+ "kudos",
237
+ "labour",
238
+ "literature",
239
+ "machinery",
240
+ "mackerel",
241
+ "mail",
242
+ "media",
243
+ "mews",
244
+ "moose",
245
+ "music",
246
+ "mud",
247
+ "manga",
248
+ "news",
249
+ "only",
250
+ "personnel",
251
+ "pike",
252
+ "plankton",
253
+ "pliers",
254
+ "police",
255
+ "pollution",
256
+ "premises",
257
+ "rain",
258
+ "research",
259
+ "rice",
260
+ "salmon",
261
+ "scissors",
262
+ "series",
263
+ "sewage",
264
+ "shambles",
265
+ "shrimp",
266
+ "software",
267
+ "species",
268
+ "staff",
269
+ "swine",
270
+ "tennis",
271
+ "traffic",
272
+ "transportation",
273
+ "trout",
274
+ "tuna",
275
+ "wealth",
276
+ "welfare",
277
+ "whiting",
278
+ "wildebeest",
279
+ "wildlife",
280
+ "you",
281
+ /pok[eé]mon$/i,
282
+ // Regexes.
283
+ /[^aeiou]ese$/i,
284
+ // "chinese", "japanese"
285
+ /deer$/i,
286
+ // "deer", "reindeer"
287
+ /fish$/i,
288
+ // "fish", "blowfish", "angelfish"
289
+ /measles$/i,
290
+ /o[iu]s$/i,
291
+ // "carnivorous"
292
+ /pox$/i,
293
+ // "chickpox", "smallpox"
294
+ /sheep$/i
295
+ ];
296
+ function createPluralize(config = {}) {
297
+ const pluralRules = [];
298
+ const singularRules = [];
299
+ const uncountables = {};
300
+ const irregularPlurals = {};
301
+ const irregularSingles = {};
302
+ for (const [single, plur] of [
303
+ ...BASE_IRREGULAR,
304
+ ...config.irregular || []
305
+ ]) {
306
+ irregularSingles[single.toLowerCase()] = plur.toLowerCase();
307
+ irregularPlurals[plur.toLowerCase()] = single.toLowerCase();
308
+ }
309
+ for (const [rule, replacement] of [...BASE_PLURAL, ...config.plural || []]) {
310
+ pluralRules.push([sanitizeRule(rule), replacement]);
311
+ }
312
+ for (const [rule, replacement] of [
313
+ ...BASE_SINGULAR,
314
+ ...config.singular || []
315
+ ]) {
316
+ singularRules.push([sanitizeRule(rule), replacement]);
317
+ }
318
+ for (const word of [...BASE_UNCOUNTABLE, ...config.uncountable || []]) {
319
+ if (typeof word === "string") {
320
+ uncountables[word.toLowerCase()] = true;
321
+ } else {
322
+ pluralRules.push([sanitizeRule(word), "$0"]);
323
+ singularRules.push([sanitizeRule(word), "$0"]);
324
+ }
325
+ }
326
+ const plural2 = replaceWord(
327
+ irregularSingles,
328
+ irregularPlurals,
329
+ pluralRules,
330
+ uncountables
331
+ );
332
+ const singular2 = replaceWord(
333
+ irregularPlurals,
334
+ irregularSingles,
335
+ singularRules,
336
+ uncountables
337
+ );
338
+ const isPlural2 = checkWord(
339
+ irregularSingles,
340
+ irregularPlurals,
341
+ pluralRules,
342
+ uncountables
343
+ );
344
+ const isSingular2 = checkWord(
345
+ irregularPlurals,
346
+ irregularSingles,
347
+ singularRules,
348
+ uncountables
349
+ );
350
+ function pluralize2(word, count, inclusive) {
351
+ const out = count === 1 ? singular2(word) : plural2(word);
352
+ return (inclusive ? count + " " : "") + out;
353
+ }
354
+ return Object.assign(pluralize2, { plural: plural2, singular: singular2, isPlural: isPlural2, isSingular: isSingular2 });
355
+ }
356
+ const pluralize = createPluralize();
357
+ const plural = pluralize.plural;
358
+ const singular = pluralize.singular;
359
+ const isPlural = pluralize.isPlural;
360
+ const isSingular = pluralize.isSingular;
3
361
  export {
4
- pluralize
362
+ createPluralize,
363
+ isPlural,
364
+ isSingular,
365
+ plural,
366
+ pluralize,
367
+ singular
5
368
  };
@@ -29,16 +29,11 @@ function parseQueryString(string = "") {
29
29
  }
30
30
  return result;
31
31
  }
32
- function plural(count, noun, suffix = "s") {
33
- console.warn("plural is deprecated. Use pluralize instead");
34
- return `${count} ${noun}${count !== 1 ? suffix : ""}`;
35
- }
36
32
  function stripNumbers(string) {
37
33
  return string.replace(/\d*/, "");
38
34
  }
39
35
  export {
40
36
  parseQueryString,
41
- plural,
42
37
  stripNumbers,
43
38
  toQueryString
44
39
  };
@@ -1,12 +1,2 @@
1
- import { toKebab } from "../strings/convert-case/convert-case.js";
2
- function toStyleString(style) {
3
- if (!style) return null;
4
- if (typeof style === "string") return style;
5
- return Object.entries(style).map(([k, v]) => {
6
- if (k.startsWith("--")) return `${k}:${v}`;
7
- else return `${toKebab(k)}:${v}`;
8
- }).join("; ").concat(";");
9
- }
10
- export {
11
- toStyleString
12
- };
1
+ export * from "./scatter.js";
2
+ export * from "./to-style-string.js";
@@ -0,0 +1,25 @@
1
+ import { seededRandom } from "../numbers/random.js";
2
+ const round = (n) => {
3
+ const value = Math.round(n * 100) / 100;
4
+ return value === 0 ? 0 : value;
5
+ };
6
+ function scatter(count, options = {}) {
7
+ const { seed = 1, spread = 20, rotation = 6, amount = 1 } = options;
8
+ const random = seededRandom(seed);
9
+ const items = [];
10
+ for (let i = 0; i < count; i++) {
11
+ const x = round((random() - 0.5) * 2 * spread * amount);
12
+ const y = round((random() - 0.5) * 2 * spread * amount);
13
+ const r = round((random() - 0.5) * 2 * rotation * amount);
14
+ items.push({
15
+ x,
16
+ y,
17
+ rotation: r,
18
+ transform: `translate(${x}%, ${y}%) rotate(${r}deg)`
19
+ });
20
+ }
21
+ return items;
22
+ }
23
+ export {
24
+ scatter
25
+ };
@@ -0,0 +1,12 @@
1
+ import { toKebab } from "../strings/convert-case/convert-case.js";
2
+ function toStyleString(style) {
3
+ if (!style) return null;
4
+ if (typeof style === "string") return style;
5
+ return Object.entries(style).map(([k, v]) => {
6
+ if (k.startsWith("--")) return `${k}:${v}`;
7
+ else return `${toKebab(k)}:${v}`;
8
+ }).join("; ").concat(";");
9
+ }
10
+ export {
11
+ toStyleString
12
+ };
@@ -0,0 +1,68 @@
1
+ const displacePresets = {
2
+ // Ink bleeding into absorbent paper. Long wavelength, small push.
3
+ "wet-ink": {
4
+ type: "fractalNoise",
5
+ frequency: 0.015,
6
+ octaves: 3,
7
+ scale: 9,
8
+ seed: 2
9
+ },
10
+ // Ink bitten into paper tooth. The edge roughens without the letterform
11
+ // moving, so this is the only preset that survives at body sizes.
12
+ letterpress: {
13
+ type: "fractalNoise",
14
+ frequency: 0.09,
15
+ octaves: 1,
16
+ scale: 2,
17
+ seed: 5
18
+ },
19
+ // Air over heat. Anisotropic so the shimmer rises instead of swimming.
20
+ // Reads as nothing unless animated.
21
+ "heat-haze": {
22
+ type: "fractalNoise",
23
+ frequency: [4e-3, 0.02],
24
+ animateTo: [6e-3, 0.03],
25
+ duration: 8,
26
+ octaves: 2,
27
+ scale: 7,
28
+ seed: 11
29
+ },
30
+ // Tracking error on worn tape. A near-infinite horizontal wavelength against
31
+ // a very short vertical one is what tears rather than blobs.
32
+ "bad-tape": {
33
+ type: "turbulence",
34
+ frequency: [8e-4, 0.06],
35
+ animateTo: [8e-4, 0.09],
36
+ duration: 2.5,
37
+ octaves: 1,
38
+ scale: 14,
39
+ seed: 3
40
+ },
41
+ // Past the shred threshold on purpose.
42
+ shred: {
43
+ type: "turbulence",
44
+ frequency: 0.055,
45
+ octaves: 2,
46
+ scale: 32,
47
+ seed: 7
48
+ }
49
+ };
50
+ const format = (f) => Array.isArray(f) ? f.join(" ") : String(f);
51
+ function displaceSettings(opts = {}) {
52
+ const base = opts.preset && displacePresets[opts.preset] || displacePresets["wet-ink"];
53
+ const frequency = opts.frequency ?? base.frequency;
54
+ const animateTo = opts.animateTo ?? base.animateTo;
55
+ return {
56
+ type: opts.type ?? base.type,
57
+ frequency: format(frequency),
58
+ animateTo: animateTo ? format(animateTo) : null,
59
+ duration: opts.duration ?? base.duration ?? 6,
60
+ octaves: opts.octaves ?? base.octaves,
61
+ scale: opts.scale ?? base.scale,
62
+ seed: opts.seed ?? base.seed
63
+ };
64
+ }
65
+ export {
66
+ displacePresets,
67
+ displaceSettings
68
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./displace.js";
2
+ export * from "./noise.js";
@@ -0,0 +1,16 @@
1
+ import { hexToRgb } from "../colors.js";
2
+ const noisePresets = {
3
+ black: "#000000",
4
+ sepia: "#a67c52",
5
+ synthwave: "#ff2bd6"
6
+ };
7
+ function noiseColorMatrix(color, strength) {
8
+ if (!color || color === "rainbow")
9
+ return `1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 ${strength} 0`;
10
+ const { r, g, b } = hexToRgb(noisePresets[color] ?? color);
11
+ return `0 0 0 0 ${r} 0 0 0 0 ${g} 0 0 0 0 ${b} 0 0 0 ${strength} 0`;
12
+ }
13
+ export {
14
+ noiseColorMatrix,
15
+ noisePresets
16
+ };
@@ -1,4 +1,4 @@
1
- declare function getUnit(value: any): any;
1
+ declare function getUnit(value: any): string;
2
2
  declare function rem(multiple?: number): number;
3
3
  declare function em(element?: HTMLElement, multiple?: number): number;
4
4
  declare function rlh(multiple?: number): number;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Parse #rgb or #rrggbb into 0–1 channels (3dp, keeps the data URI short).
3
+ * @param {string} hex
4
+ * @returns {{r: number, g: number, b: number}}
5
+ */
6
+ declare function hexToRgb(hex: string): {
7
+ r: number;
8
+ g: number;
9
+ b: number;
10
+ };
11
+
12
+ export { hexToRgb };
@@ -0,0 +1 @@
1
+ export { statusText, statusTexts } from './status-text.cjs';
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Reason phrase for an HTTP status code.
3
+ * @param {number} code - HTTP status code.
4
+ * @returns {string|undefined} The reason phrase, or undefined if unknown.
5
+ */
6
+ declare function statusText(code: number): string | undefined;
7
+ declare const statusTexts: {
8
+ 100: string;
9
+ 101: string;
10
+ 102: string;
11
+ 103: string;
12
+ 200: string;
13
+ 201: string;
14
+ 202: string;
15
+ 203: string;
16
+ 204: string;
17
+ 205: string;
18
+ 206: string;
19
+ 207: string;
20
+ 208: string;
21
+ 226: string;
22
+ 300: string;
23
+ 301: string;
24
+ 302: string;
25
+ 303: string;
26
+ 304: string;
27
+ 305: string;
28
+ 307: string;
29
+ 308: string;
30
+ 400: string;
31
+ 401: string;
32
+ 402: string;
33
+ 403: string;
34
+ 404: string;
35
+ 405: string;
36
+ 406: string;
37
+ 407: string;
38
+ 408: string;
39
+ 409: string;
40
+ 410: string;
41
+ 411: string;
42
+ 412: string;
43
+ 413: string;
44
+ 414: string;
45
+ 415: string;
46
+ 416: string;
47
+ 417: string;
48
+ 418: string;
49
+ 421: string;
50
+ 422: string;
51
+ 423: string;
52
+ 424: string;
53
+ 425: string;
54
+ 426: string;
55
+ 428: string;
56
+ 429: string;
57
+ 431: string;
58
+ 451: string;
59
+ 500: string;
60
+ 501: string;
61
+ 502: string;
62
+ 503: string;
63
+ 504: string;
64
+ 505: string;
65
+ 506: string;
66
+ 507: string;
67
+ 508: string;
68
+ 509: string;
69
+ 510: string;
70
+ 511: string;
71
+ };
72
+
73
+ export { statusText, statusTexts };
@@ -6,6 +6,7 @@ export { splitArray } from './arrays/split-array.cjs';
6
6
  export { uniqueArray } from './arrays/unique.cjs';
7
7
  export { AuthManager, RouteManager } from './auth/route-manager.cjs';
8
8
  export { getType, isArray, isFunction, isObject, notObject } from './checks.cjs';
9
+ export { hexToRgb } from './colors.cjs';
9
10
  export { DAYS } from './date/days.cjs';
10
11
  export { MONTHS } from './date/months.cjs';
11
12
  export { getTimeInMs, ms, toDays, toHours, toMinutes, toReadableTime, toSeconds, toWeeks } from './date/time.cjs';
@@ -17,7 +18,10 @@ export { compose, composeAsync, curry, pipe, pipeAsync, times } from './function
17
18
  export { throttle } from './functions/throttle.cjs';
18
19
  export { delay, timeout, wait } from './functions/timeout.cjs';
19
20
  export { isHashedValue } from './hash.cjs';
20
- export { splitUnit } from './numbers/index.cjs';
21
+ export { statusText, statusTexts } from './http/status-text.cjs';
22
+ export { toDegrees, toRadians } from './numbers/math.cjs';
23
+ export { seededRandom } from './numbers/random.cjs';
24
+ export { splitUnit } from './numbers/split-unit.cjs';
21
25
  export { camelCaseKeys } from './objects/camelcase-keys.cjs';
22
26
  export { isEmpty, notEmpty } from './objects/empty.cjs';
23
27
  export { isEqual, notEqual } from './objects/equal.cjs';
@@ -36,8 +40,10 @@ export { createSSE, parseSSE } from './sse.cjs';
36
40
  export { toCamel, toKebab, toLower, toPascal, toSentence, toSlug, toTitle, toUpper } from './strings/convert-case/convert-case.cjs';
37
41
  export { markdown, treatMarkdownWhitespace } from './strings/markdown.cjs';
38
42
  export { parseFullName } from './strings/name.cjs';
39
- export { pluralize } from './strings/pluralize.cjs';
40
- export { parseQueryString, plural, stripNumbers, toQueryString } from './strings/query-string.cjs';
41
- export { toStyleString } from './style/index.cjs';
43
+ export { createPluralize, isPlural, isSingular, plural, pluralize, singular } from './strings/pluralize.cjs';
44
+ export { parseQueryString, stripNumbers, toQueryString } from './strings/query-string.cjs';
45
+ export { ScatterItem, scatter } from './style/scatter.cjs';
46
+ export { toStyleString } from './style/to-style-string.cjs';
47
+ export { DisplacePreset, displacePresets, displaceSettings } from './svg/displace.cjs';
48
+ export { noiseColorMatrix, noisePresets } from './svg/noise.cjs';
42
49
  export { getSymbol, getSymbolValue } from './symbols/symbols.cjs';
43
- export { toDegrees, toRadians } from './numbers/math.cjs';
@@ -1,5 +1,3 @@
1
1
  export { toDegrees, toRadians } from './math.cjs';
2
-
3
- declare function splitUnit(string: any): any[];
4
-
5
- export { splitUnit };
2
+ export { seededRandom } from './random.cjs';
3
+ export { splitUnit } from './split-unit.cjs';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Deterministic pseudo-random generator.
3
+ *
4
+ * Math.random() runs once on the server and again on the client, so anything
5
+ * built from it disagrees between SSR and hydration and jumps on load. Seeding
6
+ * makes both passes produce the same sequence. Change the seed for a different
7
+ * arrangement.
8
+ *
9
+ * @param {number} [seed]
10
+ * @returns {() => number} Generator returning a value in [0, 1)
11
+ */
12
+ declare function seededRandom(seed?: number): () => number;
13
+
14
+ export { seededRandom };