@duplojs/utils 1.3.21 → 1.3.22

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 (53) hide show
  1. package/README.md +21 -1
  2. package/dist/array/index.cjs +3 -0
  3. package/dist/array/index.d.ts +1 -0
  4. package/dist/array/index.mjs +1 -0
  5. package/dist/array/select.cjs +35 -0
  6. package/dist/array/select.d.ts +18 -0
  7. package/dist/array/select.mjs +32 -0
  8. package/dist/clean/constraint/base.d.ts +1 -1
  9. package/dist/clean/constraint/defaultConstraint/number.d.ts +4 -4
  10. package/dist/clean/constraint/defaultConstraint/string.d.ts +3 -3
  11. package/dist/clean/entity.cjs +4 -0
  12. package/dist/clean/entity.d.ts +1 -0
  13. package/dist/clean/entity.mjs +4 -0
  14. package/dist/clean/flag.d.ts +1 -0
  15. package/dist/clean/repository.d.ts +4 -4
  16. package/dist/clean/useCase.cjs +4 -3
  17. package/dist/clean/useCase.d.ts +2 -2
  18. package/dist/clean/useCase.mjs +4 -3
  19. package/dist/common/index.d.ts +1 -1
  20. package/dist/common/{toJson.d.ts → toJSON.d.ts} +1 -1
  21. package/dist/dataParser/extended/object.cjs +16 -4
  22. package/dist/dataParser/extended/object.d.ts +13 -5
  23. package/dist/dataParser/extended/object.mjs +20 -8
  24. package/dist/dataParser/identifier.d.ts +2 -2
  25. package/dist/dataParser/index.cjs +4 -0
  26. package/dist/dataParser/index.mjs +4 -4
  27. package/dist/dataParser/parsers/array/index.d.ts +1 -1
  28. package/dist/dataParser/parsers/object/omit.cjs +5 -1
  29. package/dist/dataParser/parsers/object/omit.d.ts +2 -1
  30. package/dist/dataParser/parsers/object/omit.mjs +5 -2
  31. package/dist/dataParser/parsers/object/partial.cjs +5 -1
  32. package/dist/dataParser/parsers/object/partial.d.ts +1 -0
  33. package/dist/dataParser/parsers/object/partial.mjs +5 -2
  34. package/dist/dataParser/parsers/object/pick.cjs +6 -2
  35. package/dist/dataParser/parsers/object/pick.d.ts +3 -2
  36. package/dist/dataParser/parsers/object/pick.mjs +6 -3
  37. package/dist/dataParser/parsers/object/required.cjs +5 -1
  38. package/dist/dataParser/parsers/object/required.d.ts +1 -0
  39. package/dist/dataParser/parsers/object/required.mjs +5 -2
  40. package/dist/dataParser/parsers/refine.cjs +1 -1
  41. package/dist/dataParser/parsers/refine.d.ts +1 -1
  42. package/dist/dataParser/parsers/refine.mjs +1 -1
  43. package/dist/either/future/create.d.ts +1 -1
  44. package/dist/index.cjs +2 -2
  45. package/dist/index.mjs +1 -1
  46. package/dist/metadata.json +4419 -0
  47. package/dist/string/capitalize.cjs +1 -1
  48. package/dist/string/capitalize.mjs +1 -1
  49. package/dist/string/uncapitalize.cjs +1 -1
  50. package/dist/string/uncapitalize.mjs +1 -1
  51. package/package.json +37 -5
  52. /package/dist/common/{toJson.cjs → toJSON.cjs} +0 -0
  53. /package/dist/common/{toJson.mjs → toJSON.mjs} +0 -0
@@ -1,6 +1,7 @@
1
1
  import { type MergeDefinition } from "../../../dataParser/types";
2
- import { type DataParserDefinitionObject, type DataParserObject } from ".";
2
+ import { type DataParserObjectShape, type DataParserDefinitionObject, type DataParserObject } from ".";
3
3
  import { type SimplifyTopLevel, type NeverCoalescing } from "../../../common";
4
+ export declare function omitShape(shape: DataParserObjectShape, omitObject: Partial<Record<string, true>>): DataParserObjectShape;
4
5
  export declare function omit<GenericDataParserObject extends DataParserObject, const GenericOmitObject extends Partial<Record<keyof GenericDataParserObject["definition"]["shape"], true>>, const GenericDefinition extends Partial<Omit<DataParserDefinitionObject, "shape" | "optimizedShape">> = never>(dataParser: GenericDataParserObject, omitObject: GenericOmitObject, definition?: GenericDefinition): DataParserObject<MergeDefinition<DataParserDefinitionObject, NeverCoalescing<GenericDefinition, {}> & {
5
6
  readonly shape: SimplifyTopLevel<Omit<GenericDataParserObject["definition"]["shape"], keyof GenericOmitObject>>;
6
7
  }>>;
@@ -5,9 +5,12 @@ import { isKeyof } from '../../../string/isKeyof.mjs';
5
5
  import { entries } from '../../../object/entries.mjs';
6
6
  import { fromEntries } from '../../../object/fromEntries.mjs';
7
7
 
8
+ function omitShape(shape, omitObject) {
9
+ return pipe(shape, entries, filter(([key]) => !isKeyof(key, omitObject)), fromEntries);
10
+ }
8
11
  function omit(dataParser, omitObject, definition) {
9
- const newShape = pipe(dataParser.definition.shape, entries, filter(([key]) => !isKeyof(key, omitObject)), fromEntries);
12
+ const newShape = omitShape(dataParser.definition.shape, omitObject);
10
13
  return object(newShape, definition);
11
14
  }
12
15
 
13
- export { omit };
16
+ export { omit, omitShape };
@@ -12,9 +12,13 @@ var entry = require('../../../object/entry.cjs');
12
12
  var entries = require('../../../object/entries.cjs');
13
13
  var fromEntries = require('../../../object/fromEntries.cjs');
14
14
 
15
+ function partialShape(shape) {
16
+ return pipe.pipe(shape, entries.entries, map.map(([key, dataParser]) => pipe.pipe(identifier.identifier(dataParser, optional.optionalKind), when.whenIsRight(forward.forward), when$1.whenIsLeft(optional.optional), (dataParser) => entry.entry(key, dataParser))), fromEntries.fromEntries);
17
+ }
15
18
  function partial(dataParser, definition) {
16
- const newShape = pipe.pipe(dataParser.definition.shape, entries.entries, map.map(([key, dataParser]) => pipe.pipe(identifier.identifier(dataParser, optional.optionalKind), when.whenIsRight(forward.forward), when$1.whenIsLeft(optional.optional), (dataParser) => entry.entry(key, dataParser))), fromEntries.fromEntries);
19
+ const newShape = partialShape(dataParser.definition.shape);
17
20
  return index.object(newShape, definition);
18
21
  }
19
22
 
20
23
  exports.partial = partial;
24
+ exports.partialShape = partialShape;
@@ -9,6 +9,7 @@ export type PartialDataParserObject<GenericShape extends DataParserObjectShape>
9
9
  coalescingValue: unknown;
10
10
  }>;
11
11
  }>;
12
+ export declare function partialShape(shape: DataParserObjectShape): DataParserObjectShape;
12
13
  export declare function partial<GenericDataParserObject extends DataParserObject, const GenericDefinition extends Partial<Omit<DataParserDefinitionObject, "shape" | "optimizedShape">> = never>(dataParser: GenericDataParserObject, definition?: GenericDefinition): DataParserObject<MergeDefinition<DataParserDefinitionObject, NeverCoalescing<GenericDefinition, {}> & {
13
14
  readonly shape: PartialDataParserObject<GenericDataParserObject["definition"]["shape"]>;
14
15
  }>>;
@@ -10,9 +10,12 @@ import { entry } from '../../../object/entry.mjs';
10
10
  import { entries } from '../../../object/entries.mjs';
11
11
  import { fromEntries } from '../../../object/fromEntries.mjs';
12
12
 
13
+ function partialShape(shape) {
14
+ return pipe(shape, entries, map(([key, dataParser]) => pipe(identifier(dataParser, optionalKind), whenIsRight(forward), whenIsLeft(optional), (dataParser) => entry(key, dataParser))), fromEntries);
15
+ }
13
16
  function partial(dataParser, definition) {
14
- const newShape = pipe(dataParser.definition.shape, entries, map(([key, dataParser]) => pipe(identifier(dataParser, optionalKind), whenIsRight(forward), whenIsLeft(optional), (dataParser) => entry(key, dataParser))), fromEntries);
17
+ const newShape = partialShape(dataParser.definition.shape);
15
18
  return object(newShape, definition);
16
19
  }
17
20
 
18
- export { partial };
21
+ export { partial, partialShape };
@@ -7,9 +7,13 @@ var isKeyof = require('../../../string/isKeyof.cjs');
7
7
  var entries = require('../../../object/entries.cjs');
8
8
  var fromEntries = require('../../../object/fromEntries.cjs');
9
9
 
10
- function pick(dataParser, omitObject, definition) {
11
- const newShape = pipe.pipe(dataParser.definition.shape, entries.entries, filter.filter(([key]) => isKeyof.isKeyof(key, omitObject)), fromEntries.fromEntries);
10
+ function pickShape(shape, pickObject) {
11
+ return pipe.pipe(shape, entries.entries, filter.filter(([key]) => isKeyof.isKeyof(key, pickObject)), fromEntries.fromEntries);
12
+ }
13
+ function pick(dataParser, pickObject, definition) {
14
+ const newShape = pickShape(dataParser.definition.shape, pickObject);
12
15
  return index.object(newShape, definition);
13
16
  }
14
17
 
15
18
  exports.pick = pick;
19
+ exports.pickShape = pickShape;
@@ -1,6 +1,7 @@
1
1
  import { type MergeDefinition } from "../../../dataParser/types";
2
- import { type DataParserDefinitionObject, type DataParserObject } from ".";
2
+ import { type DataParserObjectShape, type DataParserDefinitionObject, type DataParserObject } from ".";
3
3
  import { type SimplifyTopLevel, type NeverCoalescing, type Adaptor } from "../../../common";
4
- export declare function pick<GenericDataParserObject extends DataParserObject, const GenericOmitObject extends Partial<Record<keyof GenericDataParserObject["definition"]["shape"], true>>, const GenericDefinition extends Partial<Omit<DataParserDefinitionObject, "shape" | "optimizedShape">> = never>(dataParser: GenericDataParserObject, omitObject: GenericOmitObject, definition?: GenericDefinition): DataParserObject<MergeDefinition<DataParserDefinitionObject, NeverCoalescing<GenericDefinition, {}> & {
4
+ export declare function pickShape(shape: DataParserObjectShape, pickObject: Partial<Record<string, true>>): DataParserObjectShape;
5
+ export declare function pick<GenericDataParserObject extends DataParserObject, const GenericOmitObject extends Partial<Record<keyof GenericDataParserObject["definition"]["shape"], true>>, const GenericDefinition extends Partial<Omit<DataParserDefinitionObject, "shape" | "optimizedShape">> = never>(dataParser: GenericDataParserObject, pickObject: GenericOmitObject, definition?: GenericDefinition): DataParserObject<MergeDefinition<DataParserDefinitionObject, NeverCoalescing<GenericDefinition, {}> & {
5
6
  readonly shape: SimplifyTopLevel<Pick<GenericDataParserObject["definition"]["shape"], Adaptor<keyof GenericOmitObject, keyof GenericDataParserObject["definition"]["shape"]>>>;
6
7
  }>>;
@@ -5,9 +5,12 @@ import { isKeyof } from '../../../string/isKeyof.mjs';
5
5
  import { entries } from '../../../object/entries.mjs';
6
6
  import { fromEntries } from '../../../object/fromEntries.mjs';
7
7
 
8
- function pick(dataParser, omitObject, definition) {
9
- const newShape = pipe(dataParser.definition.shape, entries, filter(([key]) => isKeyof(key, omitObject)), fromEntries);
8
+ function pickShape(shape, pickObject) {
9
+ return pipe(shape, entries, filter(([key]) => isKeyof(key, pickObject)), fromEntries);
10
+ }
11
+ function pick(dataParser, pickObject, definition) {
12
+ const newShape = pickShape(dataParser.definition.shape, pickObject);
10
13
  return object(newShape, definition);
11
14
  }
12
15
 
13
- export { pick };
16
+ export { pick, pickShape };
@@ -12,9 +12,13 @@ var entry = require('../../../object/entry.cjs');
12
12
  var entries = require('../../../object/entries.cjs');
13
13
  var fromEntries = require('../../../object/fromEntries.cjs');
14
14
 
15
+ function requiredShape(shape) {
16
+ return pipe.pipe(shape, entries.entries, map.map(([key, dataParser]) => pipe.pipe(identifier.identifier(dataParser, optional.optionalKind), when.whenIsRight((dataParser) => dataParser.definition.inner), when$1.whenIsLeft(forward.forward), (dataParser) => entry.entry(key, dataParser))), fromEntries.fromEntries);
17
+ }
15
18
  function required(dataParser, definition) {
16
- const newShape = pipe.pipe(dataParser.definition.shape, entries.entries, map.map(([key, dataParser]) => pipe.pipe(identifier.identifier(dataParser, optional.optionalKind), when.whenIsRight((dataParser) => dataParser.definition.inner), when$1.whenIsLeft(forward.forward), (dataParser) => entry.entry(key, dataParser))), fromEntries.fromEntries);
19
+ const newShape = requiredShape(dataParser.definition.shape);
17
20
  return index.object(newShape, definition);
18
21
  }
19
22
 
20
23
  exports.required = required;
24
+ exports.requiredShape = requiredShape;
@@ -5,6 +5,7 @@ import { type DataParserOptional } from "../optional";
5
5
  export type RequireDataParserObject<GenericShape extends DataParserObjectShape> = SimplifyTopLevel<{
6
6
  [Prop in keyof GenericShape]: GenericShape[Prop] extends DataParserOptional<any> ? GenericShape[Prop]["definition"]["inner"] : GenericShape[Prop];
7
7
  }>;
8
+ export declare function requiredShape(shape: DataParserObjectShape): DataParserObjectShape;
8
9
  export declare function required<GenericDataParserObject extends DataParserObject, const GenericDefinition extends Partial<Omit<DataParserDefinitionObject, "shape" | "optimizedShape">> = never>(dataParser: GenericDataParserObject, definition?: GenericDefinition): DataParserObject<MergeDefinition<DataParserDefinitionObject, NeverCoalescing<GenericDefinition, {}> & {
9
10
  readonly shape: RequireDataParserObject<GenericDataParserObject["definition"]["shape"]>;
10
11
  }>>;
@@ -10,9 +10,12 @@ import { entry } from '../../../object/entry.mjs';
10
10
  import { entries } from '../../../object/entries.mjs';
11
11
  import { fromEntries } from '../../../object/fromEntries.mjs';
12
12
 
13
+ function requiredShape(shape) {
14
+ return pipe(shape, entries, map(([key, dataParser]) => pipe(identifier(dataParser, optionalKind), whenIsRight((dataParser) => dataParser.definition.inner), whenIsLeft(forward), (dataParser) => entry(key, dataParser))), fromEntries);
15
+ }
13
16
  function required(dataParser, definition) {
14
- const newShape = pipe(dataParser.definition.shape, entries, map(([key, dataParser]) => pipe(identifier(dataParser, optionalKind), whenIsRight((dataParser) => dataParser.definition.inner), whenIsLeft(forward), (dataParser) => entry(key, dataParser))), fromEntries);
17
+ const newShape = requiredShape(dataParser.definition.shape);
15
18
  return object(newShape, definition);
16
19
  }
17
20
 
18
- export { required };
21
+ export { required, requiredShape };
@@ -4,7 +4,7 @@ var base = require('../base.cjs');
4
4
  var error = require('../error.cjs');
5
5
  var kind = require('../kind.cjs');
6
6
 
7
- const dataParserCheckerRefineKind = kind.createDataParserKind("checker-string-max");
7
+ const dataParserCheckerRefineKind = kind.createDataParserKind("refine");
8
8
  function checkerRefine(theFunction, definition) {
9
9
  return base.dataParserCheckerInit(dataParserCheckerRefineKind, {
10
10
  definition: {
@@ -4,7 +4,7 @@ import { type AssignObjects } from "../../object";
4
4
  export interface DataParserCheckerDefinitionRefine extends DataParserCheckerDefinition {
5
5
  theFunction(input: unknown): boolean;
6
6
  }
7
- export declare const dataParserCheckerRefineKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsDataParser/checker-string-max", unknown>>;
7
+ export declare const dataParserCheckerRefineKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsDataParser/refine", unknown>>;
8
8
  type _DataParserCheckerRefine<GenericDefinition extends DataParserCheckerDefinitionRefine> = (Kind<typeof dataParserCheckerRefineKind.definition> & DataParserChecker<GenericDefinition, string>);
9
9
  export interface DataParserCheckerRefine<GenericDefinition extends DataParserCheckerDefinitionRefine = DataParserCheckerDefinitionRefine> extends _DataParserCheckerRefine<GenericDefinition> {
10
10
  }
@@ -2,7 +2,7 @@ import { dataParserCheckerInit } from '../base.mjs';
2
2
  import { SymbolDataParserErrorIssue } from '../error.mjs';
3
3
  import { createDataParserKind } from '../kind.mjs';
4
4
 
5
- const dataParserCheckerRefineKind = createDataParserKind("checker-string-max");
5
+ const dataParserCheckerRefineKind = createDataParserKind("refine");
6
6
  function checkerRefine(theFunction, definition) {
7
7
  return dataParserCheckerInit(dataParserCheckerRefineKind, {
8
8
  definition: {
@@ -15,7 +15,7 @@ declare const kind = "kind-future-either";
15
15
  export declare class Future<const GenericValue extends unknown = unknown> extends Promise<ComputeFutureEitherResult<GenericValue>> {
16
16
  constructor(value: GenericValue);
17
17
  [kind]: unknown;
18
- then<TResult1 = ComputeFutureEitherResult<GenericValue>, TResult2 = never>(onfulfilled?: ((value: ComputeFutureEitherResult<GenericValue>) => TResult1 | PromiseLike<TResult1>) | null): Promise<TResult1 | TResult2>;
18
+ then<TResult1 = Extract<ComputeFutureEitherResult<GenericValue>, any>, TResult2 = never>(onfulfilled?: ((value: Extract<ComputeFutureEitherResult<GenericValue>, any>) => TResult1 | PromiseLike<TResult1>) | null): Promise<TResult1 | TResult2>;
19
19
  static get [Symbol.species](): PromiseConstructor;
20
20
  static instanceof<GenericValue extends unknown>(value: GenericValue): value is Extract<GenericValue, Future<any>>;
21
21
  static rightAll<const GenericArray extends readonly unknown[]>(values: GenericArray): FutureEitherAllResult<GenericArray>;
package/dist/index.cjs CHANGED
@@ -26,7 +26,7 @@ var simpleClone = require('./common/simpleClone.cjs');
26
26
  var sleep = require('./common/sleep.cjs');
27
27
  var stringToBytes = require('./common/stringToBytes.cjs');
28
28
  var stringToMillisecond = require('./common/stringToMillisecond.cjs');
29
- var toJson = require('./common/toJson.cjs');
29
+ var toJSON = require('./common/toJSON.cjs');
30
30
  var toTransform = require('./common/toTransform.cjs');
31
31
  var toWrappedValue = require('./common/toWrappedValue.cjs');
32
32
  var unwrap = require('./common/unwrap.cjs');
@@ -101,7 +101,7 @@ exports.InvalidBytesInStringError = stringToBytes.InvalidBytesInStringError;
101
101
  exports.stringToBytes = stringToBytes.stringToBytes;
102
102
  exports.InvalidMillisecondInStringError = stringToMillisecond.InvalidMillisecondInStringError;
103
103
  exports.stringToMillisecond = stringToMillisecond.stringToMillisecond;
104
- exports.toJSON = toJson.toJSON;
104
+ exports.toJSON = toJSON.toJSON;
105
105
  exports.toTransform = toTransform.toTransform;
106
106
  exports.toWrappedValue = toWrappedValue.toWrappedValue;
107
107
  exports.unwrap = unwrap.unwrap;
package/dist/index.mjs CHANGED
@@ -48,7 +48,7 @@ export { simpleClone } from './common/simpleClone.mjs';
48
48
  export { sleep } from './common/sleep.mjs';
49
49
  export { InvalidBytesInStringError, stringToBytes } from './common/stringToBytes.mjs';
50
50
  export { InvalidMillisecondInStringError, stringToMillisecond } from './common/stringToMillisecond.mjs';
51
- export { toJSON } from './common/toJson.mjs';
51
+ export { toJSON } from './common/toJSON.mjs';
52
52
  export { toTransform } from './common/toTransform.mjs';
53
53
  export { toWrappedValue } from './common/toWrappedValue.mjs';
54
54
  export { unwrap } from './common/unwrap.mjs';