@duplojs/utils 1.1.15 → 1.1.16
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.
- package/dist/dataParser/extended/lazy.d.ts +2 -2
- package/dist/dataParser/parsers/lazy.cjs +6 -3
- package/dist/dataParser/parsers/lazy.d.ts +4 -4
- package/dist/dataParser/parsers/lazy.mjs +6 -3
- package/dist/either/hasInformation.cjs +6 -1
- package/dist/either/hasInformation.d.ts +1 -0
- package/dist/either/hasInformation.mjs +6 -1
- package/dist/either/whenHasInformation.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type FixDeepFunctionInfer, type NeverCoalescing } from "../../common";
|
|
1
|
+
import { type Memoized, type FixDeepFunctionInfer, type NeverCoalescing } from "../../common";
|
|
2
2
|
import { type DataParserExtended } from "../baseExtended";
|
|
3
3
|
import { type AddCheckersToDefinition, type MergeDefinition } from "../types";
|
|
4
4
|
import * as dataParsers from "../parsers";
|
|
@@ -17,6 +17,6 @@ export interface DataParserLazyExtended<GenericDefinition extends dataParsers.Da
|
|
|
17
17
|
]>>;
|
|
18
18
|
}
|
|
19
19
|
export declare function lazy<GenericDataParser extends DataParser, const GenericDefinition extends Partial<dataParsers.DataParserDefinitionLazy> = never>(getter: () => GenericDataParser, definition?: GenericDefinition): DataParserLazyExtended<MergeDefinition<dataParsers.DataParserDefinitionLazy, NeverCoalescing<GenericDefinition, {}> & {
|
|
20
|
-
getter
|
|
20
|
+
getter: Memoized<GenericDataParser>;
|
|
21
21
|
}>>;
|
|
22
22
|
export {};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var memo = require('../../common/memo.cjs');
|
|
4
|
+
require('../../common/globalStore.cjs');
|
|
5
|
+
require('../../common/builder.cjs');
|
|
3
6
|
var base = require('../base.cjs');
|
|
4
7
|
var kind = require('../kind.cjs');
|
|
5
8
|
|
|
@@ -9,11 +12,11 @@ function lazy(getter, definition) {
|
|
|
9
12
|
definition: {
|
|
10
13
|
errorMessage: definition?.errorMessage,
|
|
11
14
|
checkers: definition?.checkers ?? [],
|
|
12
|
-
getter,
|
|
15
|
+
getter: memo.memo(getter),
|
|
13
16
|
},
|
|
14
17
|
}, {
|
|
15
|
-
sync: (data, _error, self) => self.definition.getter
|
|
16
|
-
async: (data, _error, self) => self.definition.getter
|
|
18
|
+
sync: (data, _error, self) => self.definition.getter.value.exec(data, _error),
|
|
19
|
+
async: (data, _error, self) => self.definition.getter.value.asyncExec(data, _error),
|
|
17
20
|
});
|
|
18
21
|
}
|
|
19
22
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type NeverCoalescing, type Kind, type FixDeepFunctionInfer } from "../../common";
|
|
1
|
+
import { type NeverCoalescing, type Kind, type FixDeepFunctionInfer, type Memoized } from "../../common";
|
|
2
2
|
import { type DataParserDefinition, type DataParser, type Output, type Input, type DataParserChecker } from "../base";
|
|
3
3
|
import { type AddCheckersToDefinition, type MergeDefinition } from "../../dataParser/types";
|
|
4
4
|
import { type CheckerRefineImplementation } from "./refine";
|
|
@@ -7,10 +7,10 @@ export interface DataParserLazyCheckerCustom<GenericInput extends unknown = unkn
|
|
|
7
7
|
}
|
|
8
8
|
export type DataParserLazyCheckers<GenericInput extends unknown = unknown> = (DataParserLazyCheckerCustom<GenericInput>[GetPropsWithValueExtends<DataParserLazyCheckerCustom<GenericInput>, DataParserChecker>] | CheckerRefineImplementation<GenericInput>);
|
|
9
9
|
export interface DataParserDefinitionLazy extends DataParserDefinition<DataParserLazyCheckers> {
|
|
10
|
-
getter
|
|
10
|
+
getter: Memoized<DataParser>;
|
|
11
11
|
}
|
|
12
12
|
export declare const lazyKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsDataParser/lazy", unknown>>;
|
|
13
|
-
type _DataParserLazy<GenericDefinition extends DataParserDefinitionLazy> = (DataParser<GenericDefinition, Output<
|
|
13
|
+
type _DataParserLazy<GenericDefinition extends DataParserDefinitionLazy> = (DataParser<GenericDefinition, Output<GenericDefinition["getter"]["value"]>, Input<GenericDefinition["getter"]["value"]>> & Kind<typeof lazyKind.definition>);
|
|
14
14
|
export interface DataParserLazy<GenericDefinition extends DataParserDefinitionLazy = DataParserDefinitionLazy> extends _DataParserLazy<GenericDefinition> {
|
|
15
15
|
addChecker<GenericChecker extends readonly [
|
|
16
16
|
DataParserLazyCheckers<Output<this>>,
|
|
@@ -21,6 +21,6 @@ export interface DataParserLazy<GenericDefinition extends DataParserDefinitionLa
|
|
|
21
21
|
], GenericChecker>): DataParserLazy<AddCheckersToDefinition<GenericDefinition, GenericChecker>>;
|
|
22
22
|
}
|
|
23
23
|
export declare function lazy<GenericDataParser extends DataParser, const GenericDefinition extends Partial<DataParserDefinitionLazy> = never>(getter: () => GenericDataParser, definition?: GenericDefinition): DataParserLazy<MergeDefinition<DataParserDefinitionLazy, NeverCoalescing<GenericDefinition, {}> & {
|
|
24
|
-
getter
|
|
24
|
+
getter: Memoized<GenericDataParser>;
|
|
25
25
|
}>>;
|
|
26
26
|
export {};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { memo } from '../../common/memo.mjs';
|
|
2
|
+
import '../../common/globalStore.mjs';
|
|
3
|
+
import '../../common/builder.mjs';
|
|
1
4
|
import { dataParserInit } from '../base.mjs';
|
|
2
5
|
import { createDataParserKind } from '../kind.mjs';
|
|
3
6
|
|
|
@@ -7,11 +10,11 @@ function lazy(getter, definition) {
|
|
|
7
10
|
definition: {
|
|
8
11
|
errorMessage: definition?.errorMessage,
|
|
9
12
|
checkers: definition?.checkers ?? [],
|
|
10
|
-
getter,
|
|
13
|
+
getter: memo(getter),
|
|
11
14
|
},
|
|
12
15
|
}, {
|
|
13
|
-
sync: (data, _error, self) => self.definition.getter
|
|
14
|
-
async: (data, _error, self) => self.definition.getter
|
|
16
|
+
sync: (data, _error, self) => self.definition.getter.value.exec(data, _error),
|
|
17
|
+
async: (data, _error, self) => self.definition.getter.value.asyncExec(data, _error),
|
|
15
18
|
});
|
|
16
19
|
}
|
|
17
20
|
|
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
var kind = require('./kind.cjs');
|
|
4
4
|
|
|
5
|
-
function hasInformation(
|
|
5
|
+
function hasInformation(...args) {
|
|
6
|
+
if (args.length === 1) {
|
|
7
|
+
const [information] = args;
|
|
8
|
+
return (input) => hasInformation(input, information);
|
|
9
|
+
}
|
|
10
|
+
const [input, information] = args;
|
|
6
11
|
return kind.eitherInformationKind.has(input)
|
|
7
12
|
&& kind.eitherInformationKind.getValue(input) === information;
|
|
8
13
|
}
|
|
@@ -3,5 +3,6 @@ import { type EitherLeft } from "./left";
|
|
|
3
3
|
import { type EitherRight } from "./right";
|
|
4
4
|
import { eitherInformationKind } from "./kind";
|
|
5
5
|
type Either = EitherRight | EitherLeft;
|
|
6
|
+
export declare function hasInformation<const GenericInput extends unknown, GenericInformation extends (GenericInput extends Either ? ReturnType<typeof eitherInformationKind.getValue<GenericInput>> : never)>(information: GenericInformation): (input: GenericInput) => input is Extract<GenericInput, Kind<typeof eitherInformationKind.definition, GenericInformation>>;
|
|
6
7
|
export declare function hasInformation<const GenericInput extends unknown, GenericInformation extends (GenericInput extends Either ? ReturnType<typeof eitherInformationKind.getValue<GenericInput>> : never)>(input: GenericInput, information: GenericInformation): input is Extract<GenericInput, Kind<typeof eitherInformationKind.definition, GenericInformation>>;
|
|
7
8
|
export {};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { eitherInformationKind } from './kind.mjs';
|
|
2
2
|
|
|
3
|
-
function hasInformation(
|
|
3
|
+
function hasInformation(...args) {
|
|
4
|
+
if (args.length === 1) {
|
|
5
|
+
const [information] = args;
|
|
6
|
+
return (input) => hasInformation(input, information);
|
|
7
|
+
}
|
|
8
|
+
const [input, information] = args;
|
|
4
9
|
return eitherInformationKind.has(input)
|
|
5
10
|
&& eitherInformationKind.getValue(input) === information;
|
|
6
11
|
}
|
|
@@ -3,6 +3,6 @@ import { type EitherRight } from "./right";
|
|
|
3
3
|
import { type EitherLeft } from "./left";
|
|
4
4
|
import { eitherInformationKind } from "./kind";
|
|
5
5
|
type Either = EitherRight | EitherLeft;
|
|
6
|
-
export declare function whenHasInformation<const GenericInput extends unknown, GenericInformation extends (GenericInput extends Either ? ReturnType<typeof eitherInformationKind.getValue<GenericInput>> : never), const GenericOutput extends AnyValue>(information: GenericInformation | GenericInformation[], theFunction: (value: Unwrap<Extract<GenericInput
|
|
7
|
-
export declare function whenHasInformation<const GenericInput extends unknown, GenericInformation extends (GenericInput extends Either ? ReturnType<typeof eitherInformationKind.getValue<GenericInput>> : never), const GenericOutput extends AnyValue>(input: GenericInput, information: GenericInformation | GenericInformation[], theFunction: (value: Unwrap<Extract<GenericInput
|
|
6
|
+
export declare function whenHasInformation<const GenericInput extends unknown, GenericInformation extends (GenericInput extends Either ? ReturnType<typeof eitherInformationKind.getValue<GenericInput>> : never), const GenericOutput extends AnyValue>(information: GenericInformation | GenericInformation[], theFunction: (value: Unwrap<Extract<BreakGenericLink<GenericInput>, Kind<typeof eitherInformationKind.definition, GenericInformation> & WrappedValue>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<BreakGenericLink<GenericInput>, Kind<typeof eitherInformationKind.definition, GenericInformation>>;
|
|
7
|
+
export declare function whenHasInformation<const GenericInput extends unknown, GenericInformation extends (GenericInput extends Either ? ReturnType<typeof eitherInformationKind.getValue<GenericInput>> : never), const GenericOutput extends AnyValue>(input: GenericInput, information: GenericInformation | GenericInformation[], theFunction: (value: Unwrap<Extract<BreakGenericLink<GenericInput>, Kind<typeof eitherInformationKind.definition, GenericInformation> & WrappedValue>>) => GenericOutput): GenericOutput | Exclude<GenericInput, Kind<typeof eitherInformationKind.definition, GenericInformation>>;
|
|
8
8
|
export {};
|