@duplojs/utils 1.4.46 → 1.4.48

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 (66) hide show
  1. package/dist/common/index.d.ts +2 -1
  2. package/dist/common/mimeType.cjs +1081 -0
  3. package/dist/common/mimeType.d.ts +22 -0
  4. package/dist/common/mimeType.mjs +1079 -0
  5. package/dist/common/path.cjs +114 -0
  6. package/dist/common/path.d.ts +145 -0
  7. package/dist/common/path.mjs +114 -0
  8. package/dist/dataParser/base.cjs +4 -0
  9. package/dist/dataParser/base.d.ts +34 -0
  10. package/dist/dataParser/base.mjs +4 -0
  11. package/dist/dataParser/extended/date.d.ts +3 -3
  12. package/dist/dataParser/extended/time.d.ts +3 -3
  13. package/dist/dataParser/identifier.d.ts +16 -4
  14. package/dist/dataParser/parsers/array/index.cjs +1 -0
  15. package/dist/dataParser/parsers/array/index.mjs +1 -0
  16. package/dist/dataParser/parsers/date.cjs +7 -7
  17. package/dist/dataParser/parsers/date.d.ts +4 -4
  18. package/dist/dataParser/parsers/date.mjs +7 -7
  19. package/dist/dataParser/parsers/lazy.cjs +1 -0
  20. package/dist/dataParser/parsers/lazy.mjs +1 -0
  21. package/dist/dataParser/parsers/nullable.cjs +1 -0
  22. package/dist/dataParser/parsers/nullable.mjs +1 -0
  23. package/dist/dataParser/parsers/object/index.cjs +2 -0
  24. package/dist/dataParser/parsers/object/index.mjs +2 -0
  25. package/dist/dataParser/parsers/optional.cjs +1 -0
  26. package/dist/dataParser/parsers/optional.mjs +1 -0
  27. package/dist/dataParser/parsers/pipe.cjs +1 -0
  28. package/dist/dataParser/parsers/pipe.mjs +1 -0
  29. package/dist/dataParser/parsers/record/index.cjs +1 -0
  30. package/dist/dataParser/parsers/record/index.mjs +1 -0
  31. package/dist/dataParser/parsers/recover.cjs +1 -0
  32. package/dist/dataParser/parsers/recover.mjs +1 -0
  33. package/dist/dataParser/parsers/time/index.cjs +8 -8
  34. package/dist/dataParser/parsers/time/index.d.ts +4 -4
  35. package/dist/dataParser/parsers/time/index.mjs +8 -8
  36. package/dist/dataParser/parsers/transform.cjs +1 -0
  37. package/dist/dataParser/parsers/transform.mjs +1 -0
  38. package/dist/dataParser/parsers/tuple.cjs +2 -0
  39. package/dist/dataParser/parsers/tuple.mjs +2 -0
  40. package/dist/dataParser/parsers/union.cjs +2 -0
  41. package/dist/dataParser/parsers/union.mjs +2 -0
  42. package/dist/index.cjs +7 -2
  43. package/dist/index.mjs +2 -2
  44. package/dist/metadata.json +18 -68
  45. package/package.json +1 -1
  46. package/dist/common/path/getBaseName.cjs +0 -25
  47. package/dist/common/path/getBaseName.d.ts +0 -26
  48. package/dist/common/path/getBaseName.mjs +0 -23
  49. package/dist/common/path/getExtensionName.cjs +0 -17
  50. package/dist/common/path/getExtensionName.d.ts +0 -21
  51. package/dist/common/path/getExtensionName.mjs +0 -15
  52. package/dist/common/path/getParentFolderPath.cjs +0 -21
  53. package/dist/common/path/getParentFolderPath.d.ts +0 -23
  54. package/dist/common/path/getParentFolderPath.mjs +0 -19
  55. package/dist/common/path/index.cjs +0 -19
  56. package/dist/common/path/index.d.ts +0 -27
  57. package/dist/common/path/index.mjs +0 -10
  58. package/dist/common/path/isAbsolute.cjs +0 -15
  59. package/dist/common/path/isAbsolute.d.ts +0 -21
  60. package/dist/common/path/isAbsolute.mjs +0 -13
  61. package/dist/common/path/resolveFrom.cjs +0 -18
  62. package/dist/common/path/resolveFrom.d.ts +0 -27
  63. package/dist/common/path/resolveFrom.mjs +0 -16
  64. package/dist/common/path/resolveRelative.cjs +0 -51
  65. package/dist/common/path/resolveRelative.d.ts +0 -23
  66. package/dist/common/path/resolveRelative.mjs +0 -49
@@ -11,7 +11,7 @@ export interface DataParserDefinitionDate extends DataParserDefinition<DataParse
11
11
  readonly coerce: boolean;
12
12
  }
13
13
  export declare const dateKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsDataParser/date", unknown>>;
14
- type _DataParserDate<GenericDefinition extends DataParserDefinitionDate> = (DataParser<GenericDefinition, TheDate, TheDate> & Kind<typeof dateKind.definition>);
14
+ type _DataParserDate<GenericDefinition extends DataParserDefinitionDate> = (DataParser<GenericDefinition, TheDate, TheDate | Date> & Kind<typeof dateKind.definition>);
15
15
  export interface DataParserDate<GenericDefinition extends DataParserDefinitionDate = DataParserDefinitionDate> extends _DataParserDate<GenericDefinition> {
16
16
  addChecker<GenericChecker extends readonly [
17
17
  DataParserDateCheckers,
@@ -22,17 +22,17 @@ export interface DataParserDate<GenericDefinition extends DataParserDefinitionDa
22
22
  ], GenericChecker>): DataParserDate<AddCheckersToDefinition<GenericDefinition, GenericChecker>>;
23
23
  }
24
24
  /**
25
- * Creates a data parser for TheDate values.
25
+ * Creates a data parser for TheDate values or native Date instances.
26
26
  *
27
27
  * **Supported call styles:**
28
28
  * - Classic: `DP.date(definition?)` -> returns a date parser
29
29
  * - Curried: not available
30
30
  *
31
- * Validates that the input is a TheDate, optionally applies coerce, and runs the configured checkers.
31
+ * Validates that the input is a TheDate (or a Date instance), optionally applies number/ISO string coercion, and runs the configured checkers.
32
32
  *
33
33
  * ```ts
34
34
  * const parser = DP.date();
35
- * const result = parser.parse("date0+");
35
+ * const result = parser.parse(new Date("2024-01-01T00:00:00.000Z"));
36
36
  * if (E.isRight(result)) {
37
37
  * const value = unwrap(result);
38
38
  * // value: TheDate
@@ -17,13 +17,6 @@ function date(definition) {
17
17
  coerce: definition?.coerce ?? false,
18
18
  }, (data, _error, self) => {
19
19
  if (self.definition.coerce) {
20
- if (data instanceof Date) {
21
- const timestamp = data.getTime();
22
- if (!isSafeTimestamp(timestamp)) {
23
- return SymbolDataParserErrorIssue;
24
- }
25
- return createTheDate(timestamp);
26
- }
27
20
  if (typeof data === "number") {
28
21
  if (!isSafeTimestamp(data)) {
29
22
  return SymbolDataParserErrorIssue;
@@ -41,6 +34,13 @@ function date(definition) {
41
34
  if (typeof data === "string" && is(data)) {
42
35
  return data;
43
36
  }
37
+ if (data instanceof Date) {
38
+ const timestamp = data.getTime();
39
+ if (!isSafeTimestamp(timestamp)) {
40
+ return SymbolDataParserErrorIssue;
41
+ }
42
+ return createTheDate(timestamp);
43
+ }
44
44
  return SymbolDataParserErrorIssue;
45
45
  }, date.overrideHandler);
46
46
  return self;
@@ -17,6 +17,7 @@ function lazy(getter, definition) {
17
17
  }, {
18
18
  sync: (data, _error, self) => self.definition.getter.value.exec(data, _error),
19
19
  async: (data, _error, self) => self.definition.getter.value.asyncExec(data, _error),
20
+ isAsynchronous: (self) => self.definition.getter.value.isAsynchronous(),
20
21
  }, lazy.overrideHandler);
21
22
  return self;
22
23
  }
@@ -15,6 +15,7 @@ function lazy(getter, definition) {
15
15
  }, {
16
16
  sync: (data, _error, self) => self.definition.getter.value.exec(data, _error),
17
17
  async: (data, _error, self) => self.definition.getter.value.asyncExec(data, _error),
18
+ isAsynchronous: (self) => self.definition.getter.value.isAsynchronous(),
18
19
  }, lazy.overrideHandler);
19
20
  return self;
20
21
  }
@@ -27,6 +27,7 @@ function nullable(inner, definition) {
27
27
  }
28
28
  return self.definition.inner.asyncExec(data, error);
29
29
  },
30
+ isAsynchronous: (self) => self.definition.inner.isAsynchronous(),
30
31
  }, nullable.overrideHandler);
31
32
  return self;
32
33
  }
@@ -25,6 +25,7 @@ function nullable(inner, definition) {
25
25
  }
26
26
  return self.definition.inner.asyncExec(data, error);
27
27
  },
28
+ isAsynchronous: (self) => self.definition.inner.isAsynchronous(),
28
29
  }, nullable.overrideHandler);
29
30
  return self;
30
31
  }
@@ -4,6 +4,7 @@ var base = require('../../base.cjs');
4
4
  var error = require('../../error.cjs');
5
5
  var kind = require('../../kind.cjs');
6
6
  var memo = require('../../../common/memo.cjs');
7
+ var some = require('../../../array/some.cjs');
7
8
  var pipe = require('../../../common/pipe.cjs');
8
9
  var map = require('../../../array/map.cjs');
9
10
  var filter = require('../../../array/filter.cjs');
@@ -69,6 +70,7 @@ function object(shape, definition) {
69
70
  void (self.definition.optimizedShape.value.length && error.popErrorPath(error$1));
70
71
  return output;
71
72
  },
73
+ isAsynchronous: (self) => some.some(self.definition.optimizedShape.value, (element) => element.value.isAsynchronous()),
72
74
  }, object.overrideHandler);
73
75
  return self;
74
76
  }
@@ -2,6 +2,7 @@ import { dataParserInit, SymbolDataParserError, dataParserKind } from '../../bas
2
2
  import { SymbolDataParserErrorIssue, setErrorPath, popErrorPath } from '../../error.mjs';
3
3
  import { createDataParserKind } from '../../kind.mjs';
4
4
  import { memo } from '../../../common/memo.mjs';
5
+ import { some } from '../../../array/some.mjs';
5
6
  import { pipe } from '../../../common/pipe.mjs';
6
7
  import { map } from '../../../array/map.mjs';
7
8
  import { filter } from '../../../array/filter.mjs';
@@ -67,6 +68,7 @@ function object(shape, definition) {
67
68
  void (self.definition.optimizedShape.value.length && popErrorPath(error));
68
69
  return output;
69
70
  },
71
+ isAsynchronous: (self) => some(self.definition.optimizedShape.value, (element) => element.value.isAsynchronous()),
70
72
  }, object.overrideHandler);
71
73
  return self;
72
74
  }
@@ -27,6 +27,7 @@ function optional(inner, definition) {
27
27
  }
28
28
  return self.definition.inner.asyncExec(data, error);
29
29
  },
30
+ isAsynchronous: (self) => self.definition.inner.isAsynchronous(),
30
31
  }, optional.overrideHandler);
31
32
  return self;
32
33
  }
@@ -25,6 +25,7 @@ function optional(inner, definition) {
25
25
  }
26
26
  return self.definition.inner.asyncExec(data, error);
27
27
  },
28
+ isAsynchronous: (self) => self.definition.inner.isAsynchronous(),
28
29
  }, optional.overrideHandler);
29
30
  return self;
30
31
  }
@@ -29,6 +29,7 @@ function pipe(input, output, definition) {
29
29
  }
30
30
  return self.definition.output.asyncExec(result, error);
31
31
  },
32
+ isAsynchronous: (self) => self.definition.input.isAsynchronous() || self.definition.output.isAsynchronous(),
32
33
  }, pipe.overrideHandler);
33
34
  return self;
34
35
  }
@@ -27,6 +27,7 @@ function pipe(input, output, definition) {
27
27
  }
28
28
  return self.definition.output.asyncExec(result, error);
29
29
  },
30
+ isAsynchronous: (self) => self.definition.input.isAsynchronous() || self.definition.output.isAsynchronous(),
30
31
  }, pipe.overrideHandler);
31
32
  return self;
32
33
  }
@@ -94,6 +94,7 @@ function record(key, value, definition) {
94
94
  }
95
95
  return output;
96
96
  },
97
+ isAsynchronous: (self) => self.definition.value.isAsynchronous(),
97
98
  }, record.overrideHandler);
98
99
  return self;
99
100
  }
@@ -93,6 +93,7 @@ function record(key, value, definition) {
93
93
  }
94
94
  return output;
95
95
  },
96
+ isAsynchronous: (self) => self.definition.value.isAsynchronous(),
96
97
  }, record.overrideHandler);
97
98
  return self;
98
99
  }
@@ -27,6 +27,7 @@ function recover(inner, recoveredValue, definition) {
27
27
  ? self.definition.recoveredValue
28
28
  : result;
29
29
  },
30
+ isAsynchronous: (self) => self.definition.inner.isAsynchronous(),
30
31
  }, recover.overrideHandler);
31
32
  return self;
32
33
  }
@@ -25,6 +25,7 @@ function recover(inner, recoveredValue, definition) {
25
25
  ? self.definition.recoveredValue
26
26
  : result;
27
27
  },
28
+ isAsynchronous: (self) => self.definition.inner.isAsynchronous(),
28
29
  }, recover.overrideHandler);
29
30
  return self;
30
31
  }
@@ -3,13 +3,13 @@
3
3
  var base = require('../../base.cjs');
4
4
  var error = require('../../error.cjs');
5
5
  var kind = require('../../kind.cjs');
6
- var isSafeTimeValue = require('../../../date/isSafeTimeValue.cjs');
7
- var createTheTime = require('../../../date/createTheTime.cjs');
8
6
  var constants = require('../../../date/constants.cjs');
9
7
  var createTime = require('../../../date/createTime.cjs');
10
8
  var is = require('../../../either/left/is.cjs');
11
9
  var unwrap = require('../../../common/unwrap.cjs');
12
10
  var isTime = require('../../../date/isTime.cjs');
11
+ var isSafeTimeValue = require('../../../date/isSafeTimeValue.cjs');
12
+ var createTheTime = require('../../../date/createTheTime.cjs');
13
13
  var override = require('../../../common/override.cjs');
14
14
 
15
15
  const timeKind = kind.createDataParserKind("time");
@@ -23,12 +23,6 @@ function time(definition) {
23
23
  coerce: definition?.coerce ?? false,
24
24
  }, (data, _error, self) => {
25
25
  if (self.definition.coerce) {
26
- if (typeof data === "number") {
27
- if (!isSafeTimeValue.isSafeTimeValue(data)) {
28
- return error.SymbolDataParserErrorIssue;
29
- }
30
- return createTheTime.createTheTime(data);
31
- }
32
26
  if (typeof data === "string" && constants.isoTimeRegex.test(data)) {
33
27
  const result = createTime.createTime({ value: data });
34
28
  if (is.isLeft(result)) {
@@ -40,6 +34,12 @@ function time(definition) {
40
34
  if (typeof data === "string" && isTime.isTime(data)) {
41
35
  return data;
42
36
  }
37
+ if (typeof data === "number") {
38
+ if (!isSafeTimeValue.isSafeTimeValue(data)) {
39
+ return error.SymbolDataParserErrorIssue;
40
+ }
41
+ return createTheTime.createTheTime(data);
42
+ }
43
43
  return error.SymbolDataParserErrorIssue;
44
44
  }, time.overrideHandler);
45
45
  return self;
@@ -13,7 +13,7 @@ export interface DataParserDefinitionTime extends DataParserDefinition<DataParse
13
13
  readonly coerce: boolean;
14
14
  }
15
15
  export declare const timeKind: import("../../../common").KindHandler<import("../../../common").KindDefinition<"@DuplojsUtilsDataParser/time", unknown>>;
16
- type _DataParserTime<GenericDefinition extends DataParserDefinitionTime> = (DataParser<GenericDefinition, TheTime, TheTime> & Kind<typeof timeKind.definition>);
16
+ type _DataParserTime<GenericDefinition extends DataParserDefinitionTime> = (DataParser<GenericDefinition, TheTime, TheTime | number> & Kind<typeof timeKind.definition>);
17
17
  export interface DataParserTime<GenericDefinition extends DataParserDefinitionTime = DataParserDefinitionTime> extends _DataParserTime<GenericDefinition> {
18
18
  addChecker<GenericChecker extends readonly [
19
19
  DataParserTimeCheckers,
@@ -24,17 +24,17 @@ export interface DataParserTime<GenericDefinition extends DataParserDefinitionTi
24
24
  ], GenericChecker>): DataParserTime<AddCheckersToDefinition<GenericDefinition, GenericChecker>>;
25
25
  }
26
26
  /**
27
- * Creates a data parser for TheTime values.
27
+ * Creates a data parser for TheTime values or safe millisecond numbers.
28
28
  *
29
29
  * **Supported call styles:**
30
30
  * - Classic: `DP.time(definition?)` -> returns a time parser
31
31
  * - Curried: not available
32
32
  *
33
- * Validates that the input is a TheTime, optionally applies coerce, and runs the configured checkers.
33
+ * Validates that the input is a TheTime (or a safe millisecond number), optionally applies ISO string coercion, and runs the configured checkers.
34
34
  *
35
35
  * ```ts
36
36
  * const parser = DP.time();
37
- * const result = parser.parse("time0+");
37
+ * const result = parser.parse(60000);
38
38
  * if (E.isRight(result)) {
39
39
  * const value = unwrap(result);
40
40
  * // value: TheTime
@@ -1,13 +1,13 @@
1
1
  import { dataParserInit } from '../../base.mjs';
2
2
  import { SymbolDataParserErrorIssue } from '../../error.mjs';
3
3
  import { createDataParserKind } from '../../kind.mjs';
4
- import { isSafeTimeValue } from '../../../date/isSafeTimeValue.mjs';
5
- import { createTheTime } from '../../../date/createTheTime.mjs';
6
4
  import { isoTimeRegex } from '../../../date/constants.mjs';
7
5
  import { createTime } from '../../../date/createTime.mjs';
8
6
  import { isLeft } from '../../../either/left/is.mjs';
9
7
  import { unwrap } from '../../../common/unwrap.mjs';
10
8
  import { isTime } from '../../../date/isTime.mjs';
9
+ import { isSafeTimeValue } from '../../../date/isSafeTimeValue.mjs';
10
+ import { createTheTime } from '../../../date/createTheTime.mjs';
11
11
  import { createOverride } from '../../../common/override.mjs';
12
12
 
13
13
  const timeKind = createDataParserKind("time");
@@ -21,12 +21,6 @@ function time(definition) {
21
21
  coerce: definition?.coerce ?? false,
22
22
  }, (data, _error, self) => {
23
23
  if (self.definition.coerce) {
24
- if (typeof data === "number") {
25
- if (!isSafeTimeValue(data)) {
26
- return SymbolDataParserErrorIssue;
27
- }
28
- return createTheTime(data);
29
- }
30
24
  if (typeof data === "string" && isoTimeRegex.test(data)) {
31
25
  const result = createTime({ value: data });
32
26
  if (isLeft(result)) {
@@ -38,6 +32,12 @@ function time(definition) {
38
32
  if (typeof data === "string" && isTime(data)) {
39
33
  return data;
40
34
  }
35
+ if (typeof data === "number") {
36
+ if (!isSafeTimeValue(data)) {
37
+ return SymbolDataParserErrorIssue;
38
+ }
39
+ return createTheTime(data);
40
+ }
41
41
  return SymbolDataParserErrorIssue;
42
42
  }, time.overrideHandler);
43
43
  return self;
@@ -38,6 +38,7 @@ function transform(inner, theFunction, definition) {
38
38
  }
39
39
  return result;
40
40
  },
41
+ isAsynchronous: (self) => self.definition.theFunction.constructor.name === "AsyncFunction",
41
42
  }, transform.overrideHandler);
42
43
  return self;
43
44
  }
@@ -36,6 +36,7 @@ function transform(inner, theFunction, definition) {
36
36
  }
37
37
  return result;
38
38
  },
39
+ isAsynchronous: (self) => self.definition.theFunction.constructor.name === "AsyncFunction",
39
40
  }, transform.overrideHandler);
40
41
  return self;
41
42
  }
@@ -3,6 +3,7 @@
3
3
  var base = require('../base.cjs');
4
4
  var error = require('../error.cjs');
5
5
  var kind = require('../kind.cjs');
6
+ var some = require('../../array/some.cjs');
6
7
  var override = require('../../common/override.cjs');
7
8
 
8
9
  const tupleKind = kind.createDataParserKind("tuple");
@@ -78,6 +79,7 @@ function tuple(shape, definition) {
78
79
  void (self.definition.shape.length && error.popErrorPath(error$1));
79
80
  return output;
80
81
  },
82
+ isAsynchronous: (self) => some.some(self.definition.shape, (element) => element.isAsynchronous()) || !!self.definition.rest?.isAsynchronous(),
81
83
  }, tuple.overrideHandler);
82
84
  return self;
83
85
  }
@@ -1,6 +1,7 @@
1
1
  import { dataParserInit, SymbolDataParserError } from '../base.mjs';
2
2
  import { SymbolDataParserErrorIssue, setErrorPath, popErrorPath } from '../error.mjs';
3
3
  import { createDataParserKind } from '../kind.mjs';
4
+ import { some } from '../../array/some.mjs';
4
5
  import { createOverride } from '../../common/override.mjs';
5
6
 
6
7
  const tupleKind = createDataParserKind("tuple");
@@ -76,6 +77,7 @@ function tuple(shape, definition) {
76
77
  void (self.definition.shape.length && popErrorPath(error));
77
78
  return output;
78
79
  },
80
+ isAsynchronous: (self) => some(self.definition.shape, (element) => element.isAsynchronous()) || !!self.definition.rest?.isAsynchronous(),
79
81
  }, tuple.overrideHandler);
80
82
  return self;
81
83
  }
@@ -3,6 +3,7 @@
3
3
  var base = require('../base.cjs');
4
4
  var error = require('../error.cjs');
5
5
  var kind = require('../kind.cjs');
6
+ var some = require('../../array/some.cjs');
6
7
  var override = require('../../common/override.cjs');
7
8
 
8
9
  const unionKind = kind.createDataParserKind("union");
@@ -33,6 +34,7 @@ function union(options, definition) {
33
34
  }
34
35
  return error.SymbolDataParserErrorIssue;
35
36
  },
37
+ isAsynchronous: (self) => some.some(self.definition.options, (element) => element.isAsynchronous()),
36
38
  }, union.overrideHandler);
37
39
  return self;
38
40
  }
@@ -1,6 +1,7 @@
1
1
  import { dataParserInit, SymbolDataParserError } from '../base.mjs';
2
2
  import { SymbolDataParserErrorIssue } from '../error.mjs';
3
3
  import { createDataParserKind } from '../kind.mjs';
4
+ import { some } from '../../array/some.mjs';
4
5
  import { createOverride } from '../../common/override.mjs';
5
6
 
6
7
  const unionKind = createDataParserKind("union");
@@ -31,6 +32,7 @@ function union(options, definition) {
31
32
  }
32
33
  return SymbolDataParserErrorIssue;
33
34
  },
35
+ isAsynchronous: (self) => some(self.definition.options, (element) => element.isAsynchronous()),
34
36
  }, union.overrideHandler);
35
37
  return self;
36
38
  }
package/dist/index.cjs CHANGED
@@ -12,7 +12,6 @@ var index$8 = require('./dataParser/parsers/coerce/index.cjs');
12
12
  var index$9 = require('./dataParser/extended/index.cjs');
13
13
  var index$a = require('./date/index.cjs');
14
14
  var index$b = require('./clean/index.cjs');
15
- var index$c = require('./common/path/index.cjs');
16
15
  var addWrappedProperties = require('./common/addWrappedProperties.cjs');
17
16
  var asyncPipe = require('./common/asyncPipe.cjs');
18
17
  var clone = require('./common/clone.cjs');
@@ -26,6 +25,7 @@ var promiseObject = require('./common/promiseObject.cjs');
26
25
  var simpleClone = require('./common/simpleClone.cjs');
27
26
  var sleep = require('./common/sleep.cjs');
28
27
  var stringToBytes = require('./common/stringToBytes.cjs');
28
+ var mimeType = require('./common/mimeType.cjs');
29
29
  var stringToMillisecond = require('./common/stringToMillisecond.cjs');
30
30
  var toJSON = require('./common/toJSON.cjs');
31
31
  var toTransform = require('./common/toTransform.cjs');
@@ -62,6 +62,7 @@ var hasKinds = require('./common/hasKinds.cjs');
62
62
  var toCurriedPredicate = require('./common/toCurriedPredicate.cjs');
63
63
  var pipeCall = require('./common/pipeCall.cjs');
64
64
  var asserts = require('./common/asserts.cjs');
65
+ var path = require('./common/path.cjs');
65
66
 
66
67
 
67
68
 
@@ -89,7 +90,6 @@ exports.D = index$a;
89
90
  exports.DDate = index$a;
90
91
  exports.C = index$b;
91
92
  exports.DClean = index$b;
92
- exports.Path = index$c;
93
93
  exports.addWrappedProperties = addWrappedProperties.addWrappedProperties;
94
94
  exports.asyncPipe = asyncPipe.asyncPipe;
95
95
  exports.clone = clone.clone;
@@ -108,6 +108,7 @@ exports.simpleClone = simpleClone.simpleClone;
108
108
  exports.sleep = sleep.sleep;
109
109
  exports.InvalidBytesInStringError = stringToBytes.InvalidBytesInStringError;
110
110
  exports.stringToBytes = stringToBytes.stringToBytes;
111
+ exports.mimeType = mimeType.mimeType;
111
112
  exports.InvalidMillisecondInStringError = stringToMillisecond.InvalidMillisecondInStringError;
112
113
  exports.stringToMillisecond = stringToMillisecond.stringToMillisecond;
113
114
  exports.toJSON = toJSON.toJSON;
@@ -152,3 +153,7 @@ exports.toCurriedPredicate = toCurriedPredicate.toCurriedPredicate;
152
153
  exports.pipeCall = pipeCall.pipeCall;
153
154
  exports.AssertsError = asserts.AssertsError;
154
155
  exports.asserts = asserts.asserts;
156
+ Object.defineProperty(exports, "Path", {
157
+ enumerable: true,
158
+ get: function () { return path.Path; }
159
+ });
package/dist/index.mjs CHANGED
@@ -34,8 +34,6 @@ export { index$a as DDate };
34
34
  import * as index$b from './clean/index.mjs';
35
35
  export { index$b as C };
36
36
  export { index$b as DClean };
37
- import * as index$c from './common/path/index.mjs';
38
- export { index$c as Path };
39
37
  export { addWrappedProperties } from './common/addWrappedProperties.mjs';
40
38
  export { asyncPipe } from './common/asyncPipe.mjs';
41
39
  export { clone } from './common/clone.mjs';
@@ -49,6 +47,7 @@ export { promiseObject } from './common/promiseObject.mjs';
49
47
  export { simpleClone } from './common/simpleClone.mjs';
50
48
  export { sleep } from './common/sleep.mjs';
51
49
  export { InvalidBytesInStringError, stringToBytes } from './common/stringToBytes.mjs';
50
+ export { mimeType } from './common/mimeType.mjs';
52
51
  export { InvalidMillisecondInStringError, stringToMillisecond } from './common/stringToMillisecond.mjs';
53
52
  export { toJSON } from './common/toJSON.mjs';
54
53
  export { toTransform } from './common/toTransform.mjs';
@@ -85,3 +84,4 @@ export { hasKinds } from './common/hasKinds.mjs';
85
84
  export { toCurriedPredicate } from './common/toCurriedPredicate.mjs';
86
85
  export { pipeCall } from './common/pipeCall.mjs';
87
86
  export { AssertsError, asserts } from './common/asserts.mjs';
87
+ export { Path } from './common/path.mjs';
@@ -999,74 +999,6 @@
999
999
  {
1000
1000
  "name": "common",
1001
1001
  "files": [
1002
- {
1003
- "name": "path",
1004
- "files": [
1005
- {
1006
- "name": "getBaseName.cjs"
1007
- },
1008
- {
1009
- "name": "getBaseName.d.ts"
1010
- },
1011
- {
1012
- "name": "getBaseName.mjs"
1013
- },
1014
- {
1015
- "name": "getExtensionName.cjs"
1016
- },
1017
- {
1018
- "name": "getExtensionName.d.ts"
1019
- },
1020
- {
1021
- "name": "getExtensionName.mjs"
1022
- },
1023
- {
1024
- "name": "getParentFolderPath.cjs"
1025
- },
1026
- {
1027
- "name": "getParentFolderPath.d.ts"
1028
- },
1029
- {
1030
- "name": "getParentFolderPath.mjs"
1031
- },
1032
- {
1033
- "name": "index.cjs"
1034
- },
1035
- {
1036
- "name": "index.d.ts"
1037
- },
1038
- {
1039
- "name": "index.mjs"
1040
- },
1041
- {
1042
- "name": "isAbsolute.cjs"
1043
- },
1044
- {
1045
- "name": "isAbsolute.d.ts"
1046
- },
1047
- {
1048
- "name": "isAbsolute.mjs"
1049
- },
1050
- {
1051
- "name": "resolveFrom.cjs"
1052
- },
1053
- {
1054
- "name": "resolveFrom.d.ts"
1055
- },
1056
- {
1057
- "name": "resolveFrom.mjs"
1058
- },
1059
- {
1060
- "name": "resolveRelative.cjs"
1061
- },
1062
- {
1063
- "name": "resolveRelative.d.ts"
1064
- },
1065
- {
1066
- "name": "resolveRelative.mjs"
1067
- }
1068
- ]
1069
- },
1070
1002
  {
1071
1003
  "name": "types",
1072
1004
  "files": [
@@ -1483,6 +1415,15 @@
1483
1415
  {
1484
1416
  "name": "memo.mjs"
1485
1417
  },
1418
+ {
1419
+ "name": "mimeType.cjs"
1420
+ },
1421
+ {
1422
+ "name": "mimeType.d.ts"
1423
+ },
1424
+ {
1425
+ "name": "mimeType.mjs"
1426
+ },
1486
1427
  {
1487
1428
  "name": "or.cjs"
1488
1429
  },
@@ -1501,6 +1442,15 @@
1501
1442
  {
1502
1443
  "name": "override.mjs"
1503
1444
  },
1445
+ {
1446
+ "name": "path.cjs"
1447
+ },
1448
+ {
1449
+ "name": "path.d.ts"
1450
+ },
1451
+ {
1452
+ "name": "path.mjs"
1453
+ },
1504
1454
  {
1505
1455
  "name": "pipe.cjs"
1506
1456
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duplojs/utils",
3
- "version": "1.4.46",
3
+ "version": "1.4.48",
4
4
  "author": {
5
5
  "name": "mathcovax",
6
6
  "url": "https://github.com/mathcovax"
@@ -1,25 +0,0 @@
1
- 'use strict';
2
-
3
- var split = require('../../string/split.cjs');
4
- var findLast = require('../../array/findLast.cjs');
5
- var length = require('../../string/length.cjs');
6
- var endsWith = require('../../string/endsWith.cjs');
7
- var slice = require('../../string/slice.cjs');
8
-
9
- /**
10
- * {@include common/path/getBaseName/index.md}
11
- */
12
- function getBaseName(path, params) {
13
- const segments = split.split(path, "/");
14
- const lastSegment = findLast.findLast(segments, (value) => length.length(value) > 0) ?? null;
15
- if (!lastSegment || lastSegment === "..") {
16
- return null;
17
- }
18
- if (params?.extension && endsWith.endsWith(lastSegment, params?.extension)) {
19
- const extensionLength = length.length(params.extension);
20
- return slice.slice(lastSegment, 0, -extensionLength);
21
- }
22
- return lastSegment;
23
- }
24
-
25
- exports.getBaseName = getBaseName;
@@ -1,26 +0,0 @@
1
- interface GetBaseNameParams {
2
- extension?: string;
3
- }
4
- /**
5
- * Returns the last non-empty segment of a path, optionally without an extension.
6
- *
7
- * **Supported call styles:**
8
- * - Classic: `getBaseName(path, params?)` -> returns the base name or null
9
- *
10
- * It ignores trailing slashes and returns null when the path has no segment or when the last segment is `..`.
11
- * When an extension is provided, it is removed only if it matches the end of the base name.
12
- *
13
- * ```ts
14
- * const defaultResult = Path.getBaseName("/foo/bar.txt");
15
- * // defaultResult: "bar.txt"
16
- * const withoutExtResult = Path.getBaseName("/foo/bar.txt", { extension: ".txt" });
17
- * // withoutExtResult: "bar"
18
- * const nullResult = Path.getBaseName("..");
19
- * // nullResult: null
20
- * ```
21
- *
22
- * @see https://utils.duplojs.dev/en/v1/api/common/path/getBaseName
23
- *
24
- */
25
- export declare function getBaseName<GenericPath extends string>(path: GenericPath, params?: GetBaseNameParams): string | null;
26
- export {};