phecda-core 4.1.0-alpha.1 → 4.1.0-alpha.2
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/README.md +3 -3
- package/dist/a.ts +17 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +17 -0
- package/dist/index.mjs +16 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
# phecda-core
|
|
2
|
-
provide base function and abstract limit to other phecda module
|
|
3
|
-
|
|
1
|
+
# phecda-core
|
|
2
|
+
provide base function and abstract limit to other phecda module
|
|
3
|
+
|
package/dist/a.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function Pick<T extends object, K extends keyof T>(obj: T, ...args: K[]): Pick<T, K> {
|
|
2
|
+
const result = {} as Pick<T, K>
|
|
3
|
+
for (const key of args) {
|
|
4
|
+
if (obj.hasOwnProperty(key)) {
|
|
5
|
+
result[key] = obj[key]
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return result
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const a = {
|
|
12
|
+
b: 1,
|
|
13
|
+
c: 1
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
const x = Pick(a, 'b', 'c')
|
package/dist/index.d.mts
CHANGED
|
@@ -91,6 +91,7 @@ declare function getMergedMeta(target: any, property?: PropertyKey, index?: numb
|
|
|
91
91
|
declare function wait(...instances: InstanceType<Construct>[]): Promise<any[]>;
|
|
92
92
|
declare function objectToClass<Obj extends Record<string, any>>(obj: Obj): new () => Obj;
|
|
93
93
|
declare function functionToClass<Func extends (...args: any) => object>(fn: Func): new (...args: Parameters<Func>) => ReturnType<Func>;
|
|
94
|
+
declare function omit<Class extends Construct, Key extends keyof InstanceType<Class>>(classFn: Class, ...properties: Key[]): Construct<Omit<InstanceType<Class>, Key>>;
|
|
94
95
|
|
|
95
96
|
declare const DataMap: InjectData;
|
|
96
97
|
declare function Provide<K extends keyof InjectData>(key: K, value: InjectData[K]): void;
|
|
@@ -113,4 +114,4 @@ declare abstract class Base {
|
|
|
113
114
|
private _unmount;
|
|
114
115
|
}
|
|
115
116
|
|
|
116
|
-
export { type AbConstruct, Assign, Base, CLEAR_KEY, type ClassValue, Clear, type Construct, DataMap, Effect, Empty, Err, type Events, Expose, Global, If, Init, Inject, type InjectData, Injectable, Isolate, type NameSpace, PHECDA_KEY, type Phecda, Pipeline, Provide, SHARE_KEY, Storage, type StorageParam, Tag, Unique, Unmount, Watcher, type WatcherParam, activeInstance, addDecoToClass, functionToClass, get, getInject, getMergedMeta, getMeta, getMetaKey, getMetaParams, getOwnMeta, getOwnMetaKey, getOwnMetaParams, getPhecdaFromTarget, getTag, init, invoke, invokeInit, invokeUnmount, isAsyncFunc, isPhecda, objectToClass, set, setInject, setMeta, wait };
|
|
117
|
+
export { type AbConstruct, Assign, Base, CLEAR_KEY, type ClassValue, Clear, type Construct, DataMap, Effect, Empty, Err, type Events, Expose, Global, If, Init, Inject, type InjectData, Injectable, Isolate, type NameSpace, PHECDA_KEY, type Phecda, Pipeline, Provide, SHARE_KEY, Storage, type StorageParam, Tag, Unique, Unmount, Watcher, type WatcherParam, activeInstance, addDecoToClass, functionToClass, get, getInject, getMergedMeta, getMeta, getMetaKey, getMetaParams, getOwnMeta, getOwnMetaKey, getOwnMetaParams, getPhecdaFromTarget, getTag, init, invoke, invokeInit, invokeUnmount, isAsyncFunc, isPhecda, objectToClass, omit, set, setInject, setMeta, wait };
|
package/dist/index.d.ts
CHANGED
|
@@ -91,6 +91,7 @@ declare function getMergedMeta(target: any, property?: PropertyKey, index?: numb
|
|
|
91
91
|
declare function wait(...instances: InstanceType<Construct>[]): Promise<any[]>;
|
|
92
92
|
declare function objectToClass<Obj extends Record<string, any>>(obj: Obj): new () => Obj;
|
|
93
93
|
declare function functionToClass<Func extends (...args: any) => object>(fn: Func): new (...args: Parameters<Func>) => ReturnType<Func>;
|
|
94
|
+
declare function omit<Class extends Construct, Key extends keyof InstanceType<Class>>(classFn: Class, ...properties: Key[]): Construct<Omit<InstanceType<Class>, Key>>;
|
|
94
95
|
|
|
95
96
|
declare const DataMap: InjectData;
|
|
96
97
|
declare function Provide<K extends keyof InjectData>(key: K, value: InjectData[K]): void;
|
|
@@ -113,4 +114,4 @@ declare abstract class Base {
|
|
|
113
114
|
private _unmount;
|
|
114
115
|
}
|
|
115
116
|
|
|
116
|
-
export { type AbConstruct, Assign, Base, CLEAR_KEY, type ClassValue, Clear, type Construct, DataMap, Effect, Empty, Err, type Events, Expose, Global, If, Init, Inject, type InjectData, Injectable, Isolate, type NameSpace, PHECDA_KEY, type Phecda, Pipeline, Provide, SHARE_KEY, Storage, type StorageParam, Tag, Unique, Unmount, Watcher, type WatcherParam, activeInstance, addDecoToClass, functionToClass, get, getInject, getMergedMeta, getMeta, getMetaKey, getMetaParams, getOwnMeta, getOwnMetaKey, getOwnMetaParams, getPhecdaFromTarget, getTag, init, invoke, invokeInit, invokeUnmount, isAsyncFunc, isPhecda, objectToClass, set, setInject, setMeta, wait };
|
|
117
|
+
export { type AbConstruct, Assign, Base, CLEAR_KEY, type ClassValue, Clear, type Construct, DataMap, Effect, Empty, Err, type Events, Expose, Global, If, Init, Inject, type InjectData, Injectable, Isolate, type NameSpace, PHECDA_KEY, type Phecda, Pipeline, Provide, SHARE_KEY, Storage, type StorageParam, Tag, Unique, Unmount, Watcher, type WatcherParam, activeInstance, addDecoToClass, functionToClass, get, getInject, getMergedMeta, getMeta, getMetaKey, getMetaParams, getOwnMeta, getOwnMetaKey, getOwnMetaParams, getPhecdaFromTarget, getTag, init, invoke, invokeInit, invokeUnmount, isAsyncFunc, isPhecda, objectToClass, omit, set, setInject, setMeta, wait };
|
package/dist/index.js
CHANGED
|
@@ -73,6 +73,7 @@ __export(index_exports, {
|
|
|
73
73
|
isAsyncFunc: () => isAsyncFunc,
|
|
74
74
|
isPhecda: () => isPhecda,
|
|
75
75
|
objectToClass: () => objectToClass,
|
|
76
|
+
omit: () => omit,
|
|
76
77
|
set: () => set,
|
|
77
78
|
setInject: () => setInject,
|
|
78
79
|
setMeta: () => setMeta,
|
|
@@ -329,6 +330,21 @@ function functionToClass(fn) {
|
|
|
329
330
|
}
|
|
330
331
|
};
|
|
331
332
|
}
|
|
333
|
+
function omit(classFn, ...properties) {
|
|
334
|
+
const newClass = class extends classFn {
|
|
335
|
+
constructor(...args) {
|
|
336
|
+
super(...args);
|
|
337
|
+
properties.forEach((k) => {
|
|
338
|
+
delete this[k];
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
getMetaKey(classFn).forEach((k) => {
|
|
343
|
+
if (properties.includes(k))
|
|
344
|
+
addDecoToClass(newClass, k, Clear);
|
|
345
|
+
});
|
|
346
|
+
return newClass;
|
|
347
|
+
}
|
|
332
348
|
|
|
333
349
|
// src/di.ts
|
|
334
350
|
var DataMap = {};
|
|
@@ -546,6 +562,7 @@ Base = __decorateClass([
|
|
|
546
562
|
isAsyncFunc,
|
|
547
563
|
isPhecda,
|
|
548
564
|
objectToClass,
|
|
565
|
+
omit,
|
|
549
566
|
set,
|
|
550
567
|
setInject,
|
|
551
568
|
setMeta,
|
package/dist/index.mjs
CHANGED
|
@@ -258,6 +258,21 @@ function functionToClass(fn) {
|
|
|
258
258
|
}
|
|
259
259
|
};
|
|
260
260
|
}
|
|
261
|
+
function omit(classFn, ...properties) {
|
|
262
|
+
const newClass = class extends classFn {
|
|
263
|
+
constructor(...args) {
|
|
264
|
+
super(...args);
|
|
265
|
+
properties.forEach((k) => {
|
|
266
|
+
delete this[k];
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
getMetaKey(classFn).forEach((k) => {
|
|
271
|
+
if (properties.includes(k))
|
|
272
|
+
addDecoToClass(newClass, k, Clear);
|
|
273
|
+
});
|
|
274
|
+
return newClass;
|
|
275
|
+
}
|
|
261
276
|
|
|
262
277
|
// src/di.ts
|
|
263
278
|
var DataMap = {};
|
|
@@ -474,6 +489,7 @@ export {
|
|
|
474
489
|
isAsyncFunc,
|
|
475
490
|
isPhecda,
|
|
476
491
|
objectToClass,
|
|
492
|
+
omit,
|
|
477
493
|
set,
|
|
478
494
|
setInject,
|
|
479
495
|
setMeta,
|