@orioro/util 0.9.0 → 0.11.1
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/array/dataJoin.d.ts +9 -0
- package/dist/array/index.d.ts +1 -0
- package/dist/array/join.d.ts +9 -0
- package/dist/debug/debugFn/index.d.ts +3 -2
- package/dist/deprecate.d.ts +3 -0
- package/dist/hookFn/index.d.ts +10 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +1514 -0
- package/dist/index.mjs +635 -794
- package/dist/interpolate/index.d.ts +1 -1
- package/dist/pathResolve/index.d.ts +7 -0
- package/dist/promise/index.d.ts +5 -0
- package/dist/promise/isPromise.d.ts +1 -0
- package/dist/promise/makeDeferred.d.ts +6 -0
- package/dist/promise/maybeAsyncFn.d.ts +20 -0
- package/dist/promise/maybeReturnPromise.d.ts +1 -0
- package/dist/promise/untilConditionIsSatisfiedReducer.d.ts +1 -0
- package/dist/slugify/index.d.ts +2 -0
- package/dist/strAutoCast/index.d.ts +1 -0
- package/dist/strAutoCast/strAutoCast.d.ts +1 -0
- package/dist/strExpr/index.d.ts +2 -0
- package/dist/strExpr/strExpr.d.ts +14 -0
- package/dist/strExpr/syntheticJson.d.ts +1 -0
- package/dist/typeOf.d.ts +23 -1
- package/dist/url/index.d.ts +2 -0
- package/dist/url/isValidUrl.d.ts +1 -0
- package/dist/url/url.d.ts +18 -0
- package/dist/validate/common/validators/type.d.ts +2 -2
- package/package.json +8 -4
package/dist/promise/index.d.ts
CHANGED
|
@@ -2,3 +2,8 @@ export * from './promiseReduce';
|
|
|
2
2
|
export * from './resolveNestedPromises';
|
|
3
3
|
export * from './batchFn';
|
|
4
4
|
export * from './withTimeout';
|
|
5
|
+
export * from './makeDeferred';
|
|
6
|
+
export * from './isPromise';
|
|
7
|
+
export * from './maybeAsyncFn';
|
|
8
|
+
export * from './untilConditionIsSatisfiedReducer';
|
|
9
|
+
export * from './maybeReturnPromise';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isPromise(value: any): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
type AnyFn = (...args: any[]) => any;
|
|
2
|
+
type AnyAsyncFn = (...args: any[]) => Promise<any>;
|
|
3
|
+
export declare function hasNestedPromises(input: any): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Takes in a function and optionally takes in
|
|
6
|
+
* an async version of that same function.
|
|
7
|
+
* If no async version is defined, a default async
|
|
8
|
+
* version is prepared.
|
|
9
|
+
*
|
|
10
|
+
* Returns a new function that, before executing the wrapped
|
|
11
|
+
* functions verifies if there are any promises
|
|
12
|
+
* in the inputs and executes sync or async versions
|
|
13
|
+
* accordingly
|
|
14
|
+
*/
|
|
15
|
+
export declare function maybeAsyncFn({ syncFn, asyncFn, argsContainPromises, }: {
|
|
16
|
+
syncFn: AnyFn;
|
|
17
|
+
asyncFn?: AnyAsyncFn;
|
|
18
|
+
argsContainPromises?: (args: any[]) => boolean;
|
|
19
|
+
}): (...args: any[]) => any;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function maybeReturnPromise<InputT = any, ReturnT = any>(result: InputT | Promise<InputT>, parseResult: (result: InputT) => ReturnT): ReturnT | Promise<ReturnT>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function untilConditionIsSatisfiedReducer<ReturnT = any, InputT = any>(condition: (value: ReturnT) => boolean, reduce: (acc: ReturnT, value: InputT, index: number, allValues: InputT[]) => ReturnT | Promise<ReturnT>): (acc: ReturnT | Promise<ReturnT>, value: InputT, index: number, allValues: InputT[]) => ReturnT | Promise<ReturnT>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './strAutoCast';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function strAutoCast(str: string): string | boolean | number | JSON | null | undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type ExprFn = (...args: any[]) => (value: any) => any;
|
|
2
|
+
export type StrExprProps = {
|
|
3
|
+
expressions: string[] | Record<string, ExprFn>;
|
|
4
|
+
pipe?: string;
|
|
5
|
+
parseArgs?: (argsStr: string) => any;
|
|
6
|
+
};
|
|
7
|
+
type ParsedExprPart = [string, any[]];
|
|
8
|
+
export type ParsedExpr = ParsedExprPart[];
|
|
9
|
+
export declare function strExpr({ expressions, pipe, parseArgs, }: StrExprProps): {
|
|
10
|
+
parse: import("memoize-one").MemoizedFn<(this: any, expr: string) => ParsedExpr>;
|
|
11
|
+
apply: (exprParts: ParsedExpr | string, input: any) => any;
|
|
12
|
+
compile: <T = any, R = any>(expr: string) => (input: T) => R;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function syntheticJson(str: string): unknown;
|
package/dist/typeOf.d.ts
CHANGED
|
@@ -1,7 +1,29 @@
|
|
|
1
|
+
import { isPlainObject } from 'is-plain-object';
|
|
1
2
|
export type TypeTest = (value: any) => boolean;
|
|
2
3
|
type TypeMap = Record<string, TypeTest>;
|
|
3
4
|
export declare function typeMap<T extends TypeMap>(typeMap: T): T;
|
|
4
5
|
export declare function makeTypeOf<T extends TypeMap>(typeMap: T): (value: any) => keyof T | null;
|
|
5
|
-
export
|
|
6
|
+
export declare const DEFAULT_TYPES: {
|
|
7
|
+
null: (value: any) => boolean;
|
|
8
|
+
undefined: (value: any) => boolean;
|
|
9
|
+
boolean: (value: any) => boolean;
|
|
10
|
+
number: (value: any) => boolean;
|
|
11
|
+
bigint: (value: any) => boolean;
|
|
12
|
+
string: (value: any) => boolean;
|
|
13
|
+
symbol: (value: any) => boolean;
|
|
14
|
+
function: (value: any) => boolean;
|
|
15
|
+
object: typeof isPlainObject;
|
|
16
|
+
array: (value: any) => boolean;
|
|
17
|
+
regexp: (value: any) => boolean;
|
|
18
|
+
nan: (value: any) => boolean;
|
|
19
|
+
date: (value: any) => boolean;
|
|
20
|
+
map: (value: any) => boolean;
|
|
21
|
+
weakmap: (value: any) => boolean;
|
|
22
|
+
set: (value: any) => boolean;
|
|
23
|
+
weakset: (value: any) => boolean;
|
|
24
|
+
promise: (value: any) => boolean;
|
|
25
|
+
error: (value: any) => boolean;
|
|
26
|
+
};
|
|
27
|
+
export type TypeOfType = 'null' | 'undefined' | 'boolean' | 'number' | 'bigint' | 'string' | 'symbol' | 'function' | 'object' | 'array' | 'regexp' | 'nan' | 'date' | 'map' | 'weakmap' | 'set' | 'weakset' | 'promise' | 'error';
|
|
6
28
|
export declare const typeOf: (value: any) => "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "map" | "error" | "null" | "array" | "regexp" | "nan" | "date" | "weakmap" | "set" | "weakset" | "promise" | null;
|
|
7
29
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isValidUrl(url: string): boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { StringifyOptions } from 'query-string';
|
|
2
|
+
type SearchParams = Record<string, any>;
|
|
3
|
+
export type URLSpec = {
|
|
4
|
+
href?: string;
|
|
5
|
+
origin?: string;
|
|
6
|
+
protocol?: string;
|
|
7
|
+
username?: string;
|
|
8
|
+
password?: string;
|
|
9
|
+
host?: string;
|
|
10
|
+
hostname?: string;
|
|
11
|
+
port?: string;
|
|
12
|
+
pathname?: string;
|
|
13
|
+
search?: string;
|
|
14
|
+
searchParams?: SearchParams | [SearchParams, StringifyOptions];
|
|
15
|
+
hash?: string;
|
|
16
|
+
};
|
|
17
|
+
export declare function url(spec: URLSpec | string): string;
|
|
18
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TypeOfType } from '../../../typeOf';
|
|
2
2
|
import { CommonValidatorFn } from '../../types';
|
|
3
3
|
type ParsedExpectedType = {
|
|
4
|
-
type:
|
|
4
|
+
type: TypeOfType;
|
|
5
5
|
required: boolean;
|
|
6
6
|
};
|
|
7
7
|
type ExpectedTypesInput = (string | ParsedExpectedType)[] | string | ParsedExpectedType;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orioro/util",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"packageManager": "yarn@4.0.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"prepublish": "yarn build"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@orioro/dev": "
|
|
27
|
+
"@orioro/dev": "workspace:^",
|
|
28
|
+
"@orioro/jest-util": "workspace:^",
|
|
28
29
|
"@types/clone-deep": "^4.0.4",
|
|
29
30
|
"@types/jest": "^29.5.12",
|
|
30
31
|
"babel-jest": "^29.7.0",
|
|
@@ -32,11 +33,14 @@
|
|
|
32
33
|
"rollup": "^4.13.0"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
|
-
"dot-prop": "^8.0.2",
|
|
36
36
|
"eventemitter3": "^5.0.1",
|
|
37
37
|
"exponential-backoff": "^3.1.1",
|
|
38
38
|
"fast-copy": "^3.0.2",
|
|
39
|
+
"is-plain-object": "^5.0.0",
|
|
40
|
+
"lodash-es": "^4.17.21",
|
|
41
|
+
"memoize-one": "^6.0.0",
|
|
42
|
+
"query-string": "^9.1.1",
|
|
39
43
|
"traverse": "^0.6.9",
|
|
40
44
|
"type-fest": "^4.18.1"
|
|
41
45
|
}
|
|
42
|
-
}
|
|
46
|
+
}
|