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

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 (80) hide show
  1. package/README.md +3 -3
  2. package/dist/assert/argsert.d.ts +10 -0
  3. package/dist/assert/argsert.js +6 -3
  4. package/dist/assert/assert.js +1 -1
  5. package/dist/constructor/apply-mixins.js +1 -1
  6. package/dist/constructor/get-constructor-name.js +1 -1
  7. package/dist/date/date-format.d.ts +1 -1
  8. package/dist/date/date-format.js +3 -3
  9. package/dist/date/get-date-range.d.ts +1 -1
  10. package/dist/date/get-date-range.js +4 -4
  11. package/dist/date/get-duration-between-times.d.ts +2 -2
  12. package/dist/date/get-duration-between-times.js +4 -4
  13. package/dist/date/get-duration-between.d.ts +2 -2
  14. package/dist/date/get-duration-between.js +3 -3
  15. package/dist/date/get-i18n-timezone-value.d.ts +1 -1
  16. package/dist/date/get-i18n-timezone-value.js +2 -2
  17. package/dist/date/get-next-date-for-time.d.ts +1 -1
  18. package/dist/date/get-next-date-for-time.js +3 -3
  19. package/dist/date/get-utc-offset.d.ts +1 -1
  20. package/dist/date/get-utc-offset.js +3 -3
  21. package/dist/fs/get-file-urls.js +1 -1
  22. package/dist/fs/get-files-sync.js +1 -1
  23. package/dist/fs/get-files.js +1 -1
  24. package/dist/fs/get-root-dir.js +1 -1
  25. package/dist/fs/is-directory.js +1 -1
  26. package/dist/fs/is-file.js +1 -1
  27. package/dist/is/is-def.js +1 -1
  28. package/dist/is/is-valid-css-color.js +1 -1
  29. package/dist/is/is.d.ts +1 -0
  30. package/dist/is/is.js +3 -3
  31. package/dist/json/compile-pointer.d.ts +20 -0
  32. package/dist/json/compile-pointer.js +17 -0
  33. package/dist/json/escape-pointer-segment.d.ts +18 -0
  34. package/dist/json/escape-pointer-segment.js +13 -0
  35. package/dist/json/get-by-pointer.d.ts +16 -0
  36. package/dist/json/get-by-pointer.js +17 -0
  37. package/dist/json/has-value.d.ts +16 -0
  38. package/dist/json/has-value.js +20 -0
  39. package/dist/json/parse-pointer.d.ts +25 -0
  40. package/dist/json/parse-pointer.js +26 -0
  41. package/dist/json/remove-by-pointer.d.ts +16 -0
  42. package/dist/json/remove-by-pointer.js +32 -0
  43. package/dist/json/set-by-pointer.d.ts +17 -0
  44. package/dist/json/set-by-pointer.js +42 -0
  45. package/dist/json/to-pointers-dictionary.d.ts +13 -0
  46. package/dist/json/to-pointers-dictionary.js +16 -0
  47. package/dist/json/traverse.d.ts +32 -0
  48. package/dist/json/traverse.js +29 -0
  49. package/dist/json/unescape-pointer-segment.d.ts +18 -0
  50. package/dist/json/unescape-pointer-segment.js +13 -0
  51. package/dist/misc/compose.js +1 -1
  52. package/dist/misc/detect-browser.js +1 -1
  53. package/dist/misc/type-check.js +1 -1
  54. package/dist/object/deep-merge.js +1 -1
  55. package/dist/object/deep-parse.js +1 -1
  56. package/dist/object/get.d.ts +2 -1
  57. package/dist/object/get.js +1 -1
  58. package/dist/path/is-posix.js +1 -1
  59. package/dist/path/is-same-as.js +1 -1
  60. package/dist/path/is-win32.js +1 -1
  61. package/dist/path/normalize.js +1 -1
  62. package/dist/path/resolve-abs-from-root.js +1 -1
  63. package/dist/path/resolve-rel-from-root.js +1 -1
  64. package/dist/path/resolve-rel.js +1 -1
  65. package/dist/path/strip-extension.d.ts +17 -0
  66. package/dist/path/strip-extension.js +12 -0
  67. package/dist/path/to-os-format.js +1 -1
  68. package/dist/path/to-posix.js +1 -1
  69. package/dist/path/to-win32.js +1 -1
  70. package/dist/random/random-alpha-numeric.js +1 -1
  71. package/dist/random/random-number.js +1 -1
  72. package/dist/string/camelcase.js +1 -1
  73. package/dist/string/capitalize.js +1 -1
  74. package/dist/string/constantcase.js +1 -1
  75. package/dist/string/kebabcase.js +1 -1
  76. package/dist/string/lowercase.js +1 -1
  77. package/dist/string/pascalcase.js +1 -1
  78. package/dist/string/snakecase.js +1 -1
  79. package/dist/string/uppercase.js +1 -1
  80. package/package.json +7 -2
package/README.md CHANGED
@@ -6,12 +6,12 @@
6
6
  [![herve-perchec](http://herve-perchec.com/badge.svg)](http://herve-perchec.com/)
7
7
 
8
8
  [![release](https://img.shields.io/gitlab/v/release/hperchec/juisy?include_prereleases\&logo=gitlab\&sort=semver)](https://gitlab.com/hperchec/juisy/-/releases)
9
- [![pipeline-status](https://gitlab.com/hperchec/juisy/badges/v3.0.0-beta.1/pipeline.svg)](https://gitlab.com/hperchec/juisy/commits/v3.0.0-beta.1)
10
- ![coverage](https://gitlab.com/hperchec/juisy/badges/v3.0.0-beta.1/coverage.svg)
9
+ [![pipeline-status](https://gitlab.com/hperchec/juisy/badges/v3.0.0-beta.3/pipeline.svg)](https://gitlab.com/hperchec/juisy/commits/v3.0.0-beta.3)
10
+ ![coverage](https://gitlab.com/hperchec/juisy/badges/v3.0.0-beta.3/coverage.svg)
11
11
  [![package](https://img.shields.io/npm/v/@juisy/utils?logo=npm)](https://www.npmjs.com/package/@juisy/utils)
12
12
  [![downloads](https://img.shields.io/npm/dw/@juisy/utils?logo=npm)](https://www.npmjs.com/package/@juisy/utils)
13
13
  [![issues](https://img.shields.io/gitlab/issues/open/hperchec/juisy?gitlab_url=https%3A%2F%2Fgitlab.com)](https://gitlab.com/hperchec/juisy/issues)
14
- [![license](https://img.shields.io/gitlab/license/hperchec/juisy?gitlab_url=https%3A%2F%2Fgitlab.com)](https://gitlab.com/hperchec/juisy/-/blob/v3.0.0-beta.1/LICENSE)
14
+ [![license](https://img.shields.io/gitlab/license/hperchec/juisy?gitlab_url=https%3A%2F%2Fgitlab.com)](https://gitlab.com/hperchec/juisy/-/blob/v3.0.0-beta.3/LICENSE)
15
15
 
16
16
  <!-- markdownlint-enable line-length -->
17
17
 
@@ -31,6 +31,16 @@ export interface Argsert extends Pick<ow.Ow, keyof ow.Ow> {
31
31
  */
32
32
  getPredicateConstructor(): typeof ow.Predicate;
33
33
  }
34
+ /**
35
+ * Custom error for unknown predicates
36
+ */
37
+ export declare class UnknownPredicateError extends Error {
38
+ }
39
+ /**
40
+ * Custom error for argument assertion error
41
+ */
42
+ export declare class ArgumentAssertionError extends TypeError {
43
+ }
34
44
  /**
35
45
  * Assert that the given argument value satisfies types constraints.
36
46
  * It's a wrapper of {@link ow} package with some additional features.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -10,6 +10,9 @@ import get from '@juisy/utils/object/get';
10
10
  class UnknownPredicateError extends Error {
11
11
  // ...
12
12
  }
13
+ class ArgumentAssertionError extends TypeError {
14
+ // ...
15
+ }
13
16
  const argsert = function(value, label, predicates) {
14
17
  try {
15
18
  for (const predicate of predicates) {
@@ -31,7 +34,7 @@ const argsert = function(value, label, predicates) {
31
34
  }
32
35
  } catch (error) {
33
36
  if (error instanceof UnknownPredicateError) throw error;
34
- const newError = new TypeError("", { cause: error });
37
+ const newError = new ArgumentAssertionError("", { cause: error });
35
38
  const stackFrames = ErrorStackParser.parse(newError);
36
39
  stackFrames.splice(0, 1);
37
40
  const callerName = stackFrames[0].getFunctionName();
@@ -42,4 +45,4 @@ const argsert = function(value, label, predicates) {
42
45
  Object.defineProperties(argsert, Object.getOwnPropertyDescriptors(_ow));
43
46
  argsert.getPredicateConstructor = () => Predicate;
44
47
 
45
- export { argsert, argsert as default };
48
+ export { ArgumentAssertionError, UnknownPredicateError, argsert, argsert as default };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,4 +1,4 @@
1
- import { Dayjs } from 'juisy_utils_scoped_dayjs/esm';
1
+ import { Dayjs } from 'juisy_utils.scoped_dayjs';
2
2
  /**
3
3
  * Format a date in the given format. Same as dayjs format() method.
4
4
  *
@@ -1,10 +1,10 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
6
- import dayjs from 'juisy_utils_scoped_dayjs/esm';
7
- import utcPlugin from 'juisy_utils_scoped_dayjs/esm/plugin/utc';
6
+ import dayjs from 'juisy_utils.scoped_dayjs';
7
+ import utcPlugin from 'juisy_utils.scoped_dayjs/plugin/utc.js';
8
8
 
9
9
  dayjs.extend(utcPlugin);
10
10
  function dateFormat(date, format, utc = false) {
@@ -1,4 +1,4 @@
1
- import { Dayjs } from 'juisy_utils_scoped_dayjs/esm';
1
+ import { Dayjs } from 'juisy_utils.scoped_dayjs';
2
2
  /**
3
3
  * {@link getDateRange} function options
4
4
  */
@@ -1,11 +1,11 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
6
- import dayjs from 'juisy_utils_scoped_dayjs/esm';
7
- import isSameOrBeforePlugin from 'juisy_utils_scoped_dayjs/esm/plugin/isSameOrBefore';
8
- import isSameOrAfterPlugin from 'juisy_utils_scoped_dayjs/esm/plugin/isSameOrAfter';
6
+ import dayjs from 'juisy_utils.scoped_dayjs';
7
+ import isSameOrBeforePlugin from 'juisy_utils.scoped_dayjs/plugin/isSameOrBefore.js';
8
+ import isSameOrAfterPlugin from 'juisy_utils.scoped_dayjs/plugin/isSameOrAfter.js';
9
9
  import isDef from '@juisy/utils/is/is-def';
10
10
 
11
11
  dayjs.extend(isSameOrBeforePlugin);
@@ -1,5 +1,5 @@
1
- import { Dayjs } from 'juisy_utils_scoped_dayjs/esm';
2
- import { default as durationPlugin } from 'juisy_utils_scoped_dayjs/esm/plugin/duration';
1
+ import { Dayjs } from 'juisy_utils.scoped_dayjs';
2
+ import { default as durationPlugin } from 'juisy_utils.scoped_dayjs/plugin/duration.js';
3
3
  /**
4
4
  * Get duration between times
5
5
  * @param startTime - The start time ('HH:mm' or 'HH:mm:ss')
@@ -1,11 +1,11 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
6
- import dayjs from 'juisy_utils_scoped_dayjs/esm';
7
- import utcPlugin from 'juisy_utils_scoped_dayjs/esm/plugin/utc';
8
- import durationPlugin from 'juisy_utils_scoped_dayjs/esm/plugin/duration';
6
+ import dayjs from 'juisy_utils.scoped_dayjs';
7
+ import utcPlugin from 'juisy_utils.scoped_dayjs/plugin/utc.js';
8
+ import durationPlugin from 'juisy_utils.scoped_dayjs/plugin/duration.js';
9
9
  import getNextDateForTime from '@juisy/utils/date/get-next-date-for-time';
10
10
 
11
11
  dayjs.extend(utcPlugin);
@@ -1,5 +1,5 @@
1
- import { Dayjs } from 'juisy_utils_scoped_dayjs/esm';
2
- import { default as durationPlugin } from 'juisy_utils_scoped_dayjs/esm/plugin/duration';
1
+ import { Dayjs } from 'juisy_utils.scoped_dayjs';
2
+ import { default as durationPlugin } from 'juisy_utils.scoped_dayjs/plugin/duration.js';
3
3
  /**
4
4
  * Get duration between times
5
5
  * @param from - The "from" date ({@link Date}, {@link Dayjs} or string)
@@ -1,10 +1,10 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
6
- import dayjs from 'juisy_utils_scoped_dayjs/esm';
7
- import durationPlugin from 'juisy_utils_scoped_dayjs/esm/plugin/duration';
6
+ import dayjs from 'juisy_utils.scoped_dayjs';
7
+ import durationPlugin from 'juisy_utils.scoped_dayjs/plugin/duration.js';
8
8
 
9
9
  dayjs.extend(durationPlugin);
10
10
  function getDurationBetween(from, to) {
@@ -1,4 +1,4 @@
1
- import { Dayjs } from 'juisy_utils_scoped_dayjs/esm';
1
+ import { Dayjs } from 'juisy_utils.scoped_dayjs';
2
2
  /**
3
3
  * Get the translated values for date timezone
4
4
  * @param locale - The locale
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
6
- import dayjs from 'juisy_utils_scoped_dayjs/esm';
6
+ import dayjs from 'juisy_utils.scoped_dayjs';
7
7
 
8
8
  function getI18nTimezoneValue(locale, timezone, date) {
9
9
  const baseDate = dayjs.isDayjs(date) ? date : dayjs(date);
@@ -1,4 +1,4 @@
1
- import { Dayjs } from 'juisy_utils_scoped_dayjs/esm';
1
+ import { Dayjs } from 'juisy_utils.scoped_dayjs';
2
2
  /**
3
3
  * Get the next date for the given time
4
4
  * @param date - The start date ({@link Date}, {@link Dayjs} or string)
@@ -1,10 +1,10 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
6
- import dayjs from 'juisy_utils_scoped_dayjs/esm';
7
- import durationPlugin from 'juisy_utils_scoped_dayjs/esm/plugin/duration';
6
+ import dayjs from 'juisy_utils.scoped_dayjs';
7
+ import durationPlugin from 'juisy_utils.scoped_dayjs/plugin/duration.js';
8
8
 
9
9
  dayjs.extend(durationPlugin);
10
10
  function getNextDateForTime(date, time) {
@@ -1,4 +1,4 @@
1
- import { Dayjs } from 'juisy_utils_scoped_dayjs/esm';
1
+ import { Dayjs } from 'juisy_utils.scoped_dayjs';
2
2
  /**
3
3
  * Get the UTC offset of a date
4
4
  * @param date - The date to parse ({@link Date}, {@link Dayjs} or string)
@@ -1,10 +1,10 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
6
- import dayjs from 'juisy_utils_scoped_dayjs/esm';
7
- import utcPlugin from 'juisy_utils_scoped_dayjs/esm/plugin/utc';
6
+ import dayjs from 'juisy_utils.scoped_dayjs';
7
+ import utcPlugin from 'juisy_utils.scoped_dayjs/plugin/utc.js';
8
8
 
9
9
  dayjs.extend(utcPlugin);
10
10
  function getUtcOffset(date, format = "hours") {
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
package/dist/is/is-def.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
package/dist/is/is.d.ts CHANGED
@@ -452,5 +452,6 @@ export declare const isWeakSet: typeof _isWeakSet;
452
452
  */
453
453
  export declare const isWhitespaceString: typeof _isWhitespaceString;
454
454
  export { isUndefined as isUndef };
455
+ export { isEmptyStringOrWhitespace as isBlankString };
455
456
  export { default as is } from '@sindresorhus/is';
456
457
  export default is;
package/dist/is/is.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
6
- import is, { isAll as isAll$1, isAny as isAny$1, isArray as isArray$1, isArrayBuffer as isArrayBuffer$1, isArrayLike as isArrayLike$1, isAsyncFunction as isAsyncFunction$1, isAsyncGenerator as isAsyncGenerator$1, isAsyncGeneratorFunction as isAsyncGeneratorFunction$1, isAsyncIterable as isAsyncIterable$1, isBigInt64Array as isBigInt64Array$1, isBigUint64Array as isBigUint64Array$1, isBigint as isBigint$1, isBlob as isBlob$1, isBoolean as isBoolean$1, isBoundFunction as isBoundFunction$1, isBuffer as isBuffer$1, isClass as isClass$1, isDataView as isDataView$1, isDate as isDate$1, isDirectInstanceOf as isDirectInstanceOf$1, isEmptyArray as isEmptyArray$1, isEmptyMap as isEmptyMap$1, isEmptyObject as isEmptyObject$1, isEmptySet as isEmptySet$1, isEmptyString as isEmptyString$1, isEmptyStringOrWhitespace as isEmptyStringOrWhitespace$1, isEnumCase as isEnumCase$1, isError as isError$1, isEvenInteger as isEvenInteger$1, isFalsy as isFalsy$1, isFloat32Array as isFloat32Array$1, isFloat64Array as isFloat64Array$1, isFormData as isFormData$1, isFunction as isFunction$1, isGenerator as isGenerator$1, isGeneratorFunction as isGeneratorFunction$1, isHtmlElement as isHtmlElement$1, isInRange as isInRange$1, isInfinite as isInfinite$1, isInt16Array as isInt16Array$1, isInt32Array as isInt32Array$1, isInt8Array as isInt8Array$1, isInteger as isInteger$1, isIterable as isIterable$1, isMap as isMap$1, isNan as isNan$1, isNativePromise as isNativePromise$1, isNegativeNumber as isNegativeNumber$1, isNodeStream as isNodeStream$1, isNonEmptyArray as isNonEmptyArray$1, isNonEmptyMap as isNonEmptyMap$1, isNonEmptyObject as isNonEmptyObject$1, isNonEmptySet as isNonEmptySet$1, isNonEmptyString as isNonEmptyString$1, isNonEmptyStringAndNotWhitespace as isNonEmptyStringAndNotWhitespace$1, isNull as isNull$1, isNullOrUndefined as isNullOrUndefined$1, isNumber as isNumber$1, isNumericString as isNumericString$1, isObject as isObject$1, isObservable as isObservable$1, isOddInteger as isOddInteger$1, isPlainObject as isPlainObject$1, isPositiveNumber as isPositiveNumber$1, isPrimitive as isPrimitive$1, isPromise as isPromise$1, isPropertyKey as isPropertyKey$1, isRegExp as isRegExp$1, isSafeInteger as isSafeInteger$1, isSet as isSet$1, isSharedArrayBuffer as isSharedArrayBuffer$1, isString as isString$1, isSymbol as isSymbol$1, isTruthy as isTruthy$1, isTupleLike as isTupleLike$1, isTypedArray as isTypedArray$1, isUint16Array as isUint16Array$1, isUint32Array as isUint32Array$1, isUint8Array as isUint8Array$1, isUint8ClampedArray as isUint8ClampedArray$1, isUndefined as isUndefined$1, isUrlInstance as isUrlInstance$1, isUrlSearchParams as isUrlSearchParams$1, isUrlString as isUrlString$1, isValidDate as isValidDate$1, isValidLength as isValidLength$1, isWeakMap as isWeakMap$1, isWeakRef as isWeakRef$1, isWeakSet as isWeakSet$1, isWhitespaceString as isWhitespaceString$1 } from '@sindresorhus/is';
6
+ import is, { isAll as isAll$1, isAny as isAny$1, isArray as isArray$1, isArrayBuffer as isArrayBuffer$1, isArrayLike as isArrayLike$1, isAsyncFunction as isAsyncFunction$1, isAsyncGenerator as isAsyncGenerator$1, isAsyncGeneratorFunction as isAsyncGeneratorFunction$1, isAsyncIterable as isAsyncIterable$1, isBigInt64Array as isBigInt64Array$1, isBigUint64Array as isBigUint64Array$1, isBigint as isBigint$1, isEmptyStringOrWhitespace as isEmptyStringOrWhitespace$1, isBlob as isBlob$1, isBoolean as isBoolean$1, isBoundFunction as isBoundFunction$1, isBuffer as isBuffer$1, isClass as isClass$1, isDataView as isDataView$1, isDate as isDate$1, isDirectInstanceOf as isDirectInstanceOf$1, isEmptyArray as isEmptyArray$1, isEmptyMap as isEmptyMap$1, isEmptyObject as isEmptyObject$1, isEmptySet as isEmptySet$1, isEmptyString as isEmptyString$1, isEnumCase as isEnumCase$1, isError as isError$1, isEvenInteger as isEvenInteger$1, isFalsy as isFalsy$1, isFloat32Array as isFloat32Array$1, isFloat64Array as isFloat64Array$1, isFormData as isFormData$1, isFunction as isFunction$1, isGenerator as isGenerator$1, isGeneratorFunction as isGeneratorFunction$1, isHtmlElement as isHtmlElement$1, isInRange as isInRange$1, isInfinite as isInfinite$1, isInt16Array as isInt16Array$1, isInt32Array as isInt32Array$1, isInt8Array as isInt8Array$1, isInteger as isInteger$1, isIterable as isIterable$1, isMap as isMap$1, isNan as isNan$1, isNativePromise as isNativePromise$1, isNegativeNumber as isNegativeNumber$1, isNodeStream as isNodeStream$1, isNonEmptyArray as isNonEmptyArray$1, isNonEmptyMap as isNonEmptyMap$1, isNonEmptyObject as isNonEmptyObject$1, isNonEmptySet as isNonEmptySet$1, isNonEmptyString as isNonEmptyString$1, isNonEmptyStringAndNotWhitespace as isNonEmptyStringAndNotWhitespace$1, isNull as isNull$1, isNullOrUndefined as isNullOrUndefined$1, isNumber as isNumber$1, isNumericString as isNumericString$1, isObject as isObject$1, isObservable as isObservable$1, isOddInteger as isOddInteger$1, isPlainObject as isPlainObject$1, isPositiveNumber as isPositiveNumber$1, isPrimitive as isPrimitive$1, isPromise as isPromise$1, isPropertyKey as isPropertyKey$1, isRegExp as isRegExp$1, isSafeInteger as isSafeInteger$1, isSet as isSet$1, isSharedArrayBuffer as isSharedArrayBuffer$1, isString as isString$1, isSymbol as isSymbol$1, isTruthy as isTruthy$1, isTupleLike as isTupleLike$1, isTypedArray as isTypedArray$1, isUint16Array as isUint16Array$1, isUint32Array as isUint32Array$1, isUint8Array as isUint8Array$1, isUint8ClampedArray as isUint8ClampedArray$1, isUndefined as isUndefined$1, isUrlInstance as isUrlInstance$1, isUrlSearchParams as isUrlSearchParams$1, isUrlString as isUrlString$1, isValidDate as isValidDate$1, isValidLength as isValidLength$1, isWeakMap as isWeakMap$1, isWeakRef as isWeakRef$1, isWeakSet as isWeakSet$1, isWhitespaceString as isWhitespaceString$1 } from '@sindresorhus/is';
7
7
  export { default, default as is } from '@sindresorhus/is';
8
8
  export { default as isDef } from './is-def.js';
9
9
  export { default as isValidCSSColor } from './is-valid-css-color.js';
@@ -99,4 +99,4 @@ const isWeakRef = isWeakRef$1;
99
99
  const isWeakSet = isWeakSet$1;
100
100
  const isWhitespaceString = isWhitespaceString$1;
101
101
 
102
- export { isAll, isAny, isArray, isArrayBuffer, isArrayLike, isAsyncFunction, isAsyncGenerator, isAsyncGeneratorFunction, isAsyncIterable, isBigInt64Array, isBigUint64Array, isBigint, isBlob, isBoolean, isBoundFunction, isBuffer, isClass, isDataView, isDate, isDirectInstanceOf, isEmptyArray, isEmptyMap, isEmptyObject, isEmptySet, isEmptyString, isEmptyStringOrWhitespace, isEnumCase, isError, isEvenInteger, isFalsy, isFloat32Array, isFloat64Array, isFormData, isFunction, isGenerator, isGeneratorFunction, isHtmlElement, isInRange, isInfinite, isInt16Array, isInt32Array, isInt8Array, isInteger, isIterable, isMap, isNan, isNativePromise, isNegativeNumber, isNodeStream, isNonEmptyArray, isNonEmptyMap, isNonEmptyObject, isNonEmptySet, isNonEmptyString, isNonEmptyStringAndNotWhitespace, isNull, isNullOrUndefined, isNumber, isNumericString, isObject, isObservable, isOddInteger, isPlainObject, isPositiveNumber, isPrimitive, isPromise, isPropertyKey, isRegExp, isSafeInteger, isSet, isSharedArrayBuffer, isString, isSymbol, isTruthy, isTupleLike, isTypedArray, isUint16Array, isUint32Array, isUint8Array, isUint8ClampedArray, isUndefined as isUndef, isUndefined, isUrlInstance, isUrlSearchParams, isUrlString, isValidDate, isValidLength, isWeakMap, isWeakRef, isWeakSet, isWhitespaceString };
102
+ export { isAll, isAny, isArray, isArrayBuffer, isArrayLike, isAsyncFunction, isAsyncGenerator, isAsyncGeneratorFunction, isAsyncIterable, isBigInt64Array, isBigUint64Array, isBigint, isEmptyStringOrWhitespace as isBlankString, isBlob, isBoolean, isBoundFunction, isBuffer, isClass, isDataView, isDate, isDirectInstanceOf, isEmptyArray, isEmptyMap, isEmptyObject, isEmptySet, isEmptyString, isEmptyStringOrWhitespace, isEnumCase, isError, isEvenInteger, isFalsy, isFloat32Array, isFloat64Array, isFormData, isFunction, isGenerator, isGeneratorFunction, isHtmlElement, isInRange, isInfinite, isInt16Array, isInt32Array, isInt8Array, isInteger, isIterable, isMap, isNan, isNativePromise, isNegativeNumber, isNodeStream, isNonEmptyArray, isNonEmptyMap, isNonEmptyObject, isNonEmptySet, isNonEmptyString, isNonEmptyStringAndNotWhitespace, isNull, isNullOrUndefined, isNumber, isNumericString, isObject, isObservable, isOddInteger, isPlainObject, isPositiveNumber, isPrimitive, isPromise, isPropertyKey, isRegExp, isSafeInteger, isSet, isSharedArrayBuffer, isString, isSymbol, isTruthy, isTupleLike, isTypedArray, isUint16Array, isUint32Array, isUint8Array, isUint8ClampedArray, isUndefined as isUndef, isUndefined, isUrlInstance, isUrlSearchParams, isUrlString, isValidDate, isValidLength, isWeakMap, isWeakRef, isWeakSet, isWhitespaceString };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @module json/compile-pointer
3
+ * @importTarget ./json/compile-pointer
4
+ * @remarks Code widely inspired from [json-pointer](https://www.npmjs.com/package/json-pointer) library
5
+ * @author Hervé Perchec
6
+ */
7
+ /**
8
+ * Creates a JSON pointer from segments (array of reference tokens)
9
+ * in compliance with [RFC 6901](https://datatracker.ietf.org/doc/html/rfc6901#section-3).
10
+ * @param segments - The pointer segments
11
+ * @param hash - Add the '#' prefix
12
+ * @envCompat Browser
13
+ * @envCompat Node
14
+ * @example
15
+ * compilePointer([ 'a', 'b' ]) // '/a/b'
16
+ * compilePointer([ 'a/b', 'c' ], true) // '#/a~1b/c'
17
+ * compilePointer([]) // '/'
18
+ */
19
+ export declare function compilePointer(segments: Array<string | number>, hash?: boolean): string;
20
+ export default compilePointer;
@@ -0,0 +1,17 @@
1
+ /*!
2
+ * juisy v3.0.0-beta.3
3
+ * Copyright © 2022-Present Hervé Perchec
4
+ */
5
+
6
+ import argsert from '@juisy/utils/assert/argsert';
7
+ import escapePointerSegment from '@juisy/utils/json/escape-pointer-segment';
8
+
9
+ function compilePointer(segments, hash = false) {
10
+ argsert(segments, "segments", [
11
+ argsert.array.ofType(argsert.any(argsert.string.nonBlank, argsert.number))
12
+ ]);
13
+ argsert(hash, "hash", ["boolean"]);
14
+ return `${hash ? "#" : ""}/${segments.map(String).map(escapePointerSegment).join("/")}`;
15
+ }
16
+
17
+ export { compilePointer, compilePointer as default };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @module json/escape-pointer-segment
3
+ * @importTarget ./json/escape-pointer-segment
4
+ * @remarks Code widely inspired from [json-pointer](https://www.npmjs.com/package/json-pointer) library
5
+ * @author Hervé Perchec
6
+ */
7
+ /**
8
+ * Escapes a pointer segment in compliance with [RFC 6901](https://datatracker.ietf.org/doc/html/rfc6901#section-3).
9
+ * It replaces `/` & `~` by `~1` & `~0`.
10
+ * @param unsafeString - The string to escape
11
+ * @envCompat Browser
12
+ * @envCompat Node
13
+ * @example
14
+ * escapePointerSegment('a~b') // 'a~0b'
15
+ * escapePointerSegment('b/c') // 'b~1c'
16
+ */
17
+ export declare function escapePointerSegment(unsafeString: string): string;
18
+ export default escapePointerSegment;
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * juisy v3.0.0-beta.3
3
+ * Copyright © 2022-Present Hervé Perchec
4
+ */
5
+
6
+ import argsert from '@juisy/utils/assert/argsert';
7
+
8
+ function escapePointerSegment(unsafeString) {
9
+ argsert(unsafeString, "unsafeString", ["string"]);
10
+ return unsafeString.replace(/~/g, "~0").replace(/\//g, "~1");
11
+ }
12
+
13
+ export { escapePointerSegment as default, escapePointerSegment };
@@ -0,0 +1,16 @@
1
+ import { JsonValue, JsonArray, JsonObject } from 'type-fest';
2
+ /**
3
+ * Lookup a JSON pointer in the target object.
4
+ * It supports pointer that starts with '#' (e.g. `#/internal/ref/example`).
5
+ * @param target - The target object
6
+ * @param pointer - The pointer as string or array of reference tokens
7
+ * @envCompat Browser
8
+ * @envCompat Node
9
+ * @example
10
+ * const object = { 'a': [{ 'b': { 'c': 3 } }] }
11
+ * getByPointer(object, '/a/0/b/c') // 3
12
+ * getByPointer(object, '#/a/0/b') // { 'c': 3 }
13
+ * getByPointer(object, '/a/0/b/c/d') // Error
14
+ */
15
+ export declare function getByPointer(target: JsonArray | JsonObject, pointer: string | Array<string | number>): JsonValue;
16
+ export default getByPointer;
@@ -0,0 +1,17 @@
1
+ /*!
2
+ * juisy v3.0.0-beta.3
3
+ * Copyright © 2022-Present Hervé Perchec
4
+ */
5
+
6
+ import get from '@juisy/utils/object/get';
7
+ import { isArray } from '@juisy/utils/is/is';
8
+ import parsePointer from '@juisy/utils/json/parse-pointer';
9
+
10
+ function getByPointer(target, pointer) {
11
+ const tokens = isArray(pointer) ? pointer : parsePointer(pointer);
12
+ const value = get(target, tokens, new Error(`Invalid reference token: "${pointer}"`));
13
+ if (value instanceof Error) throw value;
14
+ return value;
15
+ }
16
+
17
+ export { getByPointer as default, getByPointer };
@@ -0,0 +1,16 @@
1
+ import { JsonArray, JsonObject } from 'type-fest';
2
+ /**
3
+ * Tests if the target object has a value for the given JSON pointer.
4
+ * It supports pointer that starts with '#' (e.g. `#/internal/ref/example`).
5
+ * @param target - The target object
6
+ * @param pointer - The pointer as string or array of reference tokens
7
+ * @envCompat Browser
8
+ * @envCompat Node
9
+ * @example
10
+ * const object = { 'a': [{ 'b': { 'c': 3 } }] }
11
+ * hasValue(object, '/a/0/b/c') // true
12
+ * hasValue(object, '#/a/0/b') // true
13
+ * hasValue(object, '/a/0/b/d') // false
14
+ */
15
+ export declare function hasValue(target: JsonArray | JsonObject, pointer: string | Array<string | number>): boolean;
16
+ export default hasValue;
@@ -0,0 +1,20 @@
1
+ /*!
2
+ * juisy v3.0.0-beta.3
3
+ * Copyright © 2022-Present Hervé Perchec
4
+ */
5
+
6
+ import { ArgumentAssertionError } from '@juisy/utils/assert/argsert';
7
+ import getByPointer from '@juisy/utils/json/get-by-pointer';
8
+ import { InvalidJSONPointerError } from '@juisy/utils/json/parse-pointer';
9
+
10
+ function hasValue(target, pointer) {
11
+ try {
12
+ getByPointer(target, pointer);
13
+ } catch (error) {
14
+ if (error instanceof ArgumentAssertionError || error instanceof InvalidJSONPointerError) throw error;
15
+ return false;
16
+ }
17
+ return true;
18
+ }
19
+
20
+ export { hasValue as default, hasValue };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @module json/parse-pointer
3
+ * @importTarget ./json/parse-pointer
4
+ * @remarks Code widely inspired from [json-pointer](https://www.npmjs.com/package/json-pointer) library
5
+ * @author Hervé Perchec
6
+ */
7
+ /**
8
+ * Class for invalid JSON pointer error
9
+ */
10
+ export declare class InvalidJSONPointerError extends Error {
11
+ }
12
+ /**
13
+ * Parse a JSON pointer ([RFC 6901](https://datatracker.ietf.org/doc/html/rfc6901#section-3))
14
+ * and returns an array of reference tokens.
15
+ * It supports pointer that starts with '#' (e.g. `#/internal/ref/example`).
16
+ * @param pointer - The JSON pointer as string
17
+ * @envCompat Browser
18
+ * @envCompat Node
19
+ * @example
20
+ * parsePointer('/a/0/b/c') // [ 'a', '0', 'b', 'c' ]
21
+ * parsePointer('#/a/0/b~0c') // [ 'a', '0', 'b~c' ]
22
+ * parsePointer('a/0') // Error
23
+ */
24
+ export declare function parsePointer(pointer: string): string[];
25
+ export default parsePointer;
@@ -0,0 +1,26 @@
1
+ /*!
2
+ * juisy v3.0.0-beta.3
3
+ * Copyright © 2022-Present Hervé Perchec
4
+ */
5
+
6
+ import argsert from '@juisy/utils/assert/argsert';
7
+ import unescapePointerSegment from '@juisy/utils/json/unescape-pointer-segment';
8
+
9
+ class InvalidJSONPointerError extends Error {
10
+ }
11
+ function parsePointer(pointer) {
12
+ argsert(pointer, "pointer", ["string", "string.nonBlank"]);
13
+ const _pointer = pointer.startsWith("#") ? pointer.slice(1) : pointer;
14
+ if (_pointer.charAt(0) !== "/") {
15
+ throw new InvalidJSONPointerError(`Invalid JSON pointer: "${_pointer}"`);
16
+ }
17
+ const tokens = _pointer.substring(1).split(/\//).map(unescapePointerSegment);
18
+ if (tokens.length > 1) {
19
+ if (tokens.includes("")) throw new InvalidJSONPointerError(`Invalid JSON pointer: "${_pointer}"`);
20
+ } else {
21
+ if (tokens[0].trim() === "") return [];
22
+ }
23
+ return tokens;
24
+ }
25
+
26
+ export { InvalidJSONPointerError, parsePointer as default, parsePointer };
@@ -0,0 +1,16 @@
1
+ import { JsonArray, JsonObject } from 'type-fest';
2
+ /**
3
+ * Removes an attribute from a JSON object based on the given pointer.
4
+ * It supports pointer that starts with '#' (e.g. `#/internal/ref/example`)
5
+ * @param target - The target object
6
+ * @param pointer - The pointer as string or array of reference tokens
7
+ * @envCompat Browser
8
+ * @envCompat Node
9
+ * @example
10
+ * const object = { 'a': [{ 'b': { 'c': 3 } }] }
11
+ * removeByPointer(object, '/a/0/b/c') // { 'a': [{ 'b': {} }] }
12
+ * removeByPointer(object, '#/a/0/b') // { 'a': [{}] }
13
+ * removeByPointer(object, [ 'a', 0 ]) // { 'a': [] }
14
+ */
15
+ export declare function removeByPointer(target: JsonArray | JsonObject, pointer: string | Array<string | number>): void;
16
+ export default removeByPointer;
@@ -0,0 +1,32 @@
1
+ /*!
2
+ * juisy v3.0.0-beta.3
3
+ * Copyright © 2022-Present Hervé Perchec
4
+ */
5
+
6
+ import { isArray } from '@juisy/utils/is/is';
7
+ import compilePointer from '@juisy/utils/json/compile-pointer';
8
+ import getByPointer from '@juisy/utils/json/get-by-pointer';
9
+ import parsePointer from '@juisy/utils/json/parse-pointer';
10
+
11
+ function removeByPointer(target, pointer) {
12
+ const tokens = isArray(pointer) ? pointer : parsePointer(pointer);
13
+ const finalToken = tokens[tokens.length - 1];
14
+ if (finalToken === void 0) {
15
+ throw new Error(`Invalid JSON pointer for remove: "${pointer}"`);
16
+ }
17
+ const parent = getByPointer(target, tokens.slice(0, -1));
18
+ if (typeof parent !== "object") {
19
+ throw new Error(`JSON pointer "${compilePointer(tokens.slice(0, -1))} is not an object`);
20
+ }
21
+ if (isArray(parent)) {
22
+ const index = +finalToken;
23
+ if (finalToken === "" && isNaN(index)) {
24
+ throw new Error(`Invalid array index: "${finalToken}"`);
25
+ }
26
+ Array.prototype.splice.call(parent, index, 1);
27
+ } else {
28
+ delete parent[finalToken];
29
+ }
30
+ }
31
+
32
+ export { removeByPointer as default, removeByPointer };
@@ -0,0 +1,17 @@
1
+ import { JsonValue, JsonArray, JsonObject } from 'type-fest';
2
+ /**
3
+ * Sets a value on a JSON object based on the given pointer.
4
+ * It supports pointer that starts with '#' (e.g. `#/internal/ref/example`)
5
+ * @param target - The target object
6
+ * @param pointer - The pointer as string or array of reference tokens
7
+ * @param value - The value to set
8
+ * @envCompat Browser
9
+ * @envCompat Node
10
+ * @example
11
+ * const object = { 'a': [] }
12
+ * setByPointer(object, '/a/0', { b: 'b' }) // { 'a': [ { 'b': 'b' } ] }
13
+ * setByPointer(object, '#/a/-', { c: 'c' }) // { 'a': [ { 'b': 'b' }, { 'c': 'c' } ] }
14
+ * setByPointer(object, '/foo/bar~0baz', 'oof') // { 'a': [ { 'b': 'b' }, { 'c': 'c' } ], 'foo': { 'bar~baz': 'oof' } }
15
+ */
16
+ export declare function setByPointer(target: JsonArray | JsonObject, pointer: string | Array<string | number>, value: JsonValue): void;
17
+ export default setByPointer;
@@ -0,0 +1,42 @@
1
+ /*!
2
+ * juisy v3.0.0-beta.3
3
+ * Copyright © 2022-Present Hervé Perchec
4
+ */
5
+
6
+ import { isArray } from '@juisy/utils/is/is';
7
+ import parsePointer from '@juisy/utils/json/parse-pointer';
8
+
9
+ function setByPointer(target, pointer, value) {
10
+ const tokens = isArray(pointer) ? pointer.map(String) : parsePointer(pointer);
11
+ let nextToken = tokens[0];
12
+ if (tokens.length === 0) {
13
+ throw Error(`Can't set the root object "/"`);
14
+ }
15
+ for (let i = 0; i < tokens.length - 1; ++i) {
16
+ let token = tokens[i];
17
+ if (typeof token !== "string" && typeof token !== "number") {
18
+ token = String(token);
19
+ }
20
+ if (token === "__proto__" || token === "constructor" || token === "prototype") {
21
+ continue;
22
+ }
23
+ if (token === "-" && isArray(target)) {
24
+ token = target.length;
25
+ }
26
+ nextToken = tokens[i + 1];
27
+ if (!(token in target)) {
28
+ if (nextToken.match(/^(\d+|-)$/)) {
29
+ target[token] = [];
30
+ } else {
31
+ target[token] = {};
32
+ }
33
+ }
34
+ target = target[token];
35
+ }
36
+ if (nextToken === "-" && isArray(target)) {
37
+ nextToken = target.length;
38
+ }
39
+ target[nextToken] = value;
40
+ }
41
+
42
+ export { setByPointer as default, setByPointer };
@@ -0,0 +1,13 @@
1
+ import { JsonValue, JsonObject, JsonArray } from 'type-fest';
2
+ /**
3
+ * Returns a (pointer -> value) dictionary for a JSON object
4
+ * @param target - The JSON object
5
+ * @param hash - Add the '#' prefix to pointer
6
+ * @envCompat Browser
7
+ * @envCompat Node
8
+ * @example
9
+ * const object = { a: [{ b: 1 }] }
10
+ * toPointersDictionary(object) // { '/a': [{ b: 1 }], '/a/0': { b: 1 }, '/a/0/b': 1 }
11
+ */
12
+ export declare function toPointersDictionary(target: JsonObject | JsonArray, hash?: boolean): Record<string, JsonValue>;
13
+ export default toPointersDictionary;
@@ -0,0 +1,16 @@
1
+ /*!
2
+ * juisy v3.0.0-beta.3
3
+ * Copyright © 2022-Present Hervé Perchec
4
+ */
5
+
6
+ import traverse from '@juisy/utils/json/traverse';
7
+
8
+ function toPointersDictionary(target, hash = false) {
9
+ const dictionary = {};
10
+ traverse(target, (key, value, pointer) => {
11
+ dictionary[pointer] = value;
12
+ }, hash);
13
+ return dictionary;
14
+ }
15
+
16
+ export { toPointersDictionary as default, toPointersDictionary };
@@ -0,0 +1,32 @@
1
+ import { JsonArray, JsonObject, JsonValue } from 'type-fest';
2
+ export type TraverseCallback = (
3
+ /**
4
+ * The key
5
+ */
6
+ key: string | number,
7
+ /**
8
+ * The value
9
+ */
10
+ value: JsonValue,
11
+ /**
12
+ * The JSON pointer ([RFC 6901](https://datatracker.ietf.org/doc/html/rfc6901#section-3))
13
+ */
14
+ pointer: string,
15
+ /**
16
+ * The parent object or array
17
+ */
18
+ parent: JsonObject | JsonArray) => void;
19
+ /**
20
+ * Traverse the given JSON object
21
+ * @param target - The JSON object
22
+ * @param callback - The callback to execute
23
+ * @param hash - Add the '#' prefix to pointer
24
+ * @envCompat Browser
25
+ * @envCompat Node
26
+ * @example
27
+ * traverse(jsonObj, (key, value, pointer, parent) => {
28
+ * console.log({ value, pointer })
29
+ * })
30
+ */
31
+ export declare function traverse(target: JsonObject | JsonArray, callback: TraverseCallback, hash?: boolean): void;
32
+ export default traverse;
@@ -0,0 +1,29 @@
1
+ /*!
2
+ * juisy v3.0.0-beta.3
3
+ * Copyright © 2022-Present Hervé Perchec
4
+ */
5
+
6
+ import argsert from '@juisy/utils/assert/argsert';
7
+ import compilePointer from '@juisy/utils/json/compile-pointer';
8
+
9
+ function traverse(target, callback, hash = false) {
10
+ argsert(target, "target", [
11
+ argsert.any(argsert.array, argsert.object)
12
+ ]);
13
+ argsert(callback, "callback", ["function"]);
14
+ const tokens = [];
15
+ const _traverse = (target2, cb) => {
16
+ if (typeof target2 === "object") {
17
+ for (const key in target2) {
18
+ tokens.push(key);
19
+ const value = target2[key];
20
+ cb(key, value, compilePointer(tokens, hash), target2);
21
+ _traverse(value, cb);
22
+ tokens.pop();
23
+ }
24
+ }
25
+ };
26
+ _traverse(target, callback);
27
+ }
28
+
29
+ export { traverse as default, traverse };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @module json/unescape-pointer-segment
3
+ * @importTarget ./json/unescape-pointer-segment
4
+ * @remarks Code widely inspired from [json-pointer](https://www.npmjs.com/package/json-pointer) library
5
+ * @author Hervé Perchec
6
+ */
7
+ /**
8
+ * Unescapes a pointer segment in compliance with [RFC 6901](https://datatracker.ietf.org/doc/html/rfc6901#section-3).
9
+ * It replaces `~1` & `~0` by `/` & `~`.
10
+ * @param escaped - The string to unescape
11
+ * @envCompat Browser
12
+ * @envCompat Node
13
+ * @example
14
+ * unescapePointerSegment('a~0b') // 'a~b'
15
+ * unescapePointerSegment('b~1c') // 'b/c'
16
+ */
17
+ export declare function unescapePointerSegment(escaped: string): string;
18
+ export default unescapePointerSegment;
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * juisy v3.0.0-beta.3
3
+ * Copyright © 2022-Present Hervé Perchec
4
+ */
5
+
6
+ import argsert from '@juisy/utils/assert/argsert';
7
+
8
+ function unescapePointerSegment(escaped) {
9
+ argsert(escaped, "escaped", ["string"]);
10
+ return escaped.replace(/~1/g, "/").replace(/~0/g, "~");
11
+ }
12
+
13
+ export { unescapePointerSegment as default, unescapePointerSegment };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -20,5 +20,6 @@
20
20
  * get(object, 'a[0].b.c') // 3
21
21
  * get(object, 'a[0].b.d', 'default') // 'default'
22
22
  */
23
- export declare function get(object: any, path: string | string[], defaultValue?: any): any;
23
+ export declare function get(object: any, // eslint-disable-line @typescript-eslint/no-explicit-any
24
+ path: string | Array<string | number | symbol>, defaultValue?: any): any;
24
25
  export default get;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @module path/strip-extension
3
+ * @importTarget ./path/strip-extension
4
+ * @author Hervé Perchec
5
+ */
6
+ /**
7
+ * Removes the file extension of the given path
8
+ * @param value - The target path
9
+ * @envCompat Node
10
+ * @example
11
+ * stripExtension('src/index.ts') // 'src/index'
12
+ * stripExtension('../src/index.ts') // '../src/index'
13
+ * stripExtension('C:\\a\\Win32\\Absolute\\path\\index.js') // 'C:\\a\\Win32\\Absolute\\path\\index'
14
+ * stripExtension('/a/posix/absolute/path/index.js') // '/a/posix/absolute/path/index'
15
+ */
16
+ export declare function stripExtension(value: string): string;
17
+ export default stripExtension;
@@ -0,0 +1,12 @@
1
+ /*!
2
+ * juisy v3.0.0-beta.3
3
+ * Copyright © 2022-Present Hervé Perchec
4
+ */
5
+
6
+ import path from 'node:path';
7
+
8
+ function stripExtension(value) {
9
+ return value.replace(new RegExp(path.extname(value) + "$"), "");
10
+ }
11
+
12
+ export { stripExtension as default, stripExtension };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v3.0.0-beta.1
2
+ * juisy v3.0.0-beta.3
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juisy/utils",
3
- "version": "3.0.0-beta.1",
3
+ "version": "3.0.0-beta.3",
4
4
  "description": "Juisy utils",
5
5
  "type": "module",
6
6
  "files": [
@@ -29,6 +29,10 @@
29
29
  "types": "./dist/is/*.d.ts",
30
30
  "import": "./dist/is/*.js"
31
31
  },
32
+ "./json/*": {
33
+ "types": "./dist/json/*.d.ts",
34
+ "import": "./dist/json/*.js"
35
+ },
32
36
  "./misc/*": {
33
37
  "types": "./dist/misc/*.d.ts",
34
38
  "import": "./dist/misc/*.js"
@@ -104,6 +108,7 @@
104
108
  "error-stack-parser": "^2.1.4",
105
109
  "fs-extra": "^11.2.0",
106
110
  "glob": "^11.0.0",
111
+ "juisy_utils.scoped_dayjs": "npm:dayjs@^1.11.21",
107
112
  "lodash.camelcase": "^4.3.0",
108
113
  "lodash.capitalize": "^4.2.1",
109
114
  "lodash.get": "^4.4.2",
@@ -115,7 +120,7 @@
115
120
  "lodash.uppercase": "^4.3.0",
116
121
  "ow": "^2.0.0",
117
122
  "pkg-dir": "^8.0.0",
118
- "juisy_utils_scoped_dayjs": "npm:dayjs@^1.11.21"
123
+ "type-fest": "^5.2.0"
119
124
  },
120
125
  "release-it": {
121
126
  "git": false