@juisy/utils 3.0.0-beta.3 → 3.0.0-beta.4

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 (92) hide show
  1. package/LICENSE +661 -661
  2. package/README.md +12 -10
  3. package/dist/assert/argsert.d.ts +23 -5
  4. package/dist/assert/argsert.js +50 -3
  5. package/dist/assert/assert.d.ts +31 -0
  6. package/dist/assert/assert.js +32 -2
  7. package/dist/blob/to-data-url.d.ts +14 -0
  8. package/dist/blob/to-data-url.js +23 -0
  9. package/dist/constructor/apply-mixins.js +1 -1
  10. package/dist/constructor/get-constructor-name.js +1 -1
  11. package/dist/date/date-format.js +1 -1
  12. package/dist/date/get-date-range.js +1 -1
  13. package/dist/date/get-duration-between-times.js +1 -1
  14. package/dist/date/get-duration-between.js +1 -1
  15. package/dist/date/get-i18n-timezone-value.js +1 -1
  16. package/dist/date/get-next-date-for-time.js +1 -1
  17. package/dist/date/get-utc-offset.js +1 -1
  18. package/dist/fs/get-file-urls.js +5 -3
  19. package/dist/fs/get-files-sync.js +1 -1
  20. package/dist/fs/get-files.js +1 -1
  21. package/dist/fs/get-root-dir.js +1 -1
  22. package/dist/fs/is-directory.js +1 -1
  23. package/dist/fs/is-file.js +1 -1
  24. package/dist/is/is-def.js +1 -1
  25. package/dist/is/is-valid-css-color.js +1 -1
  26. package/dist/is/is.js +1 -1
  27. package/dist/json/compile-pointer.d.ts +8 -5
  28. package/dist/json/compile-pointer.js +4 -3
  29. package/dist/json/escape-pointer-segment.d.ts +5 -1
  30. package/dist/json/escape-pointer-segment.js +1 -1
  31. package/dist/json/get-by-pointer.js +1 -1
  32. package/dist/json/has-value.js +1 -1
  33. package/dist/json/parse-pointer.d.ts +8 -5
  34. package/dist/json/parse-pointer.js +2 -2
  35. package/dist/json/remove-by-pointer.js +1 -1
  36. package/dist/json/set-by-pointer.js +1 -1
  37. package/dist/json/to-pointers-dictionary.js +1 -1
  38. package/dist/json/traverse.js +1 -1
  39. package/dist/json/unescape-pointer-segment.d.ts +5 -1
  40. package/dist/json/unescape-pointer-segment.js +1 -1
  41. package/dist/misc/compose.js +1 -1
  42. package/dist/misc/detect-browser.js +1 -1
  43. package/dist/misc/get-aspect-ratio.d.ts +18 -0
  44. package/dist/misc/get-aspect-ratio.js +13 -0
  45. package/dist/misc/type-check.js +1 -1
  46. package/dist/number/get-greatest-common-divider.d.ts +17 -0
  47. package/dist/number/get-greatest-common-divider.js +17 -0
  48. package/dist/number/get-least-common-multiple.d.ts +16 -0
  49. package/dist/number/get-least-common-multiple.js +19 -0
  50. package/dist/object/deep-merge.js +1 -1
  51. package/dist/object/deep-parse.js +1 -1
  52. package/dist/object/get.js +1 -1
  53. package/dist/path/is-absolute.d.ts +19 -0
  54. package/dist/path/is-absolute.js +13 -0
  55. package/dist/path/is-invalid.d.ts +42 -0
  56. package/dist/path/is-invalid.js +23 -0
  57. package/dist/path/is-posix.js +1 -1
  58. package/dist/path/is-relative.d.ts +19 -0
  59. package/dist/path/is-relative.js +12 -0
  60. package/dist/path/is-same-as.d.ts +1 -0
  61. package/dist/path/is-same-as.js +1 -1
  62. package/dist/path/is-valid.d.ts +16 -0
  63. package/dist/path/is-valid.js +12 -0
  64. package/dist/path/is-win32.js +1 -1
  65. package/dist/path/normalize.d.ts +1 -0
  66. package/dist/path/normalize.js +2 -2
  67. package/dist/path/resolve-abs-from-root.js +2 -2
  68. package/dist/path/resolve-rel-from-root.js +1 -1
  69. package/dist/path/resolve-rel.d.ts +1 -0
  70. package/dist/path/resolve-rel.js +4 -3
  71. package/dist/path/strip-extension.d.ts +1 -0
  72. package/dist/path/strip-extension.js +2 -2
  73. package/dist/path/to-os-format.d.ts +1 -0
  74. package/dist/path/to-os-format.js +2 -2
  75. package/dist/path/to-posix.d.ts +1 -0
  76. package/dist/path/to-posix.js +2 -2
  77. package/dist/path/to-win32.d.ts +1 -0
  78. package/dist/path/to-win32.js +2 -2
  79. package/dist/random/random-alpha-numeric.js +7 -2
  80. package/dist/random/random-number.js +1 -1
  81. package/dist/string/camelcase.js +1 -1
  82. package/dist/string/capitalize.js +1 -1
  83. package/dist/string/constantcase.d.ts +4 -4
  84. package/dist/string/constantcase.js +1 -1
  85. package/dist/string/kebabcase.js +1 -1
  86. package/dist/string/lowercase.js +1 -1
  87. package/dist/string/pascalcase.js +1 -1
  88. package/dist/string/snakecase.js +1 -1
  89. package/dist/string/uppercase.js +1 -1
  90. package/package.json +22 -4
  91. package/skills/juisy-utils/SKILL.md +55 -0
  92. package/skills/juisy-utils/references/deep-imports.md +38 -0
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -4,6 +4,10 @@
4
4
  * @remarks Code widely inspired from [json-pointer](https://www.npmjs.com/package/json-pointer) library
5
5
  * @author Hervé Perchec
6
6
  */
7
+ /**
8
+ * Unescape a pointer segment in compliance with [RFC 6901](https://datatracker.ietf.org/doc/html/rfc6901#section-3)
9
+ */
10
+ export type UnescapePointerSegment<S extends string> = S extends `${infer Head}~1${infer Tail}` ? `${UnescapePointerSegment<Head>}/${UnescapePointerSegment<Tail>}` : S extends `${infer Head}~0${infer Tail}` ? `${UnescapePointerSegment<Head>}~${UnescapePointerSegment<Tail>}` : S;
7
11
  /**
8
12
  * Unescapes a pointer segment in compliance with [RFC 6901](https://datatracker.ietf.org/doc/html/rfc6901#section-3).
9
13
  * It replaces `~1` & `~0` by `/` & `~`.
@@ -14,5 +18,5 @@
14
18
  * unescapePointerSegment('a~0b') // 'a~b'
15
19
  * unescapePointerSegment('b~1c') // 'b/c'
16
20
  */
17
- export declare function unescapePointerSegment(escaped: string): string;
21
+ export declare function unescapePointerSegment<S extends string>(escaped: S): UnescapePointerSegment<S>;
18
22
  export default unescapePointerSegment;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @module misc/get-aspect-ratio
3
+ * @importTarget ./misc/get-aspect-ratio
4
+ * @author Hervé Perchec
5
+ */
6
+ /**
7
+ * Get the aspect ratio for the given width and height
8
+ * @param width - The width
9
+ * @param height - The height
10
+ * @envCompat Browser
11
+ * @envCompat Node
12
+ * @example
13
+ * getAspectRatio(1024, 768) // '4:3'
14
+ * getAspectRatio(1920, 1080) // '16:9'
15
+ * getAspectRatio(1080, 1920) // '9:16'
16
+ */
17
+ export declare function getAspectRatio(width: number, height: number): string;
18
+ export default getAspectRatio;
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * juisy v3.0.0-beta.4
3
+ * Copyright © 2022-Present Hervé Perchec
4
+ */
5
+
6
+ import getGCD from '@juisy/utils/number/get-greatest-common-divider';
7
+
8
+ function getAspectRatio(width, height) {
9
+ const gcd = getGCD(width, height);
10
+ return `${width / gcd}:${height / gcd}`;
11
+ }
12
+
13
+ export { getAspectRatio as default, getAspectRatio };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @module number/get-greatest-common-divider
3
+ * @importTarget ./number/get-greatest-common-divider
4
+ * @author Hervé Perchec
5
+ */
6
+ /**
7
+ * Get the GCD (Greatest Common Divider) of the given integers
8
+ * @envCompat Browser
9
+ * @envCompat Node
10
+ * @example
11
+ * getGreatestCommonDivider(4, 2) // 2
12
+ * getGreatestCommonDivider(48, 18, 30) // 6
13
+ * getGreatestCommonDivider(100, 50, 25, 10) // 5
14
+ * getGreatestCommonDivider(12, 18, 24, 36, 48) // 6
15
+ */
16
+ export declare function getGreatestCommonDivider(...numbers: number[]): number;
17
+ export default getGreatestCommonDivider;
@@ -0,0 +1,17 @@
1
+ /*!
2
+ * juisy v3.0.0-beta.4
3
+ * Copyright © 2022-Present Hervé Perchec
4
+ */
5
+
6
+ import argsert from '@juisy/utils/assert/argsert';
7
+
8
+ function getGreatestCommonDivider(...numbers) {
9
+ if (numbers.length === 0) return 0;
10
+ argsert(numbers, `...numbers`, [argsert.array.ofType(argsert.number.integer)]);
11
+ const getGCD = (a, b) => b === 0 ? a : getGCD(b, a % b);
12
+ return numbers.reduce((accumulator, currentValue) => {
13
+ return getGCD(Math.abs(accumulator), Math.abs(currentValue));
14
+ });
15
+ }
16
+
17
+ export { getGreatestCommonDivider as default, getGreatestCommonDivider };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @module number/get-least-common-multiple
3
+ * @importTarget ./number/get-least-common-multiple
4
+ * @author Hervé Perchec
5
+ */
6
+ /**
7
+ * Get the LCM (Least Common Multiple) of the given integers
8
+ * @envCompat Browser
9
+ * @envCompat Node
10
+ * @example
11
+ * getLeastCommonMultiple(4, 5) // 20
12
+ * getLeastCommonMultiple(12, 15, 10) // 60
13
+ * getLeastCommonMultiple(3, 4, 5, 6) // 60
14
+ */
15
+ export declare function getLeastCommonMultiple(...numbers: number[]): number;
16
+ export default getLeastCommonMultiple;
@@ -0,0 +1,19 @@
1
+ /*!
2
+ * juisy v3.0.0-beta.4
3
+ * Copyright © 2022-Present Hervé Perchec
4
+ */
5
+
6
+ import getGCD from '@juisy/utils/number/get-greatest-common-divider';
7
+
8
+ function getLeastCommonMultiple(...numbers) {
9
+ if (numbers.length === 0) return 0;
10
+ const getLCM = (a, b) => {
11
+ if (a === 0 || b === 0) return 0;
12
+ return Math.abs(a * b) / getGCD(a, b);
13
+ };
14
+ return numbers.reduce((accumulator, currentValue) => {
15
+ return getLCM(accumulator, currentValue);
16
+ });
17
+ }
18
+
19
+ export { getLeastCommonMultiple as default, getLeastCommonMultiple };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @module path/is-absolute
3
+ * @importTarget ./path/is-absolute
4
+ * @author Hervé Perchec
5
+ */
6
+ /**
7
+ * Check if the given path is absolute
8
+ * @param val - The path to check
9
+ * @envCompat Browser
10
+ * @envCompat Node
11
+ * @example
12
+ * isAbsolute('C:\\a\\win32\\absolute\\path') // true
13
+ * isAbsolute('/a/posix/absolute/path') // true
14
+ * isAbsolute('/a/mixed\\absolute/path') // true
15
+ * isAbsolute('..\\a\\relative\\..\\win32\\path') // false
16
+ * isAbsolute('../a/relative/../posix/path') // false
17
+ */
18
+ export declare function isAbsolute(val: string): boolean;
19
+ export default isAbsolute;
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * juisy v3.0.0-beta.4
3
+ * Copyright © 2022-Present Hervé Perchec
4
+ */
5
+
6
+ import * as path from 'path-unified';
7
+ import isWin32 from '@juisy/utils/path/is-win32';
8
+
9
+ function isAbsolute(val) {
10
+ return isWin32(val) ? path.win32.isAbsolute(val) : path.posix.isAbsolute(val);
11
+ }
12
+
13
+ export { isAbsolute as default, isAbsolute };
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @module path/is-invalid
3
+ * @importTarget ./path/is-invalid
4
+ * @remarks Implementation of [https://www.npmjs.com/package/is-invalid-path](https://www.npmjs.com/package/https://www.npmjs.com/package/is-invalid-path)
5
+ * library (by Jon Schlinkert) to work in Browser environment
6
+ * @author Hervé Perchec
7
+ */
8
+ export interface IsInvalidOptions {
9
+ /**
10
+ * Force the given path to be treated as Windows path.
11
+ * Default `false`.
12
+ */
13
+ windows?: boolean;
14
+ /**
15
+ * Allow Windows extended path length (32767).
16
+ * Default `false` (260).
17
+ *
18
+ * See also https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#maximum-path-length-limitation.
19
+ */
20
+ winExtended?: boolean;
21
+ /**
22
+ * Treat the given path as a filename, so returns `true`
23
+ * if the path has slashes or backslashes.
24
+ */
25
+ file?: boolean;
26
+ }
27
+ /**
28
+ * Returns `true` if the given string is invalid path.
29
+ * E.g. if the path has slashes and `options.file` is `true`,
30
+ * as slashes and backslashes are invalid in file names.
31
+ * @param val - The path to check
32
+ * @param options - {@link IsInvalidOptions}
33
+ * @envCompat Browser
34
+ * @envCompat Node
35
+ * @example
36
+ * isInvalid('a/posix/"invalid"/path') // true
37
+ * isInvalid('a/posix/invalid/filename', { file: true }) // true
38
+ * isInvalid('C:\\a\\win32\\valid\\path') // false
39
+ * isInvalid('a/mixed\\path') // false
40
+ */
41
+ export declare function isInvalid(val: string, options?: IsInvalidOptions): boolean;
42
+ export default isInvalid;
@@ -0,0 +1,23 @@
1
+ /*!
2
+ * juisy v3.0.0-beta.4
3
+ * Copyright © 2022-Present Hervé Perchec
4
+ */
5
+
6
+ import * as path from 'path-unified';
7
+ import isWin32 from '@juisy/utils/path/is-win32';
8
+
9
+ function isInvalid(val, options = {}) {
10
+ if (typeof val !== "string" || !val.trim().length) return true;
11
+ if (options.windows || isWin32(val)) {
12
+ const MAX_PATH = options.winExtended ? 32767 : 260;
13
+ if (val.length > MAX_PATH - 12) return true;
14
+ }
15
+ const rootPath = isWin32(val) ? val.match(/^[a-zA-Z]:/)?.[0] : path.parse(val).root;
16
+ if (rootPath) val = val.slice(rootPath.length);
17
+ if (options.file) {
18
+ return /[<>:"/\\|?*]/.test(val);
19
+ }
20
+ return /[<>:"|?*]/.test(val);
21
+ }
22
+
23
+ export { isInvalid as default, isInvalid };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @module path/is-relative
3
+ * @importTarget ./path/is-relative
4
+ * @author Hervé Perchec
5
+ */
6
+ /**
7
+ * Check if the given path is relative
8
+ * @param val - The path to check
9
+ * @envCompat Browser
10
+ * @envCompat Node
11
+ * @example
12
+ * isRelative('a/relative/posix/path') // true
13
+ * isRelative('..\\a\\relative\\..\\win32\\path') // true
14
+ * isRelative('../a/relative/../posix/path') // true
15
+ * isRelative('C:\\a\\win32\\absolute\\path') // false
16
+ * isRelative('/a/posix/absolute/path') // false
17
+ */
18
+ export declare function isRelative(val: string): boolean;
19
+ export default isRelative;
@@ -0,0 +1,12 @@
1
+ /*!
2
+ * juisy v3.0.0-beta.4
3
+ * Copyright © 2022-Present Hervé Perchec
4
+ */
5
+
6
+ import isAbsolute from '@juisy/utils/path/is-absolute';
7
+
8
+ function isRelative(val) {
9
+ return !isAbsolute(val);
10
+ }
11
+
12
+ export { isRelative as default, isRelative };
@@ -8,6 +8,7 @@
8
8
  * @param a - The first file path to compare
9
9
  * @param b - The second file path to compare
10
10
  * @returns True if the two paths are the same
11
+ * @envCompat Browser
11
12
  * @envCompat Node
12
13
  * @example
13
14
  * isSameAs('src/index.ts', 'src\\index.ts') // true
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -0,0 +1,16 @@
1
+ import { IsInvalidOptions } from './is-invalid';
2
+ /**
3
+ * Returns `true` if the given string is valid path.
4
+ * Takes same options as {@link isInvalid}.
5
+ * @param val - The path to check
6
+ * @param options - {@link IsInvalidOptions}
7
+ * @envCompat Browser
8
+ * @envCompat Node
9
+ * @example
10
+ * isValid('C:\\a\\win32\\valid\\path') // true
11
+ * isValid('a/mixed\\path') // true
12
+ * isValid('a/posix/"invalid"/path') // false
13
+ * isValid('a/posix/invalid/filename', { file: true }) // false
14
+ */
15
+ export declare function isValid(val: string, options?: IsInvalidOptions): boolean;
16
+ export default isValid;
@@ -0,0 +1,12 @@
1
+ /*!
2
+ * juisy v3.0.0-beta.4
3
+ * Copyright © 2022-Present Hervé Perchec
4
+ */
5
+
6
+ import { isInvalid } from '@juisy/utils/path/is-invalid';
7
+
8
+ function isValid(val, options) {
9
+ return !isInvalid(val, options);
10
+ }
11
+
12
+ export { isValid as default, isValid };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -6,6 +6,7 @@
6
6
  /**
7
7
  * Normalize a path depending on base format
8
8
  * @param val - The path to normalize
9
+ * @envCompat Browser
9
10
  * @envCompat Node
10
11
  * @example
11
12
  * normalize('a/Posix/path') // => 'a/Posix/path'
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
6
- import path from 'node:path';
6
+ import * as path from 'path-unified';
7
7
  import isWin32 from '@juisy/utils/path/is-win32';
8
8
 
9
9
  function normalize(val) {
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
6
- import path from 'node:path';
6
+ import * as path from 'path-unified';
7
7
  import getRootDir from '@juisy/utils/fs/get-root-dir';
8
8
  import toPosix from '@juisy/utils/path/to-posix';
9
9
  import toWin32 from '@juisy/utils/path/to-win32';
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -9,6 +9,7 @@
9
9
  * @param to - The "to" absolute file path
10
10
  * @param separator - (Optional) The separator type: can be `"posix"` or `"win32"`
11
11
  * @returns The resolved relative path
12
+ * @envCompat Browser
12
13
  * @envCompat Node
13
14
  * @example
14
15
  * const base = 'C:\\Users\\JohnDoe\\Documents\\Projects\\MyProject'
@@ -1,15 +1,16 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
6
- import path from 'node:path';
6
+ import * as path from 'path-unified';
7
+ import isWin32 from '@juisy/utils/path/is-win32';
7
8
  import toPosix from '@juisy/utils/path/to-posix';
8
9
  import toWin32 from '@juisy/utils/path/to-win32';
9
10
  import toOsFormat from '@juisy/utils/path/to-os-format';
10
11
 
11
12
  function resolveRel(from, to, separator) {
12
- const relativePath = path.relative(from, to);
13
+ const relativePath = isWin32(from) || isWin32(to) ? path.win32.relative(from, to) : path.posix.relative(from, to);
13
14
  return separator ? separator === "posix" ? toPosix(relativePath) : toWin32(relativePath) : toOsFormat(relativePath);
14
15
  }
15
16
 
@@ -6,6 +6,7 @@
6
6
  /**
7
7
  * Removes the file extension of the given path
8
8
  * @param value - The target path
9
+ * @envCompat Browser
9
10
  * @envCompat Node
10
11
  * @example
11
12
  * stripExtension('src/index.ts') // 'src/index'
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
6
- import path from 'node:path';
6
+ import * as path from 'path-unified';
7
7
 
8
8
  function stripExtension(value) {
9
9
  return value.replace(new RegExp(path.extname(value) + "$"), "");
@@ -6,6 +6,7 @@
6
6
  /**
7
7
  * Automatically convert a path to OS specific format
8
8
  * @param val - The path to convert
9
+ * @envCompat Browser
9
10
  * @envCompat Node
10
11
  */
11
12
  export declare function toOsFormat(val: string): string;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -7,7 +7,7 @@ import toWin32 from '@juisy/utils/path/to-win32';
7
7
  import toPosix from '@juisy/utils/path/to-posix';
8
8
 
9
9
  function toOsFormat(val) {
10
- const platform = process.platform;
10
+ const platform = process?.platform;
11
11
  return platform === "win32" ? toWin32(val) : toPosix(val);
12
12
  }
13
13
 
@@ -6,6 +6,7 @@
6
6
  /**
7
7
  * Convert a path to posix format (with `/` separator)
8
8
  * @param val - The path to convert
9
+ * @envCompat Browser
9
10
  * @envCompat Node
10
11
  * @example
11
12
  * toPosix('a/posix/path') // 'a/posix/path'
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
6
- import path from 'node:path';
6
+ import * as path from 'path-unified';
7
7
 
8
8
  function toPosix(val) {
9
9
  return val.split(path.win32.sep).join(path.posix.sep);
@@ -6,6 +6,7 @@
6
6
  /**
7
7
  * Convert a path to win32 format (with `\\` separator)
8
8
  * @param val - The path to convert
9
+ * @envCompat Browser
9
10
  * @envCompat Node
10
11
  * @example
11
12
  * toWin32('a/posix/path') // => 'a\posix\path'
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
6
- import path from 'node:path';
6
+ import * as path from 'path-unified';
7
7
 
8
8
  function toWin32(val) {
9
9
  return val.split(path.posix.sep).join(path.win32.sep);
@@ -1,12 +1,17 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
6
6
  import samplesize from 'lodash.samplesize';
7
7
 
8
8
  function randomAlphaNumeric(length, charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") {
9
- return samplesize(charset, length).join("");
9
+ let result = samplesize(charset, length).join("");
10
+ while (result.length < length) {
11
+ const missing = length - result.length;
12
+ result += samplesize(charset, missing > length ? length : missing).join("");
13
+ }
14
+ return result;
10
15
  }
11
16
 
12
17
  export { randomAlphaNumeric as default, randomAlphaNumeric };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,8 +1,8 @@
1
+ import { SnakeCase } from 'type-fest';
1
2
  /**
2
- * @module string/constantcase
3
- * @importTarget ./string/constantcase
4
- * @author Hervé Perchec
3
+ * Converts a string to CONSTANT_CASE
5
4
  */
5
+ export type ConstantCase<S extends string> = Uppercase<SnakeCase<S>>;
6
6
  /**
7
7
  * Converts a string to constantcase
8
8
  * @param str - The string to constantcase
@@ -12,5 +12,5 @@
12
12
  * @example
13
13
  * constantcase('Foo Bar') // 'FOO_BAR'
14
14
  */
15
- export declare function constantcase(str: string): string;
15
+ export declare function constantcase<S extends string>(str: S): ConstantCase<S>;
16
16
  export default constantcase;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.3
2
+ * juisy v3.0.0-beta.4
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5