@oscarpalmer/atoms 0.218.0 → 0.219.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/array/filter.d.mts +38 -4
- package/dist/array/find.d.mts +34 -0
- package/dist/array/first.d.mts +40 -4
- package/dist/array/last.d.mts +46 -10
- package/dist/array/partition.d.mts +24 -8
- package/dist/array/reverse.d.mts +6 -0
- package/dist/array/reverse.mjs +6 -0
- package/dist/array/select.d.mts +97 -116
- package/dist/array/select.mjs +19 -15
- package/dist/array/single.d.mts +22 -0
- package/dist/array/single.mjs +1 -1
- package/dist/array/sort.d.mts +54 -0
- package/dist/color/space/hex.d.mts +8 -0
- package/dist/color/space/hex.mjs +8 -0
- package/dist/index.d.mts +716 -170
- package/dist/index.mjs +293 -68
- package/dist/internal/array/callbacks.mjs +1 -1
- package/dist/internal/array/find.d.mts +3 -3
- package/dist/internal/array/find.mjs +71 -52
- package/dist/internal/array/shuffle.d.mts +5 -0
- package/dist/internal/array/shuffle.mjs +5 -0
- package/dist/internal/math/aggregate.d.mts +69 -21
- package/dist/internal/math/misc.d.mts +14 -0
- package/dist/internal/math/misc.mjs +14 -0
- package/dist/internal/number.d.mts +18 -0
- package/dist/internal/number.mjs +18 -0
- package/dist/internal/string/case.d.mts +63 -0
- package/dist/internal/string/case.mjs +63 -0
- package/dist/internal/string/misc.d.mts +20 -0
- package/dist/internal/string/misc.mjs +20 -0
- package/dist/logger.d.mts +12 -0
- package/dist/logger.mjs +12 -0
- package/dist/math.d.mts +90 -0
- package/dist/math.mjs +7 -0
- package/dist/models/array/array.find.model.d.mts +26 -0
- package/dist/models/array/array.misc.model.d.mts +2 -4
- package/dist/models/index.d.mts +1 -1
- package/dist/models/value/value.merge.model.d.mts +3 -3
- package/dist/promise/misc.d.mts +6 -0
- package/dist/promise/misc.mjs +6 -0
- package/dist/promise/timed.d.mts +3 -0
- package/dist/promise/timed.mjs +3 -0
- package/dist/queue.d.mts +0 -1
- package/dist/queue.mjs +1 -1
- package/dist/string/index.d.mts +15 -1
- package/dist/string/index.mjs +15 -1
- package/dist/string/match.d.mts +24 -0
- package/dist/string/match.mjs +24 -0
- package/dist/string/template.d.mts +4 -0
- package/package.json +1 -1
package/dist/string/index.mjs
CHANGED
|
@@ -57,7 +57,7 @@ function getUuid(html) {
|
|
|
57
57
|
*
|
|
58
58
|
* @param value JSON string to parse
|
|
59
59
|
* @param reviver Reviver function to transform the parsed values
|
|
60
|
-
* @returns Parsed value or `undefined` if parsing fails
|
|
60
|
+
* @returns Parsed value, or `undefined` if parsing fails
|
|
61
61
|
*/
|
|
62
62
|
function parse(value, reviver) {
|
|
63
63
|
try {
|
|
@@ -71,6 +71,13 @@ function parse(value, reviver) {
|
|
|
71
71
|
*
|
|
72
72
|
* @param value String to trim
|
|
73
73
|
* @returns Trimmed string
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* trim(' this is a test '); // => 'this is a test'
|
|
77
|
+
* trim('this is a test'); // => 'this is a test'
|
|
78
|
+
* trim(' '); // => ''
|
|
79
|
+
* trim(''); // => ''
|
|
80
|
+
* ```
|
|
74
81
|
*/
|
|
75
82
|
function trim(value) {
|
|
76
83
|
return typeof value === "string" ? value.trim() : "";
|
|
@@ -82,6 +89,13 @@ function trim(value) {
|
|
|
82
89
|
* @param length Maximum length of the string after truncation
|
|
83
90
|
* @param suffix Suffix to append to the truncated string
|
|
84
91
|
* @returns Truncated string
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* truncate('this is a test', 7); // => 'this is'
|
|
95
|
+
* truncate('this is a test', 7, '...'); // => 'this ...'
|
|
96
|
+
* truncate('this is a test', 20); // => 'this is a test'
|
|
97
|
+
* truncate('this is a test', 0); // => ''
|
|
98
|
+
* ```
|
|
85
99
|
*/
|
|
86
100
|
function truncate(value, length, suffix) {
|
|
87
101
|
if (typeof value !== "string" || typeof length !== "number" || length === 0) return "";
|
package/dist/string/match.d.mts
CHANGED
|
@@ -6,6 +6,14 @@
|
|
|
6
6
|
* @param needle String to look for
|
|
7
7
|
* @param ignoreCase Ignore case when matching? _(defaults to `false`)_
|
|
8
8
|
* @returns `true` if the string ends with the given substring, otherwise `false`
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* endsWith('this is a test', 'test'); // => true
|
|
13
|
+
* endsWith('this is a test', 'Test'); // => false
|
|
14
|
+
* endsWith('this is a test', 'Test', true); // => true
|
|
15
|
+
* endsWith('this is a test', 'not'); // => false
|
|
16
|
+
* ```
|
|
9
17
|
*/
|
|
10
18
|
export declare function endsWith(haystack: string, needle: string, ignoreCase?: boolean): boolean;
|
|
11
19
|
/**
|
|
@@ -15,6 +23,14 @@ export declare function endsWith(haystack: string, needle: string, ignoreCase?:
|
|
|
15
23
|
* @param needle String to look for
|
|
16
24
|
* @param ignoreCase Ignore case when matching? _(defaults to `false`)_
|
|
17
25
|
* @returns `true` if the string includes the given substring, otherwise `false`
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* includes('this is a test', 'is'); // => true
|
|
30
|
+
* includes('this is a test', 'Is'); // => false
|
|
31
|
+
* includes('this is a test', 'Is', true); // => true
|
|
32
|
+
* includes('this is a test', 'not'); // => false
|
|
33
|
+
* ```
|
|
18
34
|
*/
|
|
19
35
|
export declare function includes(haystack: string, needle: string, ignoreCase?: boolean): boolean;
|
|
20
36
|
/**
|
|
@@ -24,6 +40,14 @@ export declare function includes(haystack: string, needle: string, ignoreCase?:
|
|
|
24
40
|
* @param needle String to look for
|
|
25
41
|
* @param ignoreCase Ignore case when matching? _(defaults to `false`)_
|
|
26
42
|
* @returns `true` if the string starts with the given substring, otherwise `false`
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* startsWith('this is a test', 'this'); // => true
|
|
47
|
+
* startsWith('this is a test', 'This'); // => false
|
|
48
|
+
* startsWith('this is a test', 'This', true); // => true
|
|
49
|
+
* startsWith('this is a test', 'not'); // => false
|
|
50
|
+
* ```
|
|
27
51
|
*/
|
|
28
52
|
export declare function startsWith(haystack: string, needle: string, ignoreCase?: boolean): boolean;
|
|
29
53
|
//#endregion
|
package/dist/string/match.mjs
CHANGED
|
@@ -8,6 +8,14 @@ import { memoize } from "../internal/function/memoize.mjs";
|
|
|
8
8
|
* @param needle String to look for
|
|
9
9
|
* @param ignoreCase Ignore case when matching? _(defaults to `false`)_
|
|
10
10
|
* @returns `true` if the string ends with the given substring, otherwise `false`
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* endsWith('this is a test', 'test'); // => true
|
|
15
|
+
* endsWith('this is a test', 'Test'); // => false
|
|
16
|
+
* endsWith('this is a test', 'Test', true); // => true
|
|
17
|
+
* endsWith('this is a test', 'not'); // => false
|
|
18
|
+
* ```
|
|
11
19
|
*/
|
|
12
20
|
function endsWith(haystack, needle, ignoreCase) {
|
|
13
21
|
return match(STRING_MATCH_ENDS_WITH, haystack, needle, ignoreCase === true);
|
|
@@ -19,6 +27,14 @@ function endsWith(haystack, needle, ignoreCase) {
|
|
|
19
27
|
* @param needle String to look for
|
|
20
28
|
* @param ignoreCase Ignore case when matching? _(defaults to `false`)_
|
|
21
29
|
* @returns `true` if the string includes the given substring, otherwise `false`
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* includes('this is a test', 'is'); // => true
|
|
34
|
+
* includes('this is a test', 'Is'); // => false
|
|
35
|
+
* includes('this is a test', 'Is', true); // => true
|
|
36
|
+
* includes('this is a test', 'not'); // => false
|
|
37
|
+
* ```
|
|
22
38
|
*/
|
|
23
39
|
function includes(haystack, needle, ignoreCase) {
|
|
24
40
|
return match(STRING_MATCH_INCLUDES, haystack, needle, ignoreCase === true);
|
|
@@ -38,6 +54,14 @@ function matchCallback(haystack, needle, ignoreCase) {
|
|
|
38
54
|
* @param needle String to look for
|
|
39
55
|
* @param ignoreCase Ignore case when matching? _(defaults to `false`)_
|
|
40
56
|
* @returns `true` if the string starts with the given substring, otherwise `false`
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* startsWith('this is a test', 'this'); // => true
|
|
61
|
+
* startsWith('this is a test', 'This'); // => false
|
|
62
|
+
* startsWith('this is a test', 'This', true); // => true
|
|
63
|
+
* startsWith('this is a test', 'not'); // => false
|
|
64
|
+
* ```
|
|
41
65
|
*/
|
|
42
66
|
function startsWith(haystack, needle, ignoreCase) {
|
|
43
67
|
return match(STRING_MATCH_STARTS_WITH, haystack, needle, ignoreCase === true);
|
|
@@ -24,6 +24,10 @@ export declare function template(strings: TemplateStringsArray, ...values: unkno
|
|
|
24
24
|
* @param variables Variables to use
|
|
25
25
|
* @param options Templating options
|
|
26
26
|
* @returns Templated string
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* template('Hello, {{name}}!', {name: 'World'}); // => 'Hello, World!'
|
|
30
|
+
* ```
|
|
27
31
|
*/
|
|
28
32
|
export declare function template(value: string, variables?: PlainObject, options?: Partial<TemplateOptions>): string;
|
|
29
33
|
export declare namespace template {
|