Skip to content

Commit f995b5d

Browse files
committed
perf: build scope & remove utils console prefix
affects: @vue-async/utils
1 parent c807d04 commit f995b5d

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"scripts": {
1111
"build:es": "lerna run build:es --sort --parallel",
12-
"build": "lerna run build --sort --stream --scope=@vue-async/{module-loader,resource-manager,utils}",
12+
"build": "lerna run build --sort --stream --scope=@vue-async/*",
1313
"clean": "lerna clean --yes",
1414
"lint": "lerna run lint --parallel --stream",
1515
"lint:fix": "lerna run lint:fix --parallel",

packages/utils/src/tools.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,27 @@ const sharedPropertyDefinition = {
1515
set: noop,
1616
};
1717

18-
export function proxy(target: any, key: string, { get, set }: { get?: Function; set?: Function }) {
18+
export function proxy(target: any, key: string, { get, set }: { get?: Function; set?: Function } = {}) {
1919
sharedPropertyDefinition.get = get || noop;
2020
sharedPropertyDefinition.set = set || noop;
2121
Object.defineProperty(target, key, sharedPropertyDefinition);
2222
}
2323

24-
export function def(obj: Record<string, any>, key: string, val: any, enumerable?: boolean) {
24+
export function def(
25+
obj: Record<string, any>,
26+
key: string,
27+
val: any,
28+
{
29+
enumerable = false,
30+
writable = true,
31+
configurable = true,
32+
}: { enumerable?: boolean; writable?: boolean; configurable?: boolean } = {},
33+
) {
2534
Object.defineProperty(obj, key, {
2635
value: val,
27-
enumerable: !!enumerable,
28-
writable: true,
29-
configurable: true,
36+
enumerable,
37+
writable,
38+
configurable,
3039
});
3140
}
3241

@@ -41,21 +50,21 @@ export function createUid() {
4150

4251
export function assert(condition: any, msg: string) {
4352
if (!condition) {
44-
throw new Error(`[@vue-async] ${msg}`);
53+
throw new Error(`error: ${msg}`);
4554
}
4655
}
4756

4857
export function warn(condition: boolean, msg: string, vm?: _Vue) {
4958
if (!condition) {
5059
// eslint-disable-next-line no-console
51-
console.warn(`[@vue-async] ${msg}`, vm);
60+
console.warn(`warning: ${msg}`, vm);
5261
}
5362
}
5463

5564
export function error(condition: boolean, msg: string, vm?: _Vue) {
5665
if (!condition) {
5766
// eslint-disable-next-line no-console
58-
console.error(`[@vue-async] ${msg}`, vm);
67+
console.error(`error: ${msg}`, vm);
5968
}
6069
}
6170

0 commit comments

Comments
 (0)