@orpc/shared 0.45.1 → 0.47.0
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/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.mjs +14 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -75,11 +75,12 @@ declare function isObject(value: unknown): value is Record<PropertyKey, unknown>
|
|
|
75
75
|
* Check if the value satisfy a `object` type in typescript
|
|
76
76
|
*/
|
|
77
77
|
declare function isTypescriptObject(value: unknown): value is object & Record<PropertyKey, unknown>;
|
|
78
|
+
declare function clone<T>(value: T): T;
|
|
78
79
|
|
|
79
|
-
type MaybeOptionalOptions<TOptions> =
|
|
80
|
+
type MaybeOptionalOptions<TOptions> = Record<never, never> extends TOptions ? [options?: TOptions] : [options: TOptions];
|
|
80
81
|
type SetOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
81
82
|
|
|
82
83
|
type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) => Promisable<T>);
|
|
83
84
|
declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>): Promise<T extends Value<infer U, any> ? U : never>;
|
|
84
85
|
|
|
85
|
-
export { type AnyFunction, type InterceptableOptions, type Interceptor, type InterceptorOptions, type MaybeOptionalOptions, type OmitChainMethodDeep, type OnFinishState, type Segment, type SetOptional, type Value, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, set, stringifyJSON, toError, value };
|
|
86
|
+
export { type AnyFunction, type InterceptableOptions, type Interceptor, type InterceptorOptions, type MaybeOptionalOptions, type OmitChainMethodDeep, type OnFinishState, type Segment, type SetOptional, type Value, clone, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, set, stringifyJSON, toError, value };
|
package/dist/index.d.ts
CHANGED
|
@@ -75,11 +75,12 @@ declare function isObject(value: unknown): value is Record<PropertyKey, unknown>
|
|
|
75
75
|
* Check if the value satisfy a `object` type in typescript
|
|
76
76
|
*/
|
|
77
77
|
declare function isTypescriptObject(value: unknown): value is object & Record<PropertyKey, unknown>;
|
|
78
|
+
declare function clone<T>(value: T): T;
|
|
78
79
|
|
|
79
|
-
type MaybeOptionalOptions<TOptions> =
|
|
80
|
+
type MaybeOptionalOptions<TOptions> = Record<never, never> extends TOptions ? [options?: TOptions] : [options: TOptions];
|
|
80
81
|
type SetOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
81
82
|
|
|
82
83
|
type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) => Promisable<T>);
|
|
83
84
|
declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>): Promise<T extends Value<infer U, any> ? U : never>;
|
|
84
85
|
|
|
85
|
-
export { type AnyFunction, type InterceptableOptions, type Interceptor, type InterceptorOptions, type MaybeOptionalOptions, type OmitChainMethodDeep, type OnFinishState, type Segment, type SetOptional, type Value, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, set, stringifyJSON, toError, value };
|
|
86
|
+
export { type AnyFunction, type InterceptableOptions, type Interceptor, type InterceptorOptions, type MaybeOptionalOptions, type OmitChainMethodDeep, type OnFinishState, type Segment, type SetOptional, type Value, clone, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, set, stringifyJSON, toError, value };
|
package/dist/index.mjs
CHANGED
|
@@ -52,6 +52,19 @@ function isObject(value) {
|
|
|
52
52
|
function isTypescriptObject(value) {
|
|
53
53
|
return !!value && (typeof value === "object" || typeof value === "function");
|
|
54
54
|
}
|
|
55
|
+
function clone(value) {
|
|
56
|
+
if (Array.isArray(value)) {
|
|
57
|
+
return value.map(clone);
|
|
58
|
+
}
|
|
59
|
+
if (isObject(value)) {
|
|
60
|
+
const result = {};
|
|
61
|
+
for (const key in value) {
|
|
62
|
+
result[key] = clone(value[key]);
|
|
63
|
+
}
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
55
68
|
|
|
56
69
|
function toError(error) {
|
|
57
70
|
if (error instanceof Error) {
|
|
@@ -160,4 +173,4 @@ function value(value2, ...args) {
|
|
|
160
173
|
return value2;
|
|
161
174
|
}
|
|
162
175
|
|
|
163
|
-
export { findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, set, stringifyJSON, toError, value };
|
|
176
|
+
export { clone, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, set, stringifyJSON, toError, value };
|