@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.
Files changed (50) hide show
  1. package/dist/array/filter.d.mts +38 -4
  2. package/dist/array/find.d.mts +34 -0
  3. package/dist/array/first.d.mts +40 -4
  4. package/dist/array/last.d.mts +46 -10
  5. package/dist/array/partition.d.mts +24 -8
  6. package/dist/array/reverse.d.mts +6 -0
  7. package/dist/array/reverse.mjs +6 -0
  8. package/dist/array/select.d.mts +97 -116
  9. package/dist/array/select.mjs +19 -15
  10. package/dist/array/single.d.mts +22 -0
  11. package/dist/array/single.mjs +1 -1
  12. package/dist/array/sort.d.mts +54 -0
  13. package/dist/color/space/hex.d.mts +8 -0
  14. package/dist/color/space/hex.mjs +8 -0
  15. package/dist/index.d.mts +716 -170
  16. package/dist/index.mjs +293 -68
  17. package/dist/internal/array/callbacks.mjs +1 -1
  18. package/dist/internal/array/find.d.mts +3 -3
  19. package/dist/internal/array/find.mjs +71 -52
  20. package/dist/internal/array/shuffle.d.mts +5 -0
  21. package/dist/internal/array/shuffle.mjs +5 -0
  22. package/dist/internal/math/aggregate.d.mts +69 -21
  23. package/dist/internal/math/misc.d.mts +14 -0
  24. package/dist/internal/math/misc.mjs +14 -0
  25. package/dist/internal/number.d.mts +18 -0
  26. package/dist/internal/number.mjs +18 -0
  27. package/dist/internal/string/case.d.mts +63 -0
  28. package/dist/internal/string/case.mjs +63 -0
  29. package/dist/internal/string/misc.d.mts +20 -0
  30. package/dist/internal/string/misc.mjs +20 -0
  31. package/dist/logger.d.mts +12 -0
  32. package/dist/logger.mjs +12 -0
  33. package/dist/math.d.mts +90 -0
  34. package/dist/math.mjs +7 -0
  35. package/dist/models/array/array.find.model.d.mts +26 -0
  36. package/dist/models/array/array.misc.model.d.mts +2 -4
  37. package/dist/models/index.d.mts +1 -1
  38. package/dist/models/value/value.merge.model.d.mts +3 -3
  39. package/dist/promise/misc.d.mts +6 -0
  40. package/dist/promise/misc.mjs +6 -0
  41. package/dist/promise/timed.d.mts +3 -0
  42. package/dist/promise/timed.mjs +3 -0
  43. package/dist/queue.d.mts +0 -1
  44. package/dist/queue.mjs +1 -1
  45. package/dist/string/index.d.mts +15 -1
  46. package/dist/string/index.mjs +15 -1
  47. package/dist/string/match.d.mts +24 -0
  48. package/dist/string/match.mjs +24 -0
  49. package/dist/string/template.d.mts +4 -0
  50. package/package.json +1 -1
@@ -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 "";
@@ -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
@@ -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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oscarpalmer/atoms",
3
- "version": "0.218.0",
3
+ "version": "0.219.0",
4
4
  "description": "Atomic utilities for making your JavaScript better.",
5
5
  "keywords": [
6
6
  "array",