@duplojs/utils 1.3.30 → 1.3.32

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 (51) hide show
  1. package/dist/clean/entity.d.ts +2 -2
  2. package/dist/clean/flag.cjs +4 -0
  3. package/dist/clean/flag.d.ts +1 -0
  4. package/dist/clean/flag.mjs +4 -0
  5. package/dist/clean/index.cjs +2 -0
  6. package/dist/clean/index.d.ts +1 -0
  7. package/dist/clean/index.mjs +1 -0
  8. package/dist/clean/newType.d.ts +2 -2
  9. package/dist/clean/unwrapEntity.cjs +26 -0
  10. package/dist/clean/unwrapEntity.d.ts +13 -0
  11. package/dist/clean/unwrapEntity.mjs +24 -0
  12. package/dist/common/index.d.ts +2 -0
  13. package/dist/common/override.cjs +37 -17
  14. package/dist/common/override.d.ts +5 -8
  15. package/dist/common/override.mjs +37 -17
  16. package/dist/common/pipeCall.cjs +7 -0
  17. package/dist/common/pipeCall.d.ts +1 -0
  18. package/dist/common/pipeCall.mjs +5 -0
  19. package/dist/common/toCurriedPredicate.cjs +7 -0
  20. package/dist/common/toCurriedPredicate.d.ts +1 -0
  21. package/dist/common/toCurriedPredicate.mjs +5 -0
  22. package/dist/common/types/DeepReadonly.d.ts +3 -0
  23. package/dist/common/types/anyValue.d.ts +1 -1
  24. package/dist/common/types/index.d.ts +1 -0
  25. package/dist/dataParser/extended/object.cjs +5 -0
  26. package/dist/dataParser/extended/object.d.ts +4 -0
  27. package/dist/dataParser/extended/object.mjs +5 -0
  28. package/dist/dataParser/identifier.d.ts +2 -2
  29. package/dist/dataParser/index.cjs +3 -0
  30. package/dist/dataParser/index.mjs +1 -0
  31. package/dist/dataParser/parsers/literal.d.ts +2 -2
  32. package/dist/dataParser/parsers/object/extends.cjs +15 -0
  33. package/dist/dataParser/parsers/object/extends.d.ts +9 -0
  34. package/dist/dataParser/parsers/object/extends.mjs +12 -0
  35. package/dist/dataParser/parsers/object/index.d.ts +1 -0
  36. package/dist/index.cjs +4 -0
  37. package/dist/index.mjs +2 -0
  38. package/dist/metadata.json +51 -0
  39. package/dist/object/countKeys.cjs +12 -0
  40. package/dist/object/countKeys.d.ts +1 -0
  41. package/dist/object/countKeys.mjs +10 -0
  42. package/dist/object/entries.cjs +6 -0
  43. package/dist/object/entries.d.ts +5 -2
  44. package/dist/object/entries.mjs +6 -0
  45. package/dist/object/hasKeys.d.ts +2 -2
  46. package/dist/object/index.cjs +2 -0
  47. package/dist/object/index.d.ts +1 -0
  48. package/dist/object/index.mjs +1 -0
  49. package/dist/object/types/forbiddenKey.d.ts +6 -0
  50. package/dist/object/types/index.d.ts +1 -0
  51. package/package.json +1 -1
@@ -40,7 +40,7 @@ export interface EntityHandler<GenericName extends string = string, GenericPrope
40
40
  readonly name: GenericName;
41
41
  readonly propertiesDefinition: GenericPropertiesDefinition;
42
42
  readonly mapDataParser: DDataParser.Contract<EntityProperties<GenericPropertiesDefinition>, EntityRawProperties<GenericPropertiesDefinition>>;
43
- "new"<GenericProperties extends EntityProperties<GenericPropertiesDefinition>>(properties: GenericProperties): Entity<GenericName> & GenericProperties;
43
+ "new"<const GenericProperties extends EntityProperties<GenericPropertiesDefinition>>(properties: GenericProperties): Entity<GenericName> & GenericProperties;
44
44
  map(rawProperties: EntityRawProperties<GenericPropertiesDefinition>): (DEither.EitherRight<"createEntity", Entity<GenericName> & EntityProperties<GenericPropertiesDefinition>> | DEither.EitherLeft<"createEntityError", DDataParser.DataParserError>);
45
45
  mapOrThrow(rawProperties: EntityRawProperties<GenericPropertiesDefinition>): Entity<GenericName> & EntityProperties<GenericPropertiesDefinition>;
46
46
  is<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput, Entity<GenericName>>;
@@ -70,6 +70,6 @@ export interface PropertiesDefinitionParams {
70
70
  inArray: NeverCoalescing<GenericAdvancedArrayPropertyDefinition, true>;
71
71
  };
72
72
  }
73
- export declare function createEntity<GenericName extends string, const GenericPropertiesDefinition extends EntityPropertiesDefinition>(name: GenericName, getPropertiesDefinition: (params: PropertiesDefinitionParams) => GenericPropertiesDefinition): EntityHandler<GenericName, GenericPropertiesDefinition>;
73
+ export declare function createEntity<GenericName extends string, const GenericPropertiesDefinition extends EntityPropertiesDefinition>(name: GenericName, getPropertiesDefinition: (params: PropertiesDefinitionParams) => GenericPropertiesDefinition & DObject.ForbiddenKey<GenericPropertiesDefinition, "_entityName" | "_flags">): EntityHandler<GenericName, GenericPropertiesDefinition>;
74
74
  export type GetEntity<GenericEntityHandler extends EntityHandler<string, any>> = Extract<ReturnType<GenericEntityHandler["new"]>, any>;
75
75
  export {};
@@ -19,6 +19,10 @@ function createFlag(name) {
19
19
  getValue(entity) {
20
20
  return flagKind.getValue(entity)[name];
21
21
  },
22
+ has(entity) {
23
+ return flagKind.has(entity)
24
+ && name in flagKind.getValue(entity);
25
+ },
22
26
  });
23
27
  }
24
28
 
@@ -6,6 +6,7 @@ export interface FlagHandler<GenericEntity extends Entity = Entity, GenericName
6
6
  readonly name: GenericName;
7
7
  append<GenericInputEntity extends GenericEntity, GenericInputValue extends GenericValue>(entity: GenericInputEntity, ...args: IsEqual<GenericValue, never> extends true ? [] : [GenericInputValue]): (GenericInputEntity & Flag<GenericName, GenericInputValue>);
8
8
  getValue<GenericInputEntity extends GenericEntity & Flag<GenericName, GenericValue>>(entity: GenericInputEntity): GetKindValue<typeof flagKind, GenericInputEntity>[GenericName];
9
+ has<GenericInputEntity extends GenericEntity>(entity: GenericInputEntity): Extract<GenericInputEntity, Flag<GenericName, any>>;
9
10
  }
10
11
  export interface Flag<GenericName extends string = string, GenericValue extends unknown = never> extends Kind<typeof flagKind.definition, Record<GenericName, GenericValue>> {
11
12
  }
@@ -17,6 +17,10 @@ function createFlag(name) {
17
17
  getValue(entity) {
18
18
  return flagKind.getValue(entity)[name];
19
19
  },
20
+ has(entity) {
21
+ return flagKind.has(entity)
22
+ && name in flagKind.getValue(entity);
23
+ },
20
24
  });
21
25
  }
22
26
 
@@ -6,6 +6,7 @@ var entity = require('./entity.cjs');
6
6
  var repository = require('./repository.cjs');
7
7
  var useCase = require('./useCase.cjs');
8
8
  var flag = require('./flag.cjs');
9
+ var unwrapEntity = require('./unwrapEntity.cjs');
9
10
  var base = require('./constraint/base.cjs');
10
11
  var number = require('./constraint/defaultConstraint/number.cjs');
11
12
  var string = require('./constraint/defaultConstraint/string.cjs');
@@ -53,6 +54,7 @@ exports.useCaseHandlerKind = useCase.useCaseHandlerKind;
53
54
  exports.useCaseInstances = useCase.useCaseInstances;
54
55
  exports.createFlag = flag.createFlag;
55
56
  exports.flagKind = flag.flagKind;
57
+ exports.unwrapEntity = unwrapEntity.unwrapEntity;
56
58
  exports.CreateConstrainedTypeError = base.CreateConstrainedTypeError;
57
59
  exports.constrainedTypeKind = base.constrainedTypeKind;
58
60
  exports.constraintHandlerKind = base.constraintHandlerKind;
@@ -7,3 +7,4 @@ export * from "./primitive";
7
7
  export * from "./repository";
8
8
  export * from "./useCase";
9
9
  export * from "./flag";
10
+ export * from "./unwrapEntity";
@@ -4,6 +4,7 @@ export { CreateEntityError, createEntity, entityKind } from './entity.mjs';
4
4
  export { createRepository, repositoryHandlerKind } from './repository.mjs';
5
5
  export { createUseCase, useCaseHandlerKind, useCaseInstances } from './useCase.mjs';
6
6
  export { createFlag, flagKind } from './flag.mjs';
7
+ export { unwrapEntity } from './unwrapEntity.mjs';
7
8
  export { CreateConstrainedTypeError, constrainedTypeKind, constraintHandlerKind, createConstraint } from './constraint/base.mjs';
8
9
  export { Int, Negative, Positive } from './constraint/defaultConstraint/number.mjs';
9
10
  export { Email, Url } from './constraint/defaultConstraint/string.mjs';
@@ -1,4 +1,4 @@
1
- import { type Kind, type WrappedValue, type Unwrap, type NeverCoalescing } from "..";
1
+ import { type Kind, type WrappedValue, type Unwrap, type NeverCoalescing, type DeepReadonly } from "..";
2
2
  import { constrainedTypeKind, type ConstraintHandler } from "./constraint";
3
3
  import { type Primitive, type EligiblePrimitive } from "./primitive";
4
4
  import * as DEither from "../either";
@@ -34,6 +34,6 @@ export declare class CreateNewTypeError extends CreateNewTypeError_base {
34
34
  export declare function createNewType<GenericName extends string, GenericDataParser extends DDataParser.DataParser, const GenericConstrainHandler extends (ConstraintHandler<string, EligiblePrimitive, readonly DDataParser.DataParserChecker<DDataParser.DataParserCheckerDefinition, DDataParser.Output<GenericDataParser>>[]> | readonly [
35
35
  ConstraintHandler<string, EligiblePrimitive, readonly DDataParser.DataParserChecker<DDataParser.DataParserCheckerDefinition, DDataParser.Output<GenericDataParser>>[]>,
36
36
  ...ConstraintHandler<string, EligiblePrimitive, readonly DDataParser.DataParserChecker<DDataParser.DataParserCheckerDefinition, DDataParser.Output<GenericDataParser>>[]>[]
37
- ]) = never>(name: GenericName, dataParser: GenericDataParser & DataParserContainTransform<GenericDataParser>, constraint?: GenericConstrainHandler): NewTypeHandler<GenericName, DDataParser.Output<GenericDataParser>, DArray.ArrayCoalescing<NeverCoalescing<GenericConstrainHandler, readonly []>>>;
37
+ ]) = never>(name: GenericName, dataParser: GenericDataParser & DataParserContainTransform<GenericDataParser>, constraint?: GenericConstrainHandler): NewTypeHandler<GenericName, DeepReadonly<DDataParser.Output<GenericDataParser>>, DArray.ArrayCoalescing<NeverCoalescing<GenericConstrainHandler, readonly []>>>;
38
38
  export type GetNewType<GenericHandler extends NewTypeHandler<string, unknown, readonly any[]>> = Extract<GenericHandler extends any ? NewType<GenericHandler["name"], DDataParser.Output<GenericHandler["dataParser"]>, GenericHandler["constrains"][number]["name"]> : never, any>;
39
39
  export {};
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ var entity = require('./entity.cjs');
4
+ var flag = require('./flag.cjs');
5
+ var unwrap = require('../common/unwrap.cjs');
6
+
7
+ function unwrapEntity(entity$1) {
8
+ const unwrapEntity = {};
9
+ for (const prop in entity$1) {
10
+ if (prop === entity.entityKind.runTimeKey) {
11
+ unwrapEntity._entityName = entity$1[prop];
12
+ }
13
+ else if (prop === flag.flagKind.runTimeKey) {
14
+ unwrapEntity._flags = entity$1[prop];
15
+ }
16
+ else if (entity$1[prop] instanceof Array) {
17
+ unwrapEntity[prop] = entity$1[prop].map(unwrap.unwrap);
18
+ }
19
+ else {
20
+ unwrapEntity[prop] = unwrap.unwrap(entity$1[prop]);
21
+ }
22
+ }
23
+ return unwrapEntity;
24
+ }
25
+
26
+ exports.unwrapEntity = unwrapEntity;
@@ -0,0 +1,13 @@
1
+ import { type GetKindValue, type SimplifyTopLevel, type Kind, type Unwrap, type DeepReadonly } from "../common";
2
+ import { entityKind, type Entity } from "./entity";
3
+ import { flagKind } from "./flag";
4
+ type UnwrapArrayProperties<GenericValue extends readonly any[]> = GenericValue extends readonly [infer InferredFirst, ...infer InferredRest] ? (InferredRest extends readonly [] ? readonly [] : UnwrapArrayProperties<InferredRest>) extends infer InferredResult extends readonly any[] ? readonly [Unwrap<InferredFirst>, ...InferredResult] : never : readonly Unwrap<GenericValue[number]>[];
5
+ export type UnwrapEntity<GenericEntity extends Entity> = SimplifyTopLevel<DeepReadonly<{
6
+ [Prop in Extract<keyof GenericEntity, string>]: GenericEntity[Prop] extends readonly any[] ? UnwrapArrayProperties<GenericEntity[Prop]> : Unwrap<GenericEntity[Prop]>;
7
+ } & {
8
+ [Prop in "_entityName"]: GetKindValue<typeof entityKind, GenericEntity>;
9
+ } & (GenericEntity extends Kind<typeof flagKind.definition, any> ? {
10
+ [Prop in "_flags"]: SimplifyTopLevel<GetKindValue<typeof flagKind, GenericEntity>>;
11
+ } : {})>>;
12
+ export declare function unwrapEntity<GenericEntity extends Entity>(entity: GenericEntity): UnwrapEntity<GenericEntity>;
13
+ export {};
@@ -0,0 +1,24 @@
1
+ import { entityKind } from './entity.mjs';
2
+ import { flagKind } from './flag.mjs';
3
+ import { unwrap } from '../common/unwrap.mjs';
4
+
5
+ function unwrapEntity(entity) {
6
+ const unwrapEntity = {};
7
+ for (const prop in entity) {
8
+ if (prop === entityKind.runTimeKey) {
9
+ unwrapEntity._entityName = entity[prop];
10
+ }
11
+ else if (prop === flagKind.runTimeKey) {
12
+ unwrapEntity._flags = entity[prop];
13
+ }
14
+ else if (entity[prop] instanceof Array) {
15
+ unwrapEntity[prop] = entity[prop].map(unwrap);
16
+ }
17
+ else {
18
+ unwrapEntity[prop] = unwrap(entity[prop]);
19
+ }
20
+ }
21
+ return unwrapEntity;
22
+ }
23
+
24
+ export { unwrapEntity };
@@ -45,3 +45,5 @@ export * from "./truthy";
45
45
  export * from "./falsy";
46
46
  export * from "./hasSomeKinds";
47
47
  export * from "./hasKinds";
48
+ export * from "./toCurriedPredicate";
49
+ export * from "./pipeCall";
@@ -1,33 +1,53 @@
1
1
  'use strict';
2
2
 
3
3
  var globalStore = require('./globalStore.cjs');
4
- var pipe = require('./pipe.cjs');
5
- var fromEntries = require('../object/fromEntries.cjs');
6
- var map = require('../array/map.cjs');
7
- var entry = require('../object/entry.cjs');
8
4
 
9
5
  const SymbolOverrideStore = Symbol.for("@duplojs/utils/override");
10
6
  const overrideStore = globalStore.createGlobalStore(SymbolOverrideStore, {});
11
7
  function createOverride(overrideName) {
12
- const store = overrideStore.value[overrideName] ?? [];
13
- overrideStore.set({
14
- ...overrideStore.value,
15
- [overrideName]: store,
16
- });
8
+ const overridePropertiesStore = overrideStore.value[overrideName] ?? {};
9
+ overrideStore.value[overrideName] ||= overridePropertiesStore;
10
+ let cachedStoreKey = Object.keys(overridePropertiesStore);
17
11
  return {
18
12
  setMethod(prop, theFunction) {
19
- store.push([prop, theFunction]);
13
+ overridePropertiesStore[prop] = theFunction;
14
+ cachedStoreKey = Object.keys(overridePropertiesStore);
20
15
  },
21
16
  setPropertyDefaultValue(prop, value) {
22
- store.push([prop, value]);
17
+ overridePropertiesStore[prop] = value;
18
+ cachedStoreKey = Object.keys(overridePropertiesStore);
23
19
  },
24
20
  apply(overrideInterface) {
25
- const self = {
26
- ...overrideInterface,
27
- ...pipe.pipe(store, map.map(([key, value]) => entry.entry(key, typeof value === "function"
28
- ? (...args) => value(self, ...args)
29
- : value)), fromEntries.fromEntries),
30
- };
21
+ const cachedOverrideProperties = {};
22
+ const self = new Proxy({}, {
23
+ get(target, prop) {
24
+ if (overridePropertiesStore[prop]) {
25
+ if (!cachedOverrideProperties[prop]) {
26
+ cachedOverrideProperties[prop] = typeof overridePropertiesStore[prop] === "function"
27
+ ? (...args) => overridePropertiesStore[prop](self, ...args)
28
+ : overridePropertiesStore[prop];
29
+ }
30
+ return cachedOverrideProperties[prop];
31
+ }
32
+ return overrideInterface[prop];
33
+ },
34
+ ownKeys() {
35
+ return [
36
+ ...Object.keys(overrideInterface),
37
+ ...cachedStoreKey,
38
+ ];
39
+ },
40
+ has(target, prop) {
41
+ return Object.keys(overrideInterface).includes(prop)
42
+ || cachedStoreKey.includes(prop);
43
+ },
44
+ getOwnPropertyDescriptor() {
45
+ return {
46
+ enumerable: true,
47
+ configurable: true,
48
+ };
49
+ },
50
+ });
31
51
  return self;
32
52
  },
33
53
  };
@@ -1,17 +1,14 @@
1
- import { type GetPropsWithValueExtends } from "../object";
2
- import { type Adaptor, type AnyFunction, type AnyValue, type ObjectKey } from "./types";
1
+ import { type Adaptor, type AnyFunction, type AnyValue } from "./types";
2
+ import type * as DObject from "../object";
3
3
  declare const SymbolOverrideStore: unique symbol;
4
4
  declare module "./globalStore" {
5
5
  interface GlobalStore {
6
- [SymbolOverrideStore]: Record<string, [
7
- ObjectKey,
8
- Exclude<AnyValue, AnyFunction> | AnyFunction<[object, ...unknown[]]>
9
- ][]>;
6
+ [SymbolOverrideStore]: Record<string, Record<string, unknown>>;
10
7
  }
11
8
  }
12
9
  export interface OverrideHandler<GenericInterface extends object> {
13
- setMethod<GenericProperty extends GetPropsWithValueExtends<GenericInterface, AnyFunction>>(prop: GenericProperty, theFunction: (self: GenericInterface, ...args: Parameters<GenericInterface[GenericProperty]>) => ReturnType<GenericInterface[GenericProperty]>): void;
14
- setPropertyDefaultValue<GenericProperty extends Exclude<keyof GenericInterface, GetPropsWithValueExtends<GenericInterface, AnyFunction>>>(prop: GenericProperty, value: Adaptor<GenericInterface[GenericProperty], AnyValue>): void;
10
+ setMethod<GenericProperty extends DObject.GetPropsWithValueExtends<GenericInterface, AnyFunction>>(prop: GenericProperty, theFunction: (self: GenericInterface, ...args: Parameters<GenericInterface[GenericProperty]>) => ReturnType<GenericInterface[GenericProperty]>): void;
11
+ setPropertyDefaultValue<GenericProperty extends Exclude<keyof GenericInterface, DObject.GetPropsWithValueExtends<GenericInterface, AnyFunction>>>(prop: GenericProperty, value: Adaptor<GenericInterface[GenericProperty], AnyValue>): void;
15
12
  apply(overrideInterface: GenericInterface): GenericInterface;
16
13
  }
17
14
  export declare function createOverride<GenericInterface extends object>(overrideName: string): OverrideHandler<GenericInterface>;
@@ -1,31 +1,51 @@
1
1
  import { createGlobalStore } from './globalStore.mjs';
2
- import { pipe } from './pipe.mjs';
3
- import { fromEntries } from '../object/fromEntries.mjs';
4
- import { map } from '../array/map.mjs';
5
- import { entry } from '../object/entry.mjs';
6
2
 
7
3
  const SymbolOverrideStore = Symbol.for("@duplojs/utils/override");
8
4
  const overrideStore = createGlobalStore(SymbolOverrideStore, {});
9
5
  function createOverride(overrideName) {
10
- const store = overrideStore.value[overrideName] ?? [];
11
- overrideStore.set({
12
- ...overrideStore.value,
13
- [overrideName]: store,
14
- });
6
+ const overridePropertiesStore = overrideStore.value[overrideName] ?? {};
7
+ overrideStore.value[overrideName] ||= overridePropertiesStore;
8
+ let cachedStoreKey = Object.keys(overridePropertiesStore);
15
9
  return {
16
10
  setMethod(prop, theFunction) {
17
- store.push([prop, theFunction]);
11
+ overridePropertiesStore[prop] = theFunction;
12
+ cachedStoreKey = Object.keys(overridePropertiesStore);
18
13
  },
19
14
  setPropertyDefaultValue(prop, value) {
20
- store.push([prop, value]);
15
+ overridePropertiesStore[prop] = value;
16
+ cachedStoreKey = Object.keys(overridePropertiesStore);
21
17
  },
22
18
  apply(overrideInterface) {
23
- const self = {
24
- ...overrideInterface,
25
- ...pipe(store, map(([key, value]) => entry(key, typeof value === "function"
26
- ? (...args) => value(self, ...args)
27
- : value)), fromEntries),
28
- };
19
+ const cachedOverrideProperties = {};
20
+ const self = new Proxy({}, {
21
+ get(target, prop) {
22
+ if (overridePropertiesStore[prop]) {
23
+ if (!cachedOverrideProperties[prop]) {
24
+ cachedOverrideProperties[prop] = typeof overridePropertiesStore[prop] === "function"
25
+ ? (...args) => overridePropertiesStore[prop](self, ...args)
26
+ : overridePropertiesStore[prop];
27
+ }
28
+ return cachedOverrideProperties[prop];
29
+ }
30
+ return overrideInterface[prop];
31
+ },
32
+ ownKeys() {
33
+ return [
34
+ ...Object.keys(overrideInterface),
35
+ ...cachedStoreKey,
36
+ ];
37
+ },
38
+ has(target, prop) {
39
+ return Object.keys(overrideInterface).includes(prop)
40
+ || cachedStoreKey.includes(prop);
41
+ },
42
+ getOwnPropertyDescriptor() {
43
+ return {
44
+ enumerable: true,
45
+ configurable: true,
46
+ };
47
+ },
48
+ });
29
49
  return self;
30
50
  },
31
51
  };
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ function pipeCall(theFunction) {
4
+ return theFunction;
5
+ }
6
+
7
+ exports.pipeCall = pipeCall;
@@ -0,0 +1 @@
1
+ export declare function pipeCall<GenericInput extends unknown, GenericOutput extends unknown>(theFunction: (input: NoInfer<GenericInput>) => GenericOutput): (input: GenericInput) => NoInfer<GenericOutput>;
@@ -0,0 +1,5 @@
1
+ function pipeCall(theFunction) {
2
+ return theFunction;
3
+ }
4
+
5
+ export { pipeCall };
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ function toCurriedPredicate(thePredicate) {
4
+ return thePredicate;
5
+ }
6
+
7
+ exports.toCurriedPredicate = toCurriedPredicate;
@@ -0,0 +1 @@
1
+ export declare function toCurriedPredicate<GenericInput extends unknown, GenericPredicate extends GenericInput>(thePredicate: (input: GenericInput) => input is GenericPredicate): (input: GenericInput) => input is GenericPredicate;
@@ -0,0 +1,5 @@
1
+ function toCurriedPredicate(thePredicate) {
2
+ return thePredicate;
3
+ }
4
+
5
+ export { toCurriedPredicate };
@@ -0,0 +1,3 @@
1
+ export type DeepReadonly<GenericValue extends unknown> = GenericValue extends object ? {
2
+ readonly [Prop in keyof GenericValue]: DeepReadonly<GenericValue[Prop]>;
3
+ } : GenericValue;
@@ -1,2 +1,2 @@
1
1
  import { type AnyFunction } from "./anyFunction";
2
- export type AnyValue = string | number | boolean | object | null | bigint | AnyFunction | undefined | symbol;
2
+ export type AnyValue = string | number | boolean | object | null | bigint | AnyFunction | undefined | symbol | AnyValue[];
@@ -43,3 +43,4 @@ export * from "./onlyLiteral";
43
43
  export * from "./sortType";
44
44
  export * from "./maybeGetter";
45
45
  export * from "./falsyValue";
46
+ export * from "./DeepReadonly";
@@ -4,6 +4,7 @@ var baseExtended = require('../baseExtended.cjs');
4
4
  var index = require('../parsers/object/index.cjs');
5
5
  var required = require('../parsers/object/required.cjs');
6
6
  var partial = require('../parsers/object/partial.cjs');
7
+ var _extends = require('../parsers/object/extends.cjs');
7
8
  var pick = require('../parsers/object/pick.cjs');
8
9
  var omit = require('../parsers/object/omit.cjs');
9
10
  var override = require('../../common/override.cjs');
@@ -18,6 +19,10 @@ function object(shape, definition) {
18
19
  const newShape = pick.pickShape(self.definition.shape, pickObject);
19
20
  return object(newShape, definition);
20
21
  },
22
+ extends: (self, extension, definition) => {
23
+ const newShape = _extends.extendsShape(self.definition.shape, extension);
24
+ return object(newShape, definition);
25
+ },
21
26
  partial: (self, definition) => {
22
27
  const newShape = partial.partialShape(self.definition.shape);
23
28
  return object(newShape, definition);
@@ -3,6 +3,7 @@ import { type DataParserExtended } from "../baseExtended";
3
3
  import { type AddCheckersToDefinition, type MergeDefinition } from "../types";
4
4
  import * as dataParsers from "../parsers";
5
5
  import { type Output } from "../base";
6
+ import { type AssignObjects } from "../../object";
6
7
  type _DataParserObjectExtended<GenericDefinition extends dataParsers.DataParserDefinitionObject> = (Kind<typeof dataParsers.objectKind.definition> & DataParserExtended<GenericDefinition, dataParsers.DataParserObjectShapeOutput<GenericDefinition["shape"]>, dataParsers.DataParserObjectShapeInput<GenericDefinition["shape"]>>);
7
8
  export interface DataParserObjectExtended<GenericDefinition extends dataParsers.DataParserDefinitionObject = dataParsers.DataParserDefinitionObject> extends _DataParserObjectExtended<GenericDefinition> {
8
9
  addChecker<GenericChecker extends readonly [
@@ -25,6 +26,9 @@ export interface DataParserObjectExtended<GenericDefinition extends dataParsers.
25
26
  pick<const GenericPickObject extends Partial<Record<keyof GenericDefinition["shape"], true>>, const GenericSubDefinition extends Partial<Omit<dataParsers.DataParserDefinitionObject, "shape" | "optimizedShape">> = never>(pickObject: GenericPickObject, definition?: GenericDefinition): DataParserObjectExtended<MergeDefinition<dataParsers.DataParserDefinitionObject, NeverCoalescing<GenericSubDefinition, {}> & {
26
27
  readonly shape: SimplifyTopLevel<Pick<GenericDefinition["shape"], Adaptor<keyof GenericPickObject, keyof GenericDefinition["shape"]>>>;
27
28
  }>>;
29
+ extends<const GenericExtension extends dataParsers.DataParserObjectShape, const GenericSubDefinition extends Partial<Omit<dataParsers.DataParserDefinitionObject, "shape" | "optimizedShape">> = never>(extension: GenericExtension, definition?: GenericDefinition): DataParserObjectExtended<MergeDefinition<dataParsers.DataParserDefinitionObject, NeverCoalescing<GenericSubDefinition, {}> & {
30
+ readonly shape: AssignObjects<GenericDefinition["shape"], GenericExtension>;
31
+ }>>;
28
32
  partial<const GenericSubDefinition extends Partial<Omit<dataParsers.DataParserDefinitionObject, "shape" | "optimizedShape">> = never>(definition?: GenericDefinition): DataParserObjectExtended<MergeDefinition<dataParsers.DataParserDefinitionObject, NeverCoalescing<GenericSubDefinition, {}> & {
29
33
  readonly shape: dataParsers.PartialDataParserObject<GenericDefinition["shape"]>;
30
34
  }>>;
@@ -2,6 +2,7 @@ import { dataParserExtendedInit } from '../baseExtended.mjs';
2
2
  import { object as object$1 } from '../parsers/object/index.mjs';
3
3
  import { requiredShape } from '../parsers/object/required.mjs';
4
4
  import { partialShape } from '../parsers/object/partial.mjs';
5
+ import { extendsShape } from '../parsers/object/extends.mjs';
5
6
  import { pickShape } from '../parsers/object/pick.mjs';
6
7
  import { omitShape } from '../parsers/object/omit.mjs';
7
8
  import { createOverride } from '../../common/override.mjs';
@@ -16,6 +17,10 @@ function object(shape, definition) {
16
17
  const newShape = pickShape(self.definition.shape, pickObject);
17
18
  return object(newShape, definition);
18
19
  },
20
+ extends: (self, extension, definition) => {
21
+ const newShape = extendsShape(self.definition.shape, extension);
22
+ return object(newShape, definition);
23
+ },
19
24
  partial: (self, definition) => {
20
25
  const newShape = partialShape(self.definition.shape);
21
26
  return object(newShape, definition);
@@ -8,7 +8,7 @@ import { type DataParser } from "./base";
8
8
  * parsers, the correct type can be retrieved.
9
9
  */
10
10
  export declare const identifier: {
11
- <GenericKindHandler extends import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/bigint", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/extended", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/boolean", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/date", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/time", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/empty", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/nil", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/number", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/string", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/array", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/transform", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/union", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/pipe", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/nullable", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/optional", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/recover", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/lazy", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/literal", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/object", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/tuple", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/template-literal", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/unknown", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/record", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/base", {
11
+ <GenericKindHandler extends import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/bigint", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/extended", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/boolean", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/date", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/time", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/empty", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/nil", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/number", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/string", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/array", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/transform", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/union", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/pipe", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/nullable", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/optional", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/recover", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/lazy", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/literal", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/object", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/record", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/template-literal", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/tuple", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/unknown", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/base", {
12
12
  input: string;
13
13
  output: string;
14
14
  }>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/base", {
@@ -60,7 +60,7 @@ export declare const identifier: {
60
60
  input: unknown[];
61
61
  output: unknown[];
62
62
  }>>, GenericInput extends DataParser<import("./base").DataParserDefinition<import("./base").DataParserChecker<import("./base").DataParserCheckerDefinition, unknown>>, unknown, unknown>, GenericGroupedKind extends import("../common").UnionToIntersection<GenericKindHandler extends import("../common").KindHandler<import("../common").KindDefinition<string, unknown>> ? import("../common").Kind<GenericKindHandler["definition"], GenericKindHandler["definition"]["value"]> : never>>(kind: GenericKindHandler | GenericKindHandler[]): (input: GenericInput) => input is (import("../common").IsEqual<import("../common").IsEqual<false | (GenericInput extends any ? import("../common").IsEqual<GenericInput, DataParser<import("./base").DataParserDefinition<import("./base").DataParserChecker<import("./base").DataParserCheckerDefinition, unknown>>, unknown, unknown>> : never), boolean>, true> extends true ? Extract<DataParser<import("./base").DataParserDefinition<import("./base").DataParserChecker<import("./base").DataParserCheckerDefinition, unknown>>, unknown, unknown>, GenericGroupedKind> | Extract<import("./parsers").DataParserString<import("./parsers").DataParserDefinitionString>, GenericGroupedKind> | Extract<import("./parsers").DataParserObject<import("./parsers").DataParserDefinitionObject>, GenericGroupedKind> | Extract<import("./parsers").DataParserNumber<import("./parsers").DataParserDefinitionNumber>, GenericGroupedKind> | Extract<import("./parsers").DataParserLiteral<import("./parsers").DataParserDefinitionLiteral>, GenericGroupedKind> | Extract<import("./parsers").DataParserUnion<import("./parsers").DataParserDefinitionUnion>, GenericGroupedKind> | Extract<import("./parsers").DataParserArray<import("./parsers").DataParserDefinitionArray>, GenericGroupedKind> | Extract<import("./parsers").DataParserBigInt<import("./parsers").DataParserDefinitionBigInt>, GenericGroupedKind> | Extract<import("./parsers").DataParserTuple<import("./parsers").DataParserDefinitionTuple>, GenericGroupedKind> | Extract<import("./parsers").DataParserTransform<import("./parsers").DataParserDefinitionTransform>, GenericGroupedKind> | Extract<import("./parsers").DataParserBoolean<import("./parsers").DataParserDefinitionBoolean>, GenericGroupedKind> | Extract<import("./parsers").DataParserDate<import("./parsers").DataParserDefinitionDate>, GenericGroupedKind> | Extract<import("./parsers").DataParserTime<import("./parsers").DataParserDefinitionTime>, GenericGroupedKind> | Extract<import("./parsers").DataParserNil<import("./parsers").DataParserDefinitionNil>, GenericGroupedKind> | Extract<import("./parsers").DataParserEmpty<import("./parsers").DataParserDefinitionEmpty>, GenericGroupedKind> | Extract<import("./parsers").DataParserTemplateLiteral<import("./parsers").DataParserDefinitionTemplateLiteral>, GenericGroupedKind> | Extract<import("./parsers").DataParserPipe<import("./parsers").DataParserDefinitionPipe>, GenericGroupedKind> | Extract<import("./parsers").DataParserNullable<import("./parsers").DataParserDefinitionNullable<unknown>>, GenericGroupedKind> | Extract<import("./parsers").DataParserOptional<import("./parsers").DataParserDefinitionOptional<unknown>>, GenericGroupedKind> | Extract<import("./parsers").DataParserLazy<import("./parsers").DataParserDefinitionLazy>, GenericGroupedKind> | Extract<import("./parsers").DataParserUnknown<import("./parsers").DataParserDefinitionUnknown>, GenericGroupedKind> | Extract<import("./parsers").DataParserRecord<import("./parsers").DataParserDefinitionRecord>, GenericGroupedKind> | Extract<import("./parsers").DataParserRecover<import("./parsers").DataParserDefinitionRecover>, GenericGroupedKind> | Extract<import("./baseExtended").DataParserExtended<import("./base").DataParserDefinition<import("./base").DataParserChecker<import("./base").DataParserCheckerDefinition, unknown>>, unknown, unknown>, GenericGroupedKind> | Extract<import("./extended").DataParserStringExtended<import("./parsers").DataParserDefinitionString>, GenericGroupedKind> | Extract<import("./extended").DataParserObjectExtended<import("./parsers").DataParserDefinitionObject>, GenericGroupedKind> | Extract<import("./extended").DataParserNumberExtended<import("./parsers").DataParserDefinitionNumber>, GenericGroupedKind> | Extract<import("./extended").DataParserLiteralExtended<import("./parsers").DataParserDefinitionLiteral>, GenericGroupedKind> | Extract<import("./extended").DataParserUnionExtended<import("./parsers").DataParserDefinitionUnion>, GenericGroupedKind> | Extract<import("./extended").DataParserArrayExtended<import("./parsers").DataParserDefinitionArray>, GenericGroupedKind> | Extract<import("./extended").DataParserBigIntExtended<import("./parsers").DataParserDefinitionBigInt>, GenericGroupedKind> | Extract<import("./extended").DataParserTupleExtended<import("./parsers").DataParserDefinitionTuple>, GenericGroupedKind> | Extract<import("./extended").DataParserTransformExtended<import("./parsers").DataParserDefinitionTransform>, GenericGroupedKind> | Extract<import("./extended").DataParserBooleanExtended<import("./parsers").DataParserDefinitionBoolean>, GenericGroupedKind> | Extract<import("./extended").DataParserDateExtended<import("./parsers").DataParserDefinitionDate>, GenericGroupedKind> | Extract<import("./extended").DataParserTimeExtended<import("./parsers").DataParserDefinitionTime>, GenericGroupedKind> | Extract<import("./extended").DataParserNilExtended<import("./parsers").DataParserDefinitionNil>, GenericGroupedKind> | Extract<import("./extended").DataParserEmptyExtended<import("./parsers").DataParserDefinitionEmpty>, GenericGroupedKind> | Extract<import("./extended").DataParserTemplateLiteralExtended<import("./parsers").DataParserDefinitionTemplateLiteral>, GenericGroupedKind> | Extract<import("./extended").DataParserPipeExtended<import("./parsers").DataParserDefinitionPipe>, GenericGroupedKind> | Extract<import("./extended").DataParserNullableExtended<import("./parsers").DataParserDefinitionNullable<unknown>>, GenericGroupedKind> | Extract<import("./extended").DataParserOptionalExtended<import("./parsers").DataParserDefinitionOptional<unknown>>, GenericGroupedKind> | Extract<import("./extended").DataParserLazyExtended<import("./parsers").DataParserDefinitionLazy>, GenericGroupedKind> | Extract<import("./extended").DataParserUnknownExtended<import("./parsers").DataParserDefinitionUnknown>, GenericGroupedKind> | Extract<import("./extended").DataParserRecordExtended<import("./parsers").DataParserDefinitionRecord>, GenericGroupedKind> | Extract<import("./extended").DataParserRecoverExtended<import("./parsers").DataParserDefinitionRecover>, GenericGroupedKind> : never) | Extract<GenericInput, GenericGroupedKind>;
63
- <GenericKindHandler extends import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/bigint", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/extended", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/boolean", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/date", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/time", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/empty", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/nil", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/number", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/string", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/array", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/transform", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/union", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/pipe", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/nullable", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/optional", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/recover", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/lazy", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/literal", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/object", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/tuple", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/template-literal", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/unknown", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/record", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/base", {
63
+ <GenericKindHandler extends import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/bigint", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/extended", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/boolean", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/date", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/time", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/empty", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/nil", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/number", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/string", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/array", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/transform", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/union", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/pipe", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/nullable", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/optional", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/recover", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/lazy", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/literal", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/object", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/record", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/template-literal", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/tuple", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/unknown", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/base", {
64
64
  input: string;
65
65
  output: string;
66
66
  }>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/base", {
@@ -16,6 +16,7 @@ var omit = require('./parsers/object/omit.cjs');
16
16
  var pick = require('./parsers/object/pick.cjs');
17
17
  var partial = require('./parsers/object/partial.cjs');
18
18
  var required = require('./parsers/object/required.cjs');
19
+ var _extends = require('./parsers/object/extends.cjs');
19
20
  var index$3 = require('./parsers/object/index.cjs');
20
21
  var int = require('./parsers/number/checkers/int.cjs');
21
22
  var min$1 = require('./parsers/number/checkers/min.cjs');
@@ -97,6 +98,8 @@ exports.partial = partial.partial;
97
98
  exports.partialShape = partial.partialShape;
98
99
  exports.required = required.required;
99
100
  exports.requiredShape = required.requiredShape;
101
+ exports.extends = _extends.extends;
102
+ exports.extendsShape = _extends.extendsShape;
100
103
  exports.object = index$3.object;
101
104
  exports.objectKind = index$3.objectKind;
102
105
  exports.checkerInt = int.checkerInt;
@@ -16,6 +16,7 @@ export { omit, omitShape } from './parsers/object/omit.mjs';
16
16
  export { pick, pickShape } from './parsers/object/pick.mjs';
17
17
  export { partial, partialShape } from './parsers/object/partial.mjs';
18
18
  export { required, requiredShape } from './parsers/object/required.mjs';
19
+ export { extends, extendsShape } from './parsers/object/extends.mjs';
19
20
  export { object, objectKind } from './parsers/object/index.mjs';
20
21
  export { checkerInt, checkerIntKind, int } from './parsers/number/checkers/int.mjs';
21
22
  export { checkerNumberMin, checkerNumberMinKind } from './parsers/number/checkers/min.mjs';
@@ -25,8 +25,8 @@ export interface DataParserLiteral<GenericDefinition extends DataParserDefinitio
25
25
  */
26
26
  construct<const GenericDefinition extends DataParserDefinitionLiteral>(definition: GenericDefinition): DataParserLiteral<MergeDefinition<DataParserDefinitionLiteral, GenericDefinition>>;
27
27
  }
28
- export declare function literal<const GenericValue extends LiteralValue, const GenericDefinition extends Partial<Omit<DataParserDefinitionLiteral, "value">> = never>(value: GenericValue | GenericValue[], definition?: GenericDefinition): DataParserLiteral<MergeDefinition<DataParserDefinitionLiteral, NeverCoalescing<GenericDefinition, {}> & {
29
- value: GenericValue[];
28
+ export declare function literal<const GenericValue extends LiteralValue, const GenericDefinition extends Partial<Omit<DataParserDefinitionLiteral, "value">> = never>(value: GenericValue | readonly GenericValue[], definition?: GenericDefinition): DataParserLiteral<MergeDefinition<DataParserDefinitionLiteral, NeverCoalescing<GenericDefinition, {}> & {
29
+ value: readonly GenericValue[];
30
30
  }>>;
31
31
  export declare namespace literal {
32
32
  var overrideHandler: import("../../common").OverrideHandler<DataParserLiteral<DataParserDefinitionLiteral>>;
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index.cjs');
4
+ var assign = require('../../../object/assign.cjs');
5
+
6
+ function extendsShape(shape, extension) {
7
+ return assign.assign(shape, extension);
8
+ }
9
+ function extend(dataParser, extension, definition) {
10
+ const newShape = extendsShape(dataParser.definition.shape, extension);
11
+ return index.object(newShape, definition);
12
+ }
13
+
14
+ exports.extends = extend;
15
+ exports.extendsShape = extendsShape;
@@ -0,0 +1,9 @@
1
+ import { type MergeDefinition } from "../../../dataParser/types";
2
+ import { type DataParserObjectShape, type DataParserDefinitionObject, type DataParserObject } from ".";
3
+ import { type NeverCoalescing } from "../../../common";
4
+ import { type AssignObjects } from "../../../object";
5
+ export declare function extendsShape(shape: DataParserObjectShape, extension: DataParserObjectShape): DataParserObjectShape;
6
+ declare function extend<GenericDataParserObject extends DataParserObject, const GenericExtension extends DataParserObjectShape, const GenericDefinition extends Partial<Omit<DataParserDefinitionObject, "shape" | "optimizedShape">> = never>(dataParser: GenericDataParserObject, extension: GenericExtension, definition?: GenericDefinition): DataParserObject<MergeDefinition<DataParserDefinitionObject, NeverCoalescing<GenericDefinition, {}> & {
7
+ readonly shape: AssignObjects<GenericDataParserObject["definition"]["shape"], GenericExtension>;
8
+ }>>;
9
+ export { extend as extends };
@@ -0,0 +1,12 @@
1
+ import { object } from './index.mjs';
2
+ import { assign } from '../../../object/assign.mjs';
3
+
4
+ function extendsShape(shape, extension) {
5
+ return assign(shape, extension);
6
+ }
7
+ function extend(dataParser, extension, definition) {
8
+ const newShape = extendsShape(dataParser.definition.shape, extension);
9
+ return object(newShape, definition);
10
+ }
11
+
12
+ export { extend as extends, extendsShape };
@@ -8,6 +8,7 @@ export * from "./omit";
8
8
  export * from "./pick";
9
9
  export * from "./partial";
10
10
  export * from "./required";
11
+ export * from "./extends";
11
12
  export type DataParserObjectShape = Readonly<Record<string, DataParser>>;
12
13
  export type DataParserObjectShapeOutput<GenericShape extends DataParserObjectShape> = {
13
14
  -readonly [Prop in keyof GenericShape as GenericShape[Prop] extends Kind<typeof dataParserKind.definition> ? Prop : never]: Output<GenericShape[Prop]>;
package/dist/index.cjs CHANGED
@@ -58,6 +58,8 @@ var truthy = require('./common/truthy.cjs');
58
58
  var falsy = require('./common/falsy.cjs');
59
59
  var hasSomeKinds = require('./common/hasSomeKinds.cjs');
60
60
  var hasKinds = require('./common/hasKinds.cjs');
61
+ var toCurriedPredicate = require('./common/toCurriedPredicate.cjs');
62
+ var pipeCall = require('./common/pipeCall.cjs');
61
63
 
62
64
 
63
65
 
@@ -143,3 +145,5 @@ exports.truthy = truthy.truthy;
143
145
  exports.falsy = falsy.falsy;
144
146
  exports.hasSomeKinds = hasSomeKinds.hasSomeKinds;
145
147
  exports.hasKinds = hasKinds.hasKinds;
148
+ exports.toCurriedPredicate = toCurriedPredicate.toCurriedPredicate;
149
+ exports.pipeCall = pipeCall.pipeCall;
package/dist/index.mjs CHANGED
@@ -80,3 +80,5 @@ export { truthy } from './common/truthy.mjs';
80
80
  export { falsy } from './common/falsy.mjs';
81
81
  export { hasSomeKinds } from './common/hasSomeKinds.mjs';
82
82
  export { hasKinds } from './common/hasKinds.mjs';
83
+ export { toCurriedPredicate } from './common/toCurriedPredicate.mjs';
84
+ export { pipeCall } from './common/pipeCall.mjs';
@@ -976,6 +976,15 @@
976
976
  {
977
977
  "name": "repository.mjs"
978
978
  },
979
+ {
980
+ "name": "unwrapEntity.cjs"
981
+ },
982
+ {
983
+ "name": "unwrapEntity.d.ts"
984
+ },
985
+ {
986
+ "name": "unwrapEntity.mjs"
987
+ },
979
988
  {
980
989
  "name": "useCase.cjs"
981
990
  },
@@ -1026,6 +1035,9 @@
1026
1035
  {
1027
1036
  "name": "deepPartial.d.ts"
1028
1037
  },
1038
+ {
1039
+ "name": "DeepReadonly.d.ts"
1040
+ },
1029
1041
  {
1030
1042
  "name": "deepRemoveReadonly.d.ts"
1031
1043
  },
@@ -1418,6 +1430,15 @@
1418
1430
  {
1419
1431
  "name": "pipe.mjs"
1420
1432
  },
1433
+ {
1434
+ "name": "pipeCall.cjs"
1435
+ },
1436
+ {
1437
+ "name": "pipeCall.d.ts"
1438
+ },
1439
+ {
1440
+ "name": "pipeCall.mjs"
1441
+ },
1421
1442
  {
1422
1443
  "name": "promiseObject.cjs"
1423
1444
  },
@@ -1463,6 +1484,15 @@
1463
1484
  {
1464
1485
  "name": "stringToMillisecond.mjs"
1465
1486
  },
1487
+ {
1488
+ "name": "toCurriedPredicate.cjs"
1489
+ },
1490
+ {
1491
+ "name": "toCurriedPredicate.d.ts"
1492
+ },
1493
+ {
1494
+ "name": "toCurriedPredicate.mjs"
1495
+ },
1466
1496
  {
1467
1497
  "name": "toJSON.cjs"
1468
1498
  },
@@ -2077,6 +2107,15 @@
2077
2107
  {
2078
2108
  "name": "object",
2079
2109
  "files": [
2110
+ {
2111
+ "name": "extends.cjs"
2112
+ },
2113
+ {
2114
+ "name": "extends.d.ts"
2115
+ },
2116
+ {
2117
+ "name": "extends.mjs"
2118
+ },
2080
2119
  {
2081
2120
  "name": "index.cjs"
2082
2121
  },
@@ -4119,6 +4158,9 @@
4119
4158
  {
4120
4159
  "name": "flatObject.d.ts"
4121
4160
  },
4161
+ {
4162
+ "name": "forbiddenKey.d.ts"
4163
+ },
4122
4164
  {
4123
4165
  "name": "getPropsWithValue.d.ts"
4124
4166
  },
@@ -4151,6 +4193,15 @@
4151
4193
  {
4152
4194
  "name": "assign.mjs"
4153
4195
  },
4196
+ {
4197
+ "name": "countKeys.cjs"
4198
+ },
4199
+ {
4200
+ "name": "countKeys.d.ts"
4201
+ },
4202
+ {
4203
+ "name": "countKeys.mjs"
4204
+ },
4154
4205
  {
4155
4206
  "name": "deepDiscriminate.cjs"
4156
4207
  },
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ var wrapValue = require('../common/wrapValue.cjs');
4
+ var kind = require('../common/kind.cjs');
5
+
6
+ function countKeys(object) {
7
+ return Object.keys(object)
8
+ .filter((key) => !wrapValue.isRuntimeWrappedValueKey(key) && !kind.isRuntimeKind(key))
9
+ .length;
10
+ }
11
+
12
+ exports.countKeys = countKeys;
@@ -0,0 +1 @@
1
+ export declare function countKeys<GenericObject extends object>(object: GenericObject): number;
@@ -0,0 +1,10 @@
1
+ import { isRuntimeWrappedValueKey } from '../common/wrapValue.mjs';
2
+ import { isRuntimeKind } from '../common/kind.mjs';
3
+
4
+ function countKeys(object) {
5
+ return Object.keys(object)
6
+ .filter((key) => !isRuntimeWrappedValueKey(key) && !isRuntimeKind(key))
7
+ .length;
8
+ }
9
+
10
+ export { countKeys };
@@ -7,5 +7,11 @@ function entries(object) {
7
7
  return Object.entries(object)
8
8
  .filter(([key]) => !wrapValue.isRuntimeWrappedValueKey(key) && !kind.isRuntimeKind(key));
9
9
  }
10
+ /**
11
+ * @deprecated Not ignore kind key.
12
+ */
13
+ entries.unsafe = function (object) {
14
+ return Object.entries(object);
15
+ };
10
16
 
11
17
  exports.entries = entries;
@@ -1,8 +1,11 @@
1
1
  import { type DString } from "..";
2
- import { type IsEqual, type ObjectEntry, type ObjectKey } from "../common";
2
+ import { type AnyValue, type IsEqual, type ObjectEntry, type ObjectKey } from "../common";
3
3
  import { type SimplifyTopLevel } from "../common/types/simplifyTopLevel";
4
4
  export type GetEntry<GenericKey extends ObjectKey, GenericValue extends unknown> = GenericValue extends any ? GenericKey extends string | number ? [`${GenericKey}`, GenericValue] : never : never;
5
- export type GetEntries<GenericObject extends object> = GenericObject extends readonly any[] ? [DString.Number, GenericObject[number]][] : ({
5
+ export type GetEntries<GenericObject extends object> = GenericObject extends readonly any[] ? [DString.Number, GenericObject[number]][] : IsEqual<GenericObject, object> extends true ? [string, AnyValue][] : ({
6
6
  [Prop in keyof GenericObject]-?: GetEntry<Prop, GenericObject[Prop]>;
7
7
  }[keyof GenericObject]) extends infer InferredResult extends ObjectEntry ? IsEqual<InferredResult, never> extends true ? [] : InferredResult[] : never;
8
8
  export declare function entries<GenericObject extends object>(object: GenericObject): SimplifyTopLevel<GetEntries<GenericObject>>;
9
+ export declare namespace entries {
10
+ var unsafe: <GenericObject extends object>(object: GenericObject) => [string, AnyValue][];
11
+ }
@@ -5,5 +5,11 @@ function entries(object) {
5
5
  return Object.entries(object)
6
6
  .filter(([key]) => !isRuntimeWrappedValueKey(key) && !isRuntimeKind(key));
7
7
  }
8
+ /**
9
+ * @deprecated Not ignore kind key.
10
+ */
11
+ entries.unsafe = function (object) {
12
+ return Object.entries(object);
13
+ };
8
14
 
9
15
  export { entries };
@@ -1,3 +1,3 @@
1
1
  import { type RequiredKeys } from "./types/requiredKeys";
2
- export declare function hasKeys<GenericObject extends object, GenericKeys extends keyof GenericObject>(keys: GenericKeys | GenericKeys[]): (partialObject: GenericObject) => partialObject is RequiredKeys<GenericObject, NoInfer<GenericKeys>>;
3
- export declare function hasKeys<GenericObject extends object, GenericKeys extends keyof GenericObject>(partialObject: GenericObject, keys: GenericKeys | GenericKeys[]): partialObject is RequiredKeys<GenericObject, NoInfer<GenericKeys>>;
2
+ export declare function hasKeys<GenericObject extends object, GenericKeys extends keyof GenericObject>(keys: GenericKeys | readonly GenericKeys[]): (partialObject: GenericObject) => partialObject is RequiredKeys<GenericObject, NoInfer<GenericKeys>>;
3
+ export declare function hasKeys<GenericObject extends object, GenericKeys extends keyof GenericObject>(partialObject: GenericObject, keys: GenericKeys | readonly GenericKeys[]): partialObject is RequiredKeys<GenericObject, NoInfer<GenericKeys>>;
@@ -4,6 +4,7 @@ var entries = require('./entries.cjs');
4
4
  var fromEntries = require('./fromEntries.cjs');
5
5
  var hasKeys = require('./hasKeys.cjs');
6
6
  var keys = require('./keys.cjs');
7
+ var countKeys = require('./countKeys.cjs');
7
8
  var values = require('./values.cjs');
8
9
  var getProperty = require('./getProperty.cjs');
9
10
  var transformProperties = require('./transformProperties.cjs');
@@ -24,6 +25,7 @@ exports.entries = entries.entries;
24
25
  exports.fromEntries = fromEntries.fromEntries;
25
26
  exports.hasKeys = hasKeys.hasKeys;
26
27
  exports.keys = keys.keys;
28
+ exports.countKeys = countKeys.countKeys;
27
29
  exports.values = values.values;
28
30
  exports.getProperty = getProperty.getProperty;
29
31
  exports.transformProperties = transformProperties.transformProperties;
@@ -3,6 +3,7 @@ export * from "./entries";
3
3
  export * from "./fromEntries";
4
4
  export * from "./hasKeys";
5
5
  export * from "./keys";
6
+ export * from "./countKeys";
6
7
  export * from "./values";
7
8
  export * from "./getProperty";
8
9
  export * from "./transformProperties";
@@ -2,6 +2,7 @@ export { entries } from './entries.mjs';
2
2
  export { fromEntries } from './fromEntries.mjs';
3
3
  export { hasKeys } from './hasKeys.mjs';
4
4
  export { keys } from './keys.mjs';
5
+ export { countKeys } from './countKeys.mjs';
5
6
  export { values } from './values.mjs';
6
7
  export { getProperty } from './getProperty.mjs';
7
8
  export { transformProperties } from './transformProperties.mjs';
@@ -0,0 +1,6 @@
1
+ import { type IsEqual } from "../../common";
2
+ declare const SymbolForbiddenKey: unique symbol;
3
+ export type ForbiddenKey<GenericObject extends object, GenericKey extends string> = (GenericKey extends keyof GenericObject ? {
4
+ [SymbolForbiddenKey]: `Key ${GenericKey} is forbidden.`;
5
+ } : never) extends infer InferredResult ? IsEqual<InferredResult, never> extends true ? unknown : InferredResult : never;
6
+ export {};
@@ -6,3 +6,4 @@ export * from "./getPropsWithValue";
6
6
  export * from "./flatObject";
7
7
  export * from "./getPropsWithValueExtends";
8
8
  export * from "./unFlatObject";
9
+ export * from "./forbiddenKey";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duplojs/utils",
3
- "version": "1.3.30",
3
+ "version": "1.3.32",
4
4
  "author": {
5
5
  "name": "mathcovax",
6
6
  "url": "https://github.com/mathcovax"