@oscarpalmer/atoms 0.38.0 → 0.39.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/dist/js/index.js CHANGED
@@ -363,6 +363,12 @@ function getPosition(event) {
363
363
  return typeof x === "number" && typeof y === "number" ? { x, y } : undefined;
364
364
  }
365
365
  // src/js/string.ts
366
+ function capitalise(value) {
367
+ if (value.length === 0) {
368
+ return value;
369
+ }
370
+ return value.length === 1 ? value.toLocaleUpperCase() : value.charAt(0).toLocaleUpperCase() + value.slice(1).toLocaleLowerCase();
371
+ }
366
372
  function createUuid() {
367
373
  return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (substring) => (substring ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> substring / 4).toString(16));
368
374
  }
@@ -377,11 +383,21 @@ function getString(value) {
377
383
  const asString = valueOff?.toString?.() ?? String(valueOff);
378
384
  return asString.startsWith("[object ") ? JSON.stringify(value) : asString;
379
385
  }
386
+ function titleCase(value) {
387
+ return value.split(/\s+/).map((word) => capitalise(word)).join(" ");
388
+ }
380
389
 
381
390
  // src/js/is.ts
382
391
  function isArrayOrPlainObject(value) {
383
392
  return Array.isArray(value) || isPlainObject(value);
384
393
  }
394
+ function isEmpty(value) {
395
+ if (Array.isArray(value)) {
396
+ return value.length === 0 || value.filter((item) => item != null).length === 0;
397
+ }
398
+ const values = Object.values(value);
399
+ return values.length === 0 || values.filter((item) => item != null).length === 0;
400
+ }
385
401
  function isNullable(value) {
386
402
  return value == null;
387
403
  }
@@ -468,6 +484,28 @@ if (globalThis._atomic_queued == null) {
468
484
  }
469
485
  });
470
486
  }
487
+ // src/js/random.ts
488
+ function getRandomBoolean() {
489
+ return Math.random() > 0.5;
490
+ }
491
+ function getRandomColour() {
492
+ return `#${Array.from({ length: 6 }, getRandomHex).join("")}`;
493
+ }
494
+ function getRandomDate(earliest, latest) {
495
+ const earliestTime = earliest?.getTime() ?? -8640000000000000;
496
+ const latestTime = latest?.getTime() ?? 8640000000000000;
497
+ return new Date(getRandomInteger(earliestTime, latestTime));
498
+ }
499
+ function getRandomFloat(min, max) {
500
+ const minimum = min ?? Number.MIN_SAFE_INTEGER;
501
+ return Math.random() * ((max ?? Number.MAX_SAFE_INTEGER) - minimum) + minimum;
502
+ }
503
+ function getRandomInteger(min, max) {
504
+ return Math.floor(getRandomFloat(min, max));
505
+ }
506
+ function getRandomHex() {
507
+ return "0123456789ABCDEF"[getRandomInteger(0, 16)];
508
+ }
471
509
  // src/js/timer.ts
472
510
  function isRepeated(value) {
473
511
  return /^repeat$/.test(value?.$timer ?? "");
@@ -553,8 +591,10 @@ function when(condition, options) {
553
591
  });
554
592
  const instance = Object.create({
555
593
  stop() {
556
- repeated.stop();
557
- rejecter?.();
594
+ if (repeated.active) {
595
+ repeated.stop();
596
+ rejecter?.();
597
+ }
558
598
  },
559
599
  then(resolve, reject) {
560
600
  repeated.start();
@@ -581,8 +621,8 @@ var work = function(type, timer2, state, options) {
581
621
  const isRepeated2 = count > 0;
582
622
  let index = 0;
583
623
  let total = count * (interval > 0 ? interval : 1);
584
- if (total < milliseconds) {
585
- total = milliseconds;
624
+ if (total < 16.66667) {
625
+ total = 16.66667;
586
626
  }
587
627
  let current;
588
628
  let start;
@@ -624,19 +664,6 @@ var work = function(type, timer2, state, options) {
624
664
  state.frame = requestAnimationFrame(step);
625
665
  return timer2;
626
666
  };
627
- var milliseconds = 0;
628
- (() => {
629
- let start;
630
- function fn(time) {
631
- if (start == null) {
632
- start = time;
633
- requestAnimationFrame(fn);
634
- } else {
635
- milliseconds = time - start;
636
- }
637
- }
638
- requestAnimationFrame(fn);
639
- })();
640
667
  // src/js/touch.ts
641
668
  var supportsTouch = (() => {
642
669
  let value = false;
@@ -850,6 +877,7 @@ export {
850
877
  when,
851
878
  wait,
852
879
  unique,
880
+ titleCase,
853
881
  splice,
854
882
  setValue,
855
883
  repeat,
@@ -869,6 +897,7 @@ export {
869
897
  isNullableOrEmpty,
870
898
  isNullable,
871
899
  isFocusableElement,
900
+ isEmpty,
872
901
  isArrayOrPlainObject,
873
902
  insert,
874
903
  indexOf,
@@ -877,6 +906,13 @@ export {
877
906
  getTextDirection,
878
907
  getTabbableElements,
879
908
  getString,
909
+ getRandomInteger,
910
+ getRandomHex,
911
+ getRandomFloat,
912
+ getRandomDate,
913
+ getRandomColour,
914
+ getRandomColour as getRandomColor,
915
+ getRandomBoolean,
880
916
  getPosition,
881
917
  getNumber,
882
918
  getFocusableElements,
@@ -892,6 +928,8 @@ export {
892
928
  clone,
893
929
  clamp,
894
930
  chunk,
931
+ capitalise as capitalize,
932
+ capitalise,
895
933
  between,
896
934
  findElements as $$,
897
935
  findElement as $
package/dist/js/index.mjs CHANGED
@@ -7,6 +7,7 @@ export * from "./is";
7
7
  export * from "./models";
8
8
  export * from "./number";
9
9
  export * from "./queue";
10
+ export * from "./random";
10
11
  export * from "./string";
11
12
  export * from "./timer";
12
13
  export * from "./touch";
package/dist/js/is.js CHANGED
@@ -15,6 +15,13 @@ function getString(value) {
15
15
  function isArrayOrPlainObject(value) {
16
16
  return Array.isArray(value) || isPlainObject(value);
17
17
  }
18
+ function isEmpty(value) {
19
+ if (Array.isArray(value)) {
20
+ return value.length === 0 || value.filter((item) => item != null).length === 0;
21
+ }
22
+ const values = Object.values(value);
23
+ return values.length === 0 || values.filter((item) => item != null).length === 0;
24
+ }
18
25
  function isNullable(value) {
19
26
  return value == null;
20
27
  }
@@ -52,5 +59,6 @@ export {
52
59
  isNullableOrWhitespace,
53
60
  isNullableOrEmpty,
54
61
  isNullable,
62
+ isEmpty,
55
63
  isArrayOrPlainObject
56
64
  };
package/dist/js/is.mjs CHANGED
@@ -3,6 +3,13 @@ import {getString} from "./string";
3
3
  function isArrayOrPlainObject(value) {
4
4
  return Array.isArray(value) || isPlainObject(value);
5
5
  }
6
+ function isEmpty(value) {
7
+ if (Array.isArray(value)) {
8
+ return value.length === 0 || value.filter((item) => item != null).length === 0;
9
+ }
10
+ const values = Object.values(value);
11
+ return values.length === 0 || values.filter((item) => item != null).length === 0;
12
+ }
6
13
  function isNullable(value) {
7
14
  return value == null;
8
15
  }
@@ -40,5 +47,6 @@ export {
40
47
  isNullableOrWhitespace,
41
48
  isNullableOrEmpty,
42
49
  isNullable,
50
+ isEmpty,
43
51
  isArrayOrPlainObject
44
52
  };
@@ -0,0 +1,31 @@
1
+ // src/js/random.ts
2
+ function getRandomBoolean() {
3
+ return Math.random() > 0.5;
4
+ }
5
+ function getRandomColour() {
6
+ return `#${Array.from({ length: 6 }, getRandomHex).join("")}`;
7
+ }
8
+ function getRandomDate(earliest, latest) {
9
+ const earliestTime = earliest?.getTime() ?? -8640000000000000;
10
+ const latestTime = latest?.getTime() ?? 8640000000000000;
11
+ return new Date(getRandomInteger(earliestTime, latestTime));
12
+ }
13
+ function getRandomFloat(min, max) {
14
+ const minimum = min ?? Number.MIN_SAFE_INTEGER;
15
+ return Math.random() * ((max ?? Number.MAX_SAFE_INTEGER) - minimum) + minimum;
16
+ }
17
+ function getRandomInteger(min, max) {
18
+ return Math.floor(getRandomFloat(min, max));
19
+ }
20
+ function getRandomHex() {
21
+ return "0123456789ABCDEF"[getRandomInteger(0, 16)];
22
+ }
23
+ export {
24
+ getRandomInteger,
25
+ getRandomHex,
26
+ getRandomFloat,
27
+ getRandomDate,
28
+ getRandomColour,
29
+ getRandomColour as getRandomColor,
30
+ getRandomBoolean
31
+ };
@@ -0,0 +1,31 @@
1
+ // src/js/random.ts
2
+ function getRandomBoolean() {
3
+ return Math.random() > 0.5;
4
+ }
5
+ function getRandomColour() {
6
+ return `#${Array.from({ length: 6 }, getRandomHex).join("")}`;
7
+ }
8
+ function getRandomDate(earliest, latest) {
9
+ const earliestTime = earliest?.getTime() ?? -8640000000000000;
10
+ const latestTime = latest?.getTime() ?? 8640000000000000;
11
+ return new Date(getRandomInteger(earliestTime, latestTime));
12
+ }
13
+ function getRandomFloat(min, max) {
14
+ const minimum = min ?? Number.MIN_SAFE_INTEGER;
15
+ return Math.random() * ((max ?? Number.MAX_SAFE_INTEGER) - minimum) + minimum;
16
+ }
17
+ function getRandomInteger(min, max) {
18
+ return Math.floor(getRandomFloat(min, max));
19
+ }
20
+ function getRandomHex() {
21
+ return "0123456789ABCDEF"[getRandomInteger(0, 16)];
22
+ }
23
+ export {
24
+ getRandomInteger,
25
+ getRandomHex,
26
+ getRandomFloat,
27
+ getRandomDate,
28
+ getRandomColour,
29
+ getRandomColour as getRandomColor,
30
+ getRandomBoolean
31
+ };
package/dist/js/string.js CHANGED
@@ -1,4 +1,10 @@
1
1
  // src/js/string.ts
2
+ function capitalise(value) {
3
+ if (value.length === 0) {
4
+ return value;
5
+ }
6
+ return value.length === 1 ? value.toLocaleUpperCase() : value.charAt(0).toLocaleUpperCase() + value.slice(1).toLocaleLowerCase();
7
+ }
2
8
  function createUuid() {
3
9
  return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (substring) => (substring ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> substring / 4).toString(16));
4
10
  }
@@ -13,7 +19,13 @@ function getString(value) {
13
19
  const asString = valueOff?.toString?.() ?? String(valueOff);
14
20
  return asString.startsWith("[object ") ? JSON.stringify(value) : asString;
15
21
  }
22
+ function titleCase(value) {
23
+ return value.split(/\s+/).map((word) => capitalise(word)).join(" ");
24
+ }
16
25
  export {
26
+ titleCase,
17
27
  getString,
18
- createUuid
28
+ createUuid,
29
+ capitalise as capitalize,
30
+ capitalise
19
31
  };
@@ -1,4 +1,10 @@
1
1
  // src/js/string.ts
2
+ function capitalise(value) {
3
+ if (value.length === 0) {
4
+ return value;
5
+ }
6
+ return value.length === 1 ? value.toLocaleUpperCase() : value.charAt(0).toLocaleUpperCase() + value.slice(1).toLocaleLowerCase();
7
+ }
2
8
  function createUuid() {
3
9
  return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (substring) => (substring ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> substring / 4).toString(16));
4
10
  }
@@ -13,7 +19,13 @@ function getString(value) {
13
19
  const asString = valueOff?.toString?.() ?? String(valueOff);
14
20
  return asString.startsWith("[object ") ? JSON.stringify(value) : asString;
15
21
  }
22
+ function titleCase(value) {
23
+ return value.split(/\s+/).map((word) => capitalise(word)).join(" ");
24
+ }
16
25
  export {
26
+ titleCase,
17
27
  getString,
18
- createUuid
28
+ createUuid,
29
+ capitalise as capitalize,
30
+ capitalise
19
31
  };
package/dist/js/timer.js CHANGED
@@ -83,8 +83,10 @@ function when(condition, options) {
83
83
  });
84
84
  const instance = Object.create({
85
85
  stop() {
86
- repeated.stop();
87
- rejecter?.();
86
+ if (repeated.active) {
87
+ repeated.stop();
88
+ rejecter?.();
89
+ }
88
90
  },
89
91
  then(resolve, reject) {
90
92
  repeated.start();
@@ -111,8 +113,8 @@ var work = function(type, timer2, state, options) {
111
113
  const isRepeated2 = count > 0;
112
114
  let index = 0;
113
115
  let total = count * (interval > 0 ? interval : 1);
114
- if (total < milliseconds) {
115
- total = milliseconds;
116
+ if (total < 16.66667) {
117
+ total = 16.66667;
116
118
  }
117
119
  let current;
118
120
  let start;
@@ -154,19 +156,6 @@ var work = function(type, timer2, state, options) {
154
156
  state.frame = requestAnimationFrame(step);
155
157
  return timer2;
156
158
  };
157
- var milliseconds = 0;
158
- (() => {
159
- let start;
160
- function fn(time) {
161
- if (start == null) {
162
- start = time;
163
- requestAnimationFrame(fn);
164
- } else {
165
- milliseconds = time - start;
166
- }
167
- }
168
- requestAnimationFrame(fn);
169
- })();
170
159
  export {
171
160
  when,
172
161
  wait,
package/dist/js/timer.mjs CHANGED
@@ -83,8 +83,10 @@ function when(condition, options) {
83
83
  });
84
84
  const instance = Object.create({
85
85
  stop() {
86
- repeated.stop();
87
- rejecter?.();
86
+ if (repeated.active) {
87
+ repeated.stop();
88
+ rejecter?.();
89
+ }
88
90
  },
89
91
  then(resolve, reject) {
90
92
  repeated.start();
@@ -111,8 +113,8 @@ var work = function(type, timer2, state, options) {
111
113
  const isRepeated2 = count > 0;
112
114
  let index = 0;
113
115
  let total = count * (interval > 0 ? interval : 1);
114
- if (total < milliseconds) {
115
- total = milliseconds;
116
+ if (total < 16.66667) {
117
+ total = 16.66667;
116
118
  }
117
119
  let current;
118
120
  let start;
@@ -154,19 +156,6 @@ var work = function(type, timer2, state, options) {
154
156
  state.frame = requestAnimationFrame(step);
155
157
  return timer2;
156
158
  };
157
- var milliseconds = 0;
158
- (() => {
159
- let start;
160
- function fn(time) {
161
- if (start == null) {
162
- start = time;
163
- requestAnimationFrame(fn);
164
- } else {
165
- milliseconds = time - start;
166
- }
167
- }
168
- requestAnimationFrame(fn);
169
- })();
170
159
  export {
171
160
  when,
172
161
  wait,
package/package.json CHANGED
@@ -8,10 +8,10 @@
8
8
  },
9
9
  "description": "Sweet little atomic goodies…",
10
10
  "devDependencies": {
11
- "@biomejs/biome": "^1.6",
12
- "@happy-dom/global-registrator": "^14.7",
11
+ "@biomejs/biome": "^1.7",
12
+ "@happy-dom/global-registrator": "^14.11",
13
13
  "bun": "^1.1",
14
- "sass": "^1.74",
14
+ "sass": "^1.77",
15
15
  "typescript": "^5.4"
16
16
  },
17
17
  "exports": {
@@ -105,7 +105,11 @@
105
105
  },
106
106
  "./package.json": "./package.json"
107
107
  },
108
- "files": ["dist", "src", "types"],
108
+ "files": [
109
+ "dist",
110
+ "src",
111
+ "types"
112
+ ],
109
113
  "keywords": [],
110
114
  "license": "MIT",
111
115
  "main": "./dist/js/index.js",
@@ -126,5 +130,5 @@
126
130
  },
127
131
  "type": "module",
128
132
  "types": "./types/index.d.ts",
129
- "version": "0.38.0"
133
+ "version": "0.39.0"
130
134
  }
package/src/js/index.ts CHANGED
@@ -6,6 +6,7 @@ export * from './is';
6
6
  export * from './models';
7
7
  export * from './number';
8
8
  export * from './queue';
9
+ export * from './random';
9
10
  export * from './string';
10
11
  export * from './timer';
11
12
  export * from './touch';
package/src/js/is.ts CHANGED
@@ -10,6 +10,20 @@ export function isArrayOrPlainObject(
10
10
  return Array.isArray(value) || isPlainObject(value);
11
11
  }
12
12
 
13
+ export function isEmpty(value: ArrayOrPlainObject): boolean {
14
+ if (Array.isArray(value)) {
15
+ return (
16
+ value.length === 0 || value.filter(item => item != null).length === 0
17
+ );
18
+ }
19
+
20
+ const values = Object.values(value);
21
+
22
+ return (
23
+ values.length === 0 || values.filter(item => item != null).length === 0
24
+ );
25
+ }
26
+
13
27
  /**
14
28
  * Is the value undefined or null?
15
29
  */
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Returns a random boolean
3
+ */
4
+ export function getRandomBoolean(): boolean {
5
+ return Math.random() > 0.5;
6
+ }
7
+
8
+ /**
9
+ * Returns a random hexadecimal colour
10
+ */
11
+ export function getRandomColour(): string {
12
+ return `#${Array.from({length: 6}, getRandomHex).join('')}`;
13
+ }
14
+
15
+ /**
16
+ * Returns a random date
17
+ */
18
+ export function getRandomDate(earliest?: Date, latest?: Date): Date {
19
+ const earliestTime = earliest?.getTime() ?? -8_640_000_000_000_000;
20
+ const latestTime = latest?.getTime() ?? 8_640_000_000_000_000;
21
+
22
+ return new Date(getRandomInteger(earliestTime, latestTime));
23
+ }
24
+
25
+ /**
26
+ * Returns a random floating-point number
27
+ */
28
+ export function getRandomFloat(min?: number, max?: number): number {
29
+ const minimum = min ?? Number.MIN_SAFE_INTEGER;
30
+
31
+ return Math.random() * ((max ?? Number.MAX_SAFE_INTEGER) - minimum) + minimum;
32
+ }
33
+
34
+ /**
35
+ * Returns a random integer
36
+ */
37
+ export function getRandomInteger(min?: number, max?: number): number {
38
+ return Math.floor(getRandomFloat(min, max));
39
+ }
40
+
41
+ /**
42
+ * Returns a random hexadecimal character
43
+ */
44
+ export function getRandomHex(): string {
45
+ return '0123456789ABCDEF'[getRandomInteger(0, 16)];
46
+ }
47
+
48
+ export {getRandomColour as getRandomColor};
package/src/js/string.ts CHANGED
@@ -1,13 +1,26 @@
1
+ /**
2
+ * Capitalise the first letter of a string _(and lowercase the rest)_
3
+ */
4
+ export function capitalise(value: string): string {
5
+ if (value.length === 0) {
6
+ return value;
7
+ }
8
+ return value.length === 1
9
+ ? value.toLocaleUpperCase()
10
+ : value.charAt(0).toLocaleUpperCase() + value.slice(1).toLocaleLowerCase();
11
+ }
12
+
1
13
  /**
2
14
  * Create a new UUID
3
15
  */
4
16
  export function createUuid(): string {
5
17
  return '10000000-1000-4000-8000-100000000000'.replace(
6
18
  /[018]/g,
7
- (substring: any) =>
19
+ (substring: string) =>
8
20
  (
9
- substring ^
10
- (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (substring / 4)))
21
+ (substring as never) ^
22
+ (crypto.getRandomValues(new Uint8Array(1))[0] &
23
+ (15 >> ((substring as never) / 4)))
11
24
  ).toString(16),
12
25
  );
13
26
  }
@@ -29,3 +42,15 @@ export function getString(value: unknown): string {
29
42
 
30
43
  return asString.startsWith('[object ') ? JSON.stringify(value) : asString;
31
44
  }
45
+
46
+ /**
47
+ * Convert a string to title case _(capitalising every word)_
48
+ */
49
+ export function titleCase(value: string): string {
50
+ return value
51
+ .split(/\s+/)
52
+ .map(word => capitalise(word))
53
+ .join(' ');
54
+ }
55
+
56
+ export {capitalise as capitalize};
package/src/js/timer.ts CHANGED
@@ -94,8 +94,6 @@ type WhenOptions = {} & OptionsWithCount;
94
94
 
95
95
  type WorkType = 'restart' | 'start' | 'stop';
96
96
 
97
- let milliseconds = 0;
98
-
99
97
  /**
100
98
  * Is the value a repeating timer?
101
99
  */
@@ -202,13 +200,13 @@ export function wait(callback: () => void): Timer;
202
200
 
203
201
  /**
204
202
  * Creates a timer which calls a callback after a certain amount of time
205
- * - `time` defaults to `0`
206
203
  */
207
204
  export function wait(callback: () => void, time: number): Timer;
208
205
 
209
206
  /**
210
207
  * Creates a timer which calls a callback after a certain amount of time
211
208
  * - `options.interval` defaults to `0`
209
+ * - `options.timeout` defaults to `30_000` _(30 seconds)_
212
210
  */
213
211
  export function wait(
214
212
  callback: () => void,
@@ -264,9 +262,11 @@ export function when(
264
262
 
265
263
  const instance = Object.create({
266
264
  stop() {
267
- repeated.stop();
265
+ if (repeated.active) {
266
+ repeated.stop();
268
267
 
269
- rejecter?.();
268
+ rejecter?.();
269
+ }
270
270
  },
271
271
  // biome-ignore lint/suspicious/noThenProperty: <explanation>
272
272
  then(resolve?: () => void, reject?: () => void) {
@@ -314,8 +314,8 @@ function work(
314
314
  let index = 0;
315
315
  let total = count * (interval > 0 ? interval : 1);
316
316
 
317
- if (total < milliseconds) {
318
- total = milliseconds;
317
+ if (total < 16.66667) {
318
+ total = 16.66667;
319
319
  }
320
320
 
321
321
  let current: DOMHighResTimeStamp | null;
@@ -372,22 +372,3 @@ function work(
372
372
 
373
373
  return timer;
374
374
  }
375
-
376
- /**
377
- * Called immediately to calculate an approximate refresh rate in milliseconds
378
- */
379
- (() => {
380
- let start: number;
381
-
382
- function fn(time: number) {
383
- if (start == null) {
384
- start = time;
385
-
386
- requestAnimationFrame(fn);
387
- } else {
388
- milliseconds = time - start;
389
- }
390
- }
391
-
392
- requestAnimationFrame(fn);
393
- })();
package/types/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export * from './is';
6
6
  export * from './models';
7
7
  export * from './number';
8
8
  export * from './queue';
9
+ export * from './random';
9
10
  export * from './string';
10
11
  export * from './timer';
11
12
  export * from './touch';
package/types/is.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { ArrayOrPlainObject, PlainObject, Primitive } from './models';
3
3
  * Is the value an array or a record?
4
4
  */
5
5
  export declare function isArrayOrPlainObject(value: unknown): value is ArrayOrPlainObject;
6
+ export declare function isEmpty(value: ArrayOrPlainObject): boolean;
6
7
  /**
7
8
  * Is the value undefined or null?
8
9
  */
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Returns a random boolean
3
+ */
4
+ export declare function getRandomBoolean(): boolean;
5
+ /**
6
+ * Returns a random hexadecimal colour
7
+ */
8
+ export declare function getRandomColour(): string;
9
+ /**
10
+ * Returns a random date
11
+ */
12
+ export declare function getRandomDate(earliest?: Date, latest?: Date): Date;
13
+ /**
14
+ * Returns a random floating-point number
15
+ */
16
+ export declare function getRandomFloat(min?: number, max?: number): number;
17
+ /**
18
+ * Returns a random integer
19
+ */
20
+ export declare function getRandomInteger(min?: number, max?: number): number;
21
+ /**
22
+ * Returns a random hexadecimal character
23
+ */
24
+ export declare function getRandomHex(): string;
25
+ export { getRandomColour as getRandomColor };
package/types/string.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Capitalise the first letter of a string _(and lowercase the rest)_
3
+ */
4
+ export declare function capitalise(value: string): string;
1
5
  /**
2
6
  * Create a new UUID
3
7
  */
@@ -6,3 +10,8 @@ export declare function createUuid(): string;
6
10
  * Get the string value from any value
7
11
  */
8
12
  export declare function getString(value: unknown): string;
13
+ /**
14
+ * Convert a string to title case _(capitalising every word)_
15
+ */
16
+ export declare function titleCase(value: string): string;
17
+ export { capitalise as capitalize };
package/types/timer.d.ts CHANGED
@@ -93,12 +93,12 @@ export declare function repeat(callback: IndexedCallback, options?: Partial<Repe
93
93
  export declare function wait(callback: () => void): Timer;
94
94
  /**
95
95
  * Creates a timer which calls a callback after a certain amount of time
96
- * - `time` defaults to `0`
97
96
  */
98
97
  export declare function wait(callback: () => void, time: number): Timer;
99
98
  /**
100
99
  * Creates a timer which calls a callback after a certain amount of time
101
100
  * - `options.interval` defaults to `0`
101
+ * - `options.timeout` defaults to `30_000` _(30 seconds)_
102
102
  */
103
103
  export declare function wait(callback: () => void, options: Partial<WaitOptions>): Timer;
104
104
  /**