@powfix/core-js 0.24.5 → 0.25.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.
@@ -19,13 +19,14 @@ function _create_class(Constructor, protoProps, staticProps) {
19
19
  return Constructor;
20
20
  }
21
21
  var chunkJE77HYXB_cjs = require('../../chunk-JE77HYXB.cjs');
22
- var _tasks;
23
- var DedupedTaskManager = /*#__PURE__*/ function() {
24
- function DedupedTaskManager() {
25
- _class_call_check(this, DedupedTaskManager);
26
- chunkJE77HYXB_cjs.__privateAdd(this, _tasks, /* @__PURE__ */ new Map());
22
+ var _instance, _tasks;
23
+ var _DedupedTaskManager = /*#__PURE__*/ function() {
24
+ function _DedupedTaskManager() {
25
+ _class_call_check(this, _DedupedTaskManager);
26
+ chunkJE77HYXB_cjs.__privateAdd(this, _tasks);
27
+ chunkJE77HYXB_cjs.__privateSet(this, _tasks, /* @__PURE__ */ new Map());
27
28
  }
28
- _create_class(DedupedTaskManager, [
29
+ _create_class(_DedupedTaskManager, [
29
30
  {
30
31
  key: "run",
31
32
  value: function run(key, factory, options) {
@@ -55,8 +56,19 @@ var DedupedTaskManager = /*#__PURE__*/ function() {
55
56
  return chunkJE77HYXB_cjs.__privateGet(this, _tasks);
56
57
  }
57
58
  }
59
+ ], [
60
+ {
61
+ key: "getInstance",
62
+ value: function getInstance() {
63
+ var _chunkJE77HYXB_cjs___privateGet;
64
+ return (_chunkJE77HYXB_cjs___privateGet = chunkJE77HYXB_cjs.__privateGet(this, _instance)) !== null && _chunkJE77HYXB_cjs___privateGet !== void 0 ? _chunkJE77HYXB_cjs___privateGet : chunkJE77HYXB_cjs.__privateSet(this, _instance, new _DedupedTaskManager());
65
+ }
66
+ }
58
67
  ]);
59
- return DedupedTaskManager;
68
+ return _DedupedTaskManager;
60
69
  }();
70
+ _instance = new WeakMap();
61
71
  _tasks = new WeakMap();
72
+ chunkJE77HYXB_cjs.__privateAdd(_DedupedTaskManager, _instance);
73
+ var DedupedTaskManager = _DedupedTaskManager;
62
74
  exports.DedupedTaskManager = DedupedTaskManager;
@@ -1,6 +1,8 @@
1
1
  import type { DedupedTaskManagerRunOptions as RunOptions, DedupedTaskManagerTaskKey as TaskKey } from "./DedupedTaskManager.types.js";
2
2
  export declare class DedupedTaskManager {
3
3
  #private;
4
+ static getInstance(): DedupedTaskManager;
5
+ constructor();
4
6
  run<T>(key: TaskKey, factory: () => Promise<T>, options?: RunOptions): Promise<T>;
5
7
  get tasks(): Map<TaskKey, Promise<any>>;
6
8
  }
@@ -17,15 +17,16 @@ function _create_class(Constructor, protoProps, staticProps) {
17
17
  if (staticProps) _defineProperties(Constructor, staticProps);
18
18
  return Constructor;
19
19
  }
20
- import { __privateAdd, __privateGet } from '../../chunk-AQ5VUG5P.js';
21
- var _tasks;
22
- var DedupedTaskManager = /*#__PURE__*/ function() {
20
+ import { __privateAdd, __privateSet, __privateGet } from '../../chunk-AQ5VUG5P.js';
21
+ var _instance, _tasks;
22
+ var _DedupedTaskManager = /*#__PURE__*/ function() {
23
23
  "use strict";
24
- function DedupedTaskManager() {
25
- _class_call_check(this, DedupedTaskManager);
26
- __privateAdd(this, _tasks, /* @__PURE__ */ new Map());
24
+ function _DedupedTaskManager() {
25
+ _class_call_check(this, _DedupedTaskManager);
26
+ __privateAdd(this, _tasks);
27
+ __privateSet(this, _tasks, /* @__PURE__ */ new Map());
27
28
  }
28
- _create_class(DedupedTaskManager, [
29
+ _create_class(_DedupedTaskManager, [
29
30
  {
30
31
  key: "run",
31
32
  value: function run(key, factory, options) {
@@ -55,8 +56,19 @@ var DedupedTaskManager = /*#__PURE__*/ function() {
55
56
  return __privateGet(this, _tasks);
56
57
  }
57
58
  }
59
+ ], [
60
+ {
61
+ key: "getInstance",
62
+ value: function getInstance() {
63
+ var _$__privateGet;
64
+ return (_$__privateGet = __privateGet(this, _instance)) !== null && _$__privateGet !== void 0 ? _$__privateGet : __privateSet(this, _instance, new _DedupedTaskManager());
65
+ }
66
+ }
58
67
  ]);
59
- return DedupedTaskManager;
68
+ return _DedupedTaskManager;
60
69
  }();
70
+ _instance = new WeakMap();
61
71
  _tasks = new WeakMap();
72
+ __privateAdd(_DedupedTaskManager, _instance);
73
+ var DedupedTaskManager = _DedupedTaskManager;
62
74
  export { DedupedTaskManager };
@@ -0,0 +1 @@
1
+ 'use strict';
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Makes all properties required and strips `null` from property types.
3
+ *
4
+ * @example
5
+ * type Input = {
6
+ * a?: string | null
7
+ * b: number | null
8
+ * }
9
+ * type Result = CustomRequired<Input>
10
+ * // {
11
+ * // a: string
12
+ * // b: number
13
+ * // }
14
+ */
15
+ type CustomRequired<T> = {
16
+ [P in keyof T]-?: T[P] extends infer A | null ? A : T[P];
17
+ };
18
+ type R = Record<string, any>;
19
+ /**
20
+ * Extracts keys of properties whose value is an object (but not arrays).
21
+ *
22
+ * @example
23
+ * type Example = {
24
+ * id: number
25
+ * info: { name: string }
26
+ * tags: string[]
27
+ * }
28
+ * type ObjKeys = ObjectKeys<Example> // "info"
29
+ */
30
+ export type ObjectKeys<T, RT = CustomRequired<T>> = keyof {
31
+ [P in keyof RT as RT[P] extends any[] ? never : RT[P] extends R ? P : never]: RT[P];
32
+ };
33
+ /**
34
+ * Extracts keys of properties whose value is an array of objects.
35
+ *
36
+ * @example
37
+ * type Example = {
38
+ * id: number
39
+ * posts: { title: string }[]
40
+ * scores: number[]
41
+ * }
42
+ * type ArrayObjKeys = ArrayObjectKeys<Example> // "posts"
43
+ */
44
+ export type ArrayObjectKeys<T, RT = CustomRequired<T>> = keyof {
45
+ [P in keyof RT as RT[P] extends R[] ? P : never]: RT[P];
46
+ };
47
+ type DepthLevel = [never, 0, 1, 2, 3, 4, 5];
48
+ type DepthType = DepthLevel[number];
49
+ /**
50
+ * Recursively collects nested object keys (`a.b.c`) up to a defined depth.
51
+ *
52
+ * Default depth = 5.
53
+ *
54
+ * @example
55
+ * type Example = {
56
+ * user: {
57
+ * profile: {
58
+ * email: string
59
+ * }
60
+ * }
61
+ * tags: string[]
62
+ * }
63
+ *
64
+ * type Keys = NestedObjectKeys<Example>
65
+ * // "user" | "user.profile" | "user.profile.email"
66
+ */
67
+ export type NestedObjectKeys<T, Depth extends DepthType = 5, RT = CustomRequired<T>> = keyof {
68
+ [P in keyof RT & string as Depth extends never ? never : RT[P] extends any[] ? never : RT[P] extends R ? P | `${P}.${NestedObjectKeys<RT[P], DepthLevel[Depth]>}` : never]: RT[P];
69
+ };
70
+ /**
71
+ * Recursively collects nested object keys inside array properties.
72
+ *
73
+ * Keys include the root array field name and dot paths inside array item objects.
74
+ *
75
+ * @example
76
+ * type Example = {
77
+ * comments: {
78
+ * users: {
79
+ * name: string,
80
+ * addresses: {
81
+ * name
82
+ * }[]
83
+ * }[]
84
+ * }[]
85
+ * }
86
+ *
87
+ * type Keys = NestedArrayObjectKeys<Example>
88
+ * // "comments" | "comments.users" | "comments.users.addresses"
89
+ */
90
+ export type NestedArrayObjectKeys<T, Depth extends DepthType = 5, RT = CustomRequired<T>> = keyof {
91
+ [P in keyof RT & string as Depth extends never ? never : RT[P] extends R[] ? P | `${P}.${NestedArrayObjectKeys<RT[P][number], DepthLevel[Depth]>}` : never]: RT[P];
92
+ };
93
+ /**
94
+ * Picks only properties that are objects (not arrays).
95
+ *
96
+ * @example
97
+ * type Example = {
98
+ * id: number
99
+ * settings: { dark: boolean }
100
+ * history: string[]
101
+ * }
102
+ *
103
+ * type Result = PickObjects<Example>
104
+ * // { settings: { dark: boolean } }
105
+ */
106
+ export type PickObjects<T> = Pick<T, ObjectKeys<T>>;
107
+ /**
108
+ * Picks only properties that are arrays of objects.
109
+ *
110
+ * @example
111
+ * type Example = {
112
+ * users: { name: string }[]
113
+ * count: number
114
+ * }
115
+ *
116
+ * type Result = PickArrayObjects<Example>
117
+ * // { users: { name: string }[] }
118
+ */
119
+ export type PickArrayObjects<T> = Pick<T, ArrayObjectKeys<T>>;
120
+ export {};
File without changes
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
  var IntRage = require('./IntRage');
3
3
  var PartialExcept = require('./PartialExcept');
4
+ var Object$1 = require('./Object');
4
5
  Object.keys(IntRage).forEach(function(k) {
5
6
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
6
7
  enumerable: true,
@@ -17,3 +18,11 @@ Object.keys(PartialExcept).forEach(function(k) {
17
18
  }
18
19
  });
19
20
  });
21
+ Object.keys(Object$1).forEach(function(k) {
22
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
23
+ enumerable: true,
24
+ get: function get() {
25
+ return Object$1[k];
26
+ }
27
+ });
28
+ });
@@ -1,2 +1,3 @@
1
1
  export * from './IntRage.js';
2
2
  export * from './PartialExcept.js';
3
+ export * from './Object.js';
@@ -1,2 +1,3 @@
1
1
  export * from './IntRage.js';
2
2
  export * from './PartialExcept.js';
3
+ export * from './Object.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powfix/core-js",
3
- "version": "0.24.5",
3
+ "version": "0.25.0",
4
4
  "description": "core package",
5
5
  "author": "Kwon Kyung-Min <powfix@gmail.com>",
6
6
  "private": false,