@tstdl/base 0.84.5 → 0.84.7
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/browser/document-controller.d.ts +1 -1
- package/browser/document-controller.js +1 -1
- package/browser/page-controller.d.ts +1 -1
- package/browser/page-controller.js +1 -1
- package/browser/utils.d.ts +9 -1
- package/browser/utils.js +14 -15
- package/http/client/http-client-request.d.ts +3 -0
- package/http/client/http-client-request.js +4 -0
- package/http/client/http-client.js +4 -1
- package/package.json +1 -1
- package/signals/api.d.ts +1 -0
- package/signals/api.js +1 -18
- package/signals/computed-with-dependencies.d.ts +2 -0
- package/signals/computed-with-dependencies.js +36 -0
- package/signals/implementation/computed.d.ts +0 -1
- package/signals/implementation/computed.js +1 -8
- package/signals/implementation/configure.d.ts +1 -0
- package/signals/implementation/configure.js +38 -0
- package/signals/implementation/index.d.ts +1 -0
- package/signals/implementation/index.js +1 -0
- package/signals/index.d.ts +1 -0
- package/signals/index.js +1 -0
- package/types.d.ts +2 -2
- package/utils/object/object.d.ts +4 -0
- package/utils/object/object.js +4 -0
|
@@ -21,6 +21,6 @@ export declare class DocumentController extends LocatorController {
|
|
|
21
21
|
waitForLoadState(...args: Parameters<Page['waitForLoadState']>): Promise<void>;
|
|
22
22
|
waitForUrl(...args: Parameters<Page['waitForURL']>): Promise<void>;
|
|
23
23
|
waitForElement(selector: string, options?: Parameters<Page['waitForSelector']>[1]): Promise<ElementHandle>;
|
|
24
|
-
|
|
24
|
+
locateInFrame(frameSelector: string): LocatorController;
|
|
25
25
|
waitForFrame(selector: string, options?: Parameters<Page['waitForSelector']>[1]): Promise<FrameController>;
|
|
26
26
|
}
|
|
@@ -61,7 +61,7 @@ class DocumentController extends import_locator_controller.LocatorController {
|
|
|
61
61
|
}
|
|
62
62
|
return element;
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
locateInFrame(frameSelector) {
|
|
65
65
|
const locator = this.document.frameLocator(frameSelector);
|
|
66
66
|
return new import_locator_controller.LocatorController(locator, this.elementControllerOptions);
|
|
67
67
|
}
|
|
@@ -23,7 +23,7 @@ export declare class PageController extends DocumentController implements AsyncD
|
|
|
23
23
|
* @param frameSelector frame name, url or url predicate
|
|
24
24
|
* @returns
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
frame(frameSelector: Parameters<Page['frame']>[0]): FrameController;
|
|
27
27
|
renderPdf(options?: PdfRenderOptions & Abortable): Promise<Uint8Array>;
|
|
28
28
|
renderPdfStream(options?: PdfRenderOptions & Abortable): ReadableStream<Uint8Array>;
|
|
29
29
|
}
|
|
@@ -59,7 +59,7 @@ class PageController extends import_document_controller.DocumentController {
|
|
|
59
59
|
* @param frameSelector frame name, url or url predicate
|
|
60
60
|
* @returns
|
|
61
61
|
*/
|
|
62
|
-
|
|
62
|
+
frame(frameSelector) {
|
|
63
63
|
const frame = this.page.frame(frameSelector);
|
|
64
64
|
if ((0, import_type_guards.isNull)(frame)) {
|
|
65
65
|
throw new Error("Frame not found.");
|
package/browser/utils.d.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
import type { SimplifyObject, Unoptionalize } from '../types.js';
|
|
1
2
|
import type { BrowserType, ElementHandle, LaunchOptions, Locator } from 'playwright';
|
|
2
3
|
import type { NewBrowserContextOptions } from './browser-controller.js';
|
|
3
4
|
import type { NewBrowserOptions } from './browser.service.js';
|
|
5
|
+
declare const browserTypes: {
|
|
6
|
+
chromium: BrowserType<{}>;
|
|
7
|
+
firefox: BrowserType<{}>;
|
|
8
|
+
webkit: BrowserType<{}>;
|
|
9
|
+
};
|
|
10
|
+
export declare function replaceBrowsers(browsers: SimplifyObject<Unoptionalize<Partial<typeof browserTypes>>>): void;
|
|
4
11
|
export declare function getLaunchOptions(options: NewBrowserOptions): LaunchOptions;
|
|
5
12
|
export declare function mergeNewBrowserContextOptions(a: NewBrowserContextOptions | undefined, b?: NewBrowserContextOptions, c?: NewBrowserContextOptions): NewBrowserContextOptions;
|
|
6
|
-
export declare function getBrowserType(type:
|
|
13
|
+
export declare function getBrowserType(type: keyof typeof browserTypes | undefined): BrowserType;
|
|
7
14
|
export declare function isLocator(value: Locator | ElementHandle): value is Locator;
|
|
8
15
|
export declare function isElementHandle(value: Locator | ElementHandle): value is ElementHandle;
|
|
16
|
+
export {};
|
package/browser/utils.js
CHANGED
|
@@ -22,13 +22,23 @@ __export(utils_exports, {
|
|
|
22
22
|
getLaunchOptions: () => getLaunchOptions,
|
|
23
23
|
isElementHandle: () => isElementHandle,
|
|
24
24
|
isLocator: () => isLocator,
|
|
25
|
-
mergeNewBrowserContextOptions: () => mergeNewBrowserContextOptions
|
|
25
|
+
mergeNewBrowserContextOptions: () => mergeNewBrowserContextOptions,
|
|
26
|
+
replaceBrowsers: () => replaceBrowsers
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(utils_exports);
|
|
28
29
|
var import_not_supported_error = require("../error/not-supported.error.js");
|
|
29
30
|
var import_object = require("../utils/object/object.js");
|
|
30
31
|
var import_type_guards = require("../utils/type-guards.js");
|
|
31
32
|
var import_playwright = require("playwright");
|
|
33
|
+
const browserTypes = {
|
|
34
|
+
chromium: import_playwright.chromium,
|
|
35
|
+
firefox: import_playwright.firefox,
|
|
36
|
+
webkit: import_playwright.webkit
|
|
37
|
+
};
|
|
38
|
+
function replaceBrowsers(browsers) {
|
|
39
|
+
const filtered = (0, import_object.filterUndefinedObjectProperties)(browsers);
|
|
40
|
+
(0, import_object.copyObjectProperties)(filtered, browserTypes);
|
|
41
|
+
}
|
|
32
42
|
function getLaunchOptions(options) {
|
|
33
43
|
const { windowSize, browserArguments, headless } = options;
|
|
34
44
|
const args = [`--window-size=${windowSize?.width ?? 1e3},${windowSize?.height ?? 1e3}`, ...browserArguments ?? []];
|
|
@@ -44,20 +54,9 @@ function mergeNewBrowserContextOptions(a, b, c) {
|
|
|
44
54
|
};
|
|
45
55
|
}
|
|
46
56
|
function getBrowserType(type) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
case void 0:
|
|
51
|
-
browserType = import_playwright.chromium;
|
|
52
|
-
break;
|
|
53
|
-
case "firefox":
|
|
54
|
-
browserType = import_playwright.firefox;
|
|
55
|
-
break;
|
|
56
|
-
case "webkit":
|
|
57
|
-
browserType = import_playwright.webkit;
|
|
58
|
-
break;
|
|
59
|
-
default:
|
|
60
|
-
throw new import_not_supported_error.NotSupportedError(`Browser type ${type} is not supported.`);
|
|
57
|
+
const browserType = browserTypes[type ?? "chromium"];
|
|
58
|
+
if ((0, import_type_guards.isUndefined)(browserType)) {
|
|
59
|
+
throw new import_not_supported_error.NotSupportedError(`Browser type ${type} is not supported.`);
|
|
61
60
|
}
|
|
62
61
|
return browserType;
|
|
63
62
|
}
|
|
@@ -57,11 +57,14 @@ export declare class HttpClientRequest implements Disposable {
|
|
|
57
57
|
* automatically maps parameters to `urlParameters`, `query` and `body`
|
|
58
58
|
* depending on whether the `url` has parameters specified, the request `method`
|
|
59
59
|
* and if there is already a `body` or not
|
|
60
|
+
* @see mapParameters
|
|
60
61
|
* @see mapParametersToUrl
|
|
61
62
|
* @see mapParametersToQuery
|
|
62
63
|
* @see mapParametersToBody
|
|
63
64
|
*/
|
|
64
65
|
parameters: UndefinableJsonObject | undefined;
|
|
66
|
+
/** if false, disable parameters mapping completely */
|
|
67
|
+
mapParameters: boolean;
|
|
65
68
|
mapParametersToUrl: boolean;
|
|
66
69
|
mapParametersToQuery: boolean;
|
|
67
70
|
mapParametersToBody: boolean;
|
|
@@ -38,11 +38,14 @@ class HttpClientRequest {
|
|
|
38
38
|
* automatically maps parameters to `urlParameters`, `query` and `body`
|
|
39
39
|
* depending on whether the `url` has parameters specified, the request `method`
|
|
40
40
|
* and if there is already a `body` or not
|
|
41
|
+
* @see mapParameters
|
|
41
42
|
* @see mapParametersToUrl
|
|
42
43
|
* @see mapParametersToQuery
|
|
43
44
|
* @see mapParametersToBody
|
|
44
45
|
*/
|
|
45
46
|
parameters;
|
|
47
|
+
/** if false, disable parameters mapping completely */
|
|
48
|
+
mapParameters;
|
|
46
49
|
mapParametersToUrl;
|
|
47
50
|
mapParametersToQuery;
|
|
48
51
|
mapParametersToBody;
|
|
@@ -110,6 +113,7 @@ class HttpClientRequest {
|
|
|
110
113
|
const requestOptions = (0, import_type_guards.isString)(urlOrObject) ? options : urlOrObject;
|
|
111
114
|
this.headers = new import_http_headers.HttpHeaders(requestOptions.headers);
|
|
112
115
|
this.parameters = requestOptions.parameters;
|
|
116
|
+
this.mapParameters = requestOptions.mapParameters ?? true;
|
|
113
117
|
this.mapParametersToUrl = requestOptions.mapParametersToUrl ?? true;
|
|
114
118
|
this.mapParametersToQuery = requestOptions.mapParametersToQuery ?? true;
|
|
115
119
|
this.mapParametersToBody = requestOptions.mapParametersToBody ?? true;
|
|
@@ -231,6 +231,9 @@ HttpClient = __decorate([
|
|
|
231
231
|
], HttpClient);
|
|
232
232
|
function getBuildRequestUrlMiddleware(baseUrl) {
|
|
233
233
|
async function buildUrlParametersMiddleware(request, next) {
|
|
234
|
+
if (!request.mapParameters) {
|
|
235
|
+
return next(request);
|
|
236
|
+
}
|
|
234
237
|
const modifiedRequest = mapParameters(request, baseUrl);
|
|
235
238
|
return next(modifiedRequest);
|
|
236
239
|
}
|
|
@@ -267,7 +270,7 @@ async function addRequestHeadersMiddleware(request, next) {
|
|
|
267
270
|
async function errorMiddleware(request, next) {
|
|
268
271
|
try {
|
|
269
272
|
const response = await next(request);
|
|
270
|
-
if (request.throwOnNon200 && (response.statusCode < 200 || response.statusCode >=
|
|
273
|
+
if (request.throwOnNon200 && (response.statusCode < 200 || response.statusCode >= 400)) {
|
|
271
274
|
const httpError = await import_http_error.HttpError.create(import_http_error.HttpErrorReason.Non200StatusCode, request, response, `Status code ${response.statusCode}.`);
|
|
272
275
|
throw httpError;
|
|
273
276
|
}
|
package/package.json
CHANGED
package/signals/api.d.ts
CHANGED
|
@@ -12,3 +12,4 @@ export declare let computed: typeof Types.computed;
|
|
|
12
12
|
export declare let effect: typeof Types.effect;
|
|
13
13
|
export declare let untracked: typeof Types.untracked;
|
|
14
14
|
export declare let isSignal: typeof Types.isSignal;
|
|
15
|
+
export declare function configureSignals(configuration: SignalsConfiguration): void;
|
package/signals/api.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,25 +15,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var api_exports = {};
|
|
30
20
|
__export(api_exports, {
|
|
31
21
|
computed: () => computed,
|
|
22
|
+
configureSignals: () => configureSignals,
|
|
32
23
|
effect: () => effect,
|
|
33
24
|
isSignal: () => isSignal,
|
|
34
25
|
signal: () => signal,
|
|
35
26
|
untracked: () => untracked
|
|
36
27
|
});
|
|
37
28
|
module.exports = __toCommonJS(api_exports);
|
|
38
|
-
var AngularCore = __toESM(require("@angular/core"), 1);
|
|
39
29
|
let signal;
|
|
40
30
|
let computed;
|
|
41
31
|
let effect;
|
|
@@ -48,10 +38,3 @@ function configureSignals(configuration) {
|
|
|
48
38
|
untracked = configuration.untracked;
|
|
49
39
|
isSignal = configuration.isSignal;
|
|
50
40
|
}
|
|
51
|
-
configureSignals({
|
|
52
|
-
signal: AngularCore.signal,
|
|
53
|
-
computed: AngularCore.computed,
|
|
54
|
-
effect: AngularCore.effect,
|
|
55
|
-
untracked: AngularCore.untracked,
|
|
56
|
-
isSignal: AngularCore.isSignal
|
|
57
|
-
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var computed_with_dependencies_exports = {};
|
|
20
|
+
__export(computed_with_dependencies_exports, {
|
|
21
|
+
computedWithDependencies: () => computedWithDependencies
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(computed_with_dependencies_exports);
|
|
24
|
+
var import_api = require("./api.js");
|
|
25
|
+
function computedWithDependencies(computation, dependencies, options = {}) {
|
|
26
|
+
if (dependencies.length == 0) {
|
|
27
|
+
throw new Error("No additional dependencies provided.");
|
|
28
|
+
}
|
|
29
|
+
function actualComputation() {
|
|
30
|
+
for (const dependency of dependencies) {
|
|
31
|
+
dependency();
|
|
32
|
+
}
|
|
33
|
+
return computation();
|
|
34
|
+
}
|
|
35
|
+
return (0, import_api.computed)(actualComputation, options);
|
|
36
|
+
}
|
|
@@ -16,7 +16,6 @@ export interface CreateComputedOptions<T> {
|
|
|
16
16
|
* A comparison function which defines equality for computed values.
|
|
17
17
|
*/
|
|
18
18
|
equal?: ValueEqualityFn<T>;
|
|
19
|
-
additionalDependencies?: Signal<any>[];
|
|
20
19
|
}
|
|
21
20
|
/**
|
|
22
21
|
* Create a computed `Signal` which derives a reactive value from an expression.
|
|
@@ -21,7 +21,6 @@ __export(computed_exports, {
|
|
|
21
21
|
computed: () => computed
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(computed_exports);
|
|
24
|
-
var import_type_guards = require("../../utils/type-guards.js");
|
|
25
24
|
var import_api = require("./api.js");
|
|
26
25
|
var import_graph = require("./graph.js");
|
|
27
26
|
/**
|
|
@@ -32,13 +31,7 @@ var import_graph = require("./graph.js");
|
|
|
32
31
|
* found in the LICENSE file at https://angular.io/license
|
|
33
32
|
*/
|
|
34
33
|
function computed(computation, options = {}) {
|
|
35
|
-
const
|
|
36
|
-
for (const dependency of options.additionalDependencies) {
|
|
37
|
-
dependency();
|
|
38
|
-
}
|
|
39
|
-
return computation();
|
|
40
|
-
};
|
|
41
|
-
const node = new ComputedImpl(actualComputation, options.equal ?? import_api.defaultEquals);
|
|
34
|
+
const node = new ComputedImpl(computation, options.equal ?? import_api.defaultEquals);
|
|
42
35
|
return (0, import_api.createSignalFromFunction)(node, node.signal.bind(node));
|
|
43
36
|
}
|
|
44
37
|
const UNSET = Symbol("UNSET");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function configureDefaultSignalsImplementation(): void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var configure_exports = {};
|
|
20
|
+
__export(configure_exports, {
|
|
21
|
+
configureDefaultSignalsImplementation: () => configureDefaultSignalsImplementation
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(configure_exports);
|
|
24
|
+
var import_api = require("../api.js");
|
|
25
|
+
var import_api2 = require("./api.js");
|
|
26
|
+
var import_computed = require("./computed.js");
|
|
27
|
+
var import_effect = require("./effect.js");
|
|
28
|
+
var import_signal = require("./signal.js");
|
|
29
|
+
var import_untracked = require("./untracked.js");
|
|
30
|
+
function configureDefaultSignalsImplementation() {
|
|
31
|
+
(0, import_api.configureSignals)({
|
|
32
|
+
signal: import_signal.signal,
|
|
33
|
+
computed: import_computed.computed,
|
|
34
|
+
effect: import_effect.effect,
|
|
35
|
+
untracked: import_untracked.untracked,
|
|
36
|
+
isSignal: import_api2.isSignal
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -17,6 +17,7 @@ var implementation_exports = {};
|
|
|
17
17
|
module.exports = __toCommonJS(implementation_exports);
|
|
18
18
|
__reExport(implementation_exports, require("./api.js"), module.exports);
|
|
19
19
|
__reExport(implementation_exports, require("./computed.js"), module.exports);
|
|
20
|
+
__reExport(implementation_exports, require("./configure.js"), module.exports);
|
|
20
21
|
__reExport(implementation_exports, require("./effect.js"), module.exports);
|
|
21
22
|
__reExport(implementation_exports, require("./graph.js"), module.exports);
|
|
22
23
|
__reExport(implementation_exports, require("./signal.js"), module.exports);
|
package/signals/index.d.ts
CHANGED
package/signals/index.js
CHANGED
|
@@ -16,6 +16,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
16
16
|
var signals_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(signals_exports);
|
|
18
18
|
__reExport(signals_exports, require("./api.js"), module.exports);
|
|
19
|
+
__reExport(signals_exports, require("./computed-with-dependencies.js"), module.exports);
|
|
19
20
|
__reExport(signals_exports, require("./pipe.js"), module.exports);
|
|
20
21
|
__reExport(signals_exports, require("./to-observable.js"), module.exports);
|
|
21
22
|
__reExport(signals_exports, require("./to-signal.js"), module.exports);
|
package/types.d.ts
CHANGED
|
@@ -112,10 +112,10 @@ export type OmitBy<T, V> = Omit<T, {
|
|
|
112
112
|
* normalize properties of a type that allow `undefined` to make them optional.
|
|
113
113
|
*/
|
|
114
114
|
export type Optionalize<T extends object> = OmitBy<T, undefined> & Partial<PickBy<T, undefined>>;
|
|
115
|
-
export type
|
|
115
|
+
export type SimplifiedOptionalize<T extends object> = SimplifyObject<Optionalize<T>>;
|
|
116
|
+
export type Unoptionalize<T extends object> = SimplifyObject<OmitBy<T, undefined> & {
|
|
116
117
|
[P in PropertiesOfType<T, undefined>]: T[P] | undefined;
|
|
117
118
|
}>;
|
|
118
|
-
export type SimplifiedOptionalize<T extends object> = Simplify<Optionalize<T>>;
|
|
119
119
|
export type Merge<T1, T2> = SimplifyObject<Except<T1, Extract<keyof T1, keyof T2>> & T2>;
|
|
120
120
|
export type Simplify<T> = T extends BuiltIn ? T : T extends readonly any[] ? SimplifyArray<T> : T extends Record ? SimplifyObject<T> : T;
|
|
121
121
|
export type SimplifyObject<T extends Record> = {
|
package/utils/object/object.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { FromEntries, ObjectLiteral, PickBy, Record } from '../../types.js';
|
|
2
|
+
import type { IsEqual } from 'type-fest';
|
|
2
3
|
export declare function hasOwnProperty<T extends Record>(obj: T, key: keyof T): boolean;
|
|
3
4
|
/**
|
|
4
5
|
* returns object entries including those with symbols keys (which Object.entries does not)
|
|
@@ -18,6 +19,9 @@ export declare function mapObjectValuesAsync<T extends ObjectLiteral, V>(object:
|
|
|
18
19
|
export declare function filterObject<T extends ObjectLiteral, U extends T[keyof T]>(object: T, predicate: (value: T[keyof T], key: keyof T) => value is U): PickBy<T, U>;
|
|
19
20
|
export declare function filterObject<T extends ObjectLiteral>(object: T, predicate: (value: T[keyof T], key: keyof T) => boolean): Partial<T>;
|
|
20
21
|
export declare function filterObjectAsync<T extends ObjectLiteral>(object: T, predicate: (value: T[keyof T], key: keyof T) => Promise<boolean>): Promise<Partial<T>>;
|
|
22
|
+
export declare function filterUndefinedObjectProperties<T extends ObjectLiteral>(object: T): {
|
|
23
|
+
[P in keyof T]?: IsEqual<T[P], undefined> extends true ? never : Exclude<T[P], undefined>;
|
|
24
|
+
};
|
|
21
25
|
export declare function copyObjectProperties<T extends ObjectLiteral, U extends T>(source: T, target: U): void;
|
|
22
26
|
export declare function getGetter<T extends ObjectLiteral, U extends keyof T>(obj: T, property: keyof T, bind: boolean): () => T[U];
|
|
23
27
|
export declare function deepObjectEntries(object: ObjectLiteral, keepInnerObjects?: boolean, prefix?: string): [string, any][];
|
package/utils/object/object.js
CHANGED
|
@@ -22,6 +22,7 @@ __export(object_exports, {
|
|
|
22
22
|
deepObjectEntries: () => deepObjectEntries,
|
|
23
23
|
filterObject: () => filterObject,
|
|
24
24
|
filterObjectAsync: () => filterObjectAsync,
|
|
25
|
+
filterUndefinedObjectProperties: () => filterUndefinedObjectProperties,
|
|
25
26
|
fromEntries: () => fromEntries,
|
|
26
27
|
getGetter: () => getGetter,
|
|
27
28
|
hasOwnProperty: () => hasOwnProperty,
|
|
@@ -78,6 +79,9 @@ async function filterObjectAsync(object, predicate) {
|
|
|
78
79
|
const mappedEntries = await (0, import_to_array.toArrayAsync)((0, import_filter.filterAsync)(entries, async ([key, value]) => predicate(value, key)));
|
|
79
80
|
return Object.fromEntries(mappedEntries);
|
|
80
81
|
}
|
|
82
|
+
function filterUndefinedObjectProperties(object) {
|
|
83
|
+
return filterObject(object, import_type_guards.isDefined);
|
|
84
|
+
}
|
|
81
85
|
function copyObjectProperties(source, target) {
|
|
82
86
|
for (const key of objectKeys(source)) {
|
|
83
87
|
target[key] = source[key];
|