list-toolkit 2.2.6 → 2.3.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.
Files changed (125) hide show
  1. package/README.md +40 -37
  2. package/llms-full.txt +743 -0
  3. package/llms.txt +100 -0
  4. package/package.json +34 -29
  5. package/src/cache/cache-fifo.d.ts +6 -0
  6. package/src/cache/cache-fifo.js +7 -4
  7. package/src/cache/cache-lfu.d.ts +18 -0
  8. package/src/cache/cache-lfu.js +18 -6
  9. package/src/cache/cache-lru.d.ts +74 -0
  10. package/src/cache/cache-lru.js +60 -5
  11. package/src/cache/cache-random.d.ts +20 -0
  12. package/src/cache/cache-random.js +17 -6
  13. package/src/cache/decorator.d.ts +46 -0
  14. package/src/cache/decorator.js +26 -2
  15. package/src/cache.d.ts +13 -0
  16. package/src/cache.js +7 -2
  17. package/src/ext-list.d.ts +3 -0
  18. package/src/ext-list.js +0 -2
  19. package/src/ext-slist.d.ts +3 -0
  20. package/src/ext-slist.js +0 -2
  21. package/src/ext-value-list.d.ts +3 -0
  22. package/src/ext-value-list.js +0 -2
  23. package/src/ext-value-slist.d.ts +3 -0
  24. package/src/ext-value-slist.js +0 -2
  25. package/src/heap/basics.d.ts +89 -0
  26. package/src/heap/basics.js +42 -5
  27. package/src/heap/leftist-heap.d.ts +107 -0
  28. package/src/heap/leftist-heap.js +54 -2
  29. package/src/heap/min-heap.d.ts +270 -0
  30. package/src/heap/min-heap.js +186 -2
  31. package/src/heap/skew-heap.d.ts +105 -0
  32. package/src/heap/skew-heap.js +54 -2
  33. package/src/heap.d.ts +3 -0
  34. package/src/heap.js +0 -2
  35. package/src/list/basics.d.ts +43 -0
  36. package/src/list/basics.js +26 -8
  37. package/src/list/core.d.ts +271 -0
  38. package/src/list/core.js +162 -7
  39. package/src/list/ext-value.d.ts +253 -0
  40. package/src/list/ext-value.js +40 -6
  41. package/src/list/ext.d.ts +242 -0
  42. package/src/list/ext.js +148 -10
  43. package/src/list/nodes.d.ts +336 -0
  44. package/src/list/nodes.js +141 -3
  45. package/src/list/ptr.d.ts +72 -0
  46. package/src/list/ptr.js +44 -2
  47. package/src/list/value.d.ts +292 -0
  48. package/src/list/value.js +47 -6
  49. package/src/list-helpers.d.ts +44 -0
  50. package/src/list-helpers.js +36 -3
  51. package/src/list-utils.d.ts +141 -0
  52. package/src/list-utils.js +89 -3
  53. package/src/list.d.ts +3 -0
  54. package/src/list.js +0 -2
  55. package/src/meta-utils.d.ts +212 -0
  56. package/src/meta-utils.js +152 -1
  57. package/src/nt-utils.d.ts +91 -0
  58. package/src/nt-utils.js +65 -4
  59. package/src/queue.d.ts +74 -0
  60. package/src/queue.js +28 -2
  61. package/src/slist/basics.d.ts +47 -0
  62. package/src/slist/basics.js +23 -8
  63. package/src/slist/core.d.ts +251 -0
  64. package/src/slist/core.js +151 -6
  65. package/src/slist/ext-value.d.ts +188 -0
  66. package/src/slist/ext-value.js +35 -6
  67. package/src/slist/ext.d.ts +182 -0
  68. package/src/slist/ext.js +114 -12
  69. package/src/slist/nodes.d.ts +361 -0
  70. package/src/slist/nodes.js +156 -3
  71. package/src/slist/ptr.d.ts +73 -0
  72. package/src/slist/ptr.js +45 -2
  73. package/src/slist/value.d.ts +246 -0
  74. package/src/slist/value.js +38 -6
  75. package/src/slist.d.ts +3 -0
  76. package/src/slist.js +0 -2
  77. package/src/stack.d.ts +59 -0
  78. package/src/stack.js +29 -3
  79. package/src/tree/splay-tree.d.ts +151 -0
  80. package/src/tree/splay-tree.js +94 -3
  81. package/src/value-list.d.ts +3 -0
  82. package/src/value-list.js +0 -2
  83. package/src/value-slist.d.ts +3 -0
  84. package/src/value-slist.js +0 -2
  85. package/cjs/cache/cache-fifo.js +0 -37
  86. package/cjs/cache/cache-lfu.js +0 -76
  87. package/cjs/cache/cache-lru.js +0 -100
  88. package/cjs/cache/cache-random.js +0 -77
  89. package/cjs/cache/decorator.js +0 -47
  90. package/cjs/cache.js +0 -27
  91. package/cjs/ext-list.js +0 -21
  92. package/cjs/ext-slist.js +0 -21
  93. package/cjs/ext-value-list.js +0 -21
  94. package/cjs/ext-value-slist.js +0 -21
  95. package/cjs/heap/basics.js +0 -63
  96. package/cjs/heap/leftist-heap.js +0 -124
  97. package/cjs/heap/min-heap.js +0 -294
  98. package/cjs/heap/skew-heap.js +0 -114
  99. package/cjs/heap.js +0 -21
  100. package/cjs/list/basics.js +0 -88
  101. package/cjs/list/core.js +0 -305
  102. package/cjs/list/ext-value.js +0 -88
  103. package/cjs/list/ext.js +0 -356
  104. package/cjs/list/nodes.js +0 -240
  105. package/cjs/list/ptr.js +0 -61
  106. package/cjs/list/value.js +0 -99
  107. package/cjs/list-helpers.js +0 -91
  108. package/cjs/list-utils.js +0 -141
  109. package/cjs/list.js +0 -21
  110. package/cjs/meta-utils.js +0 -171
  111. package/cjs/nt-utils.js +0 -132
  112. package/cjs/package.json +0 -1
  113. package/cjs/queue.js +0 -58
  114. package/cjs/slist/basics.js +0 -71
  115. package/cjs/slist/core.js +0 -362
  116. package/cjs/slist/ext-value.js +0 -82
  117. package/cjs/slist/ext.js +0 -336
  118. package/cjs/slist/nodes.js +0 -276
  119. package/cjs/slist/ptr.js +0 -87
  120. package/cjs/slist/value.js +0 -90
  121. package/cjs/slist.js +0 -21
  122. package/cjs/stack.js +0 -55
  123. package/cjs/tree/splay-tree.js +0 -362
  124. package/cjs/value-list.js +0 -21
  125. package/cjs/value-slist.js +0 -21
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Validate that a circular DLL is well-formed (every next/prev pair is consistent).
3
+ * @param list - Head node of the circular list (must have `nextName` and `prevName`).
4
+ * @returns `true` if the list is valid.
5
+ */
6
+ export function isValidList(list: object): boolean;
7
+
8
+ /**
9
+ * Validate that a circular SLL is well-formed (every next link is truthy and loops back).
10
+ * @param list - Head node of the circular list (must have `nextName`).
11
+ * @returns `true` if the list is valid.
12
+ */
13
+ export function isValidSList(list: object): boolean;
14
+
15
+ /**
16
+ * Push values to the front of a list one by one.
17
+ * @param list - List with a `pushFront` method.
18
+ * @param values - Iterable of values to push.
19
+ * @returns The list.
20
+ */
21
+ export function pushValuesFront<L extends object>(list: L, values: Iterable<any>): L;
22
+
23
+ /**
24
+ * Push values to the back of a list one by one.
25
+ * @param list - List with a `pushBack` method.
26
+ * @param values - Iterable of values to push.
27
+ * @returns The list.
28
+ */
29
+ export function pushValuesBack<L extends object>(list: L, values: Iterable<any>): L;
30
+
31
+ /**
32
+ * Append values to the front of a list, using `appendFront` if compatible, otherwise `pushFront`.
33
+ * @param list - List with `pushFront` and optionally `appendFront`.
34
+ * @param values - Iterable or compatible list of values.
35
+ * @returns The list.
36
+ */
37
+ export function appendValuesFront<L extends object>(list: L, values: Iterable<any>): L;
38
+
39
+ /**
40
+ * Append values to the back of a list, using `appendBack` if compatible, otherwise `pushBack`.
41
+ * @param list - List with `pushBack` and optionally `appendBack`.
42
+ * @param values - Iterable or compatible list of values.
43
+ * @returns The list.
44
+ */
45
+ export function appendValuesBack<L extends object>(list: L, values: Iterable<any>): L;
46
+
47
+ /**
48
+ * Add values before a pointer position one by one.
49
+ * @param ptr - Pointer with an `addBefore` method.
50
+ * @param values - Iterable of values to add.
51
+ * @returns The pointer.
52
+ */
53
+ export function addValuesBefore<P extends object>(ptr: P, values: Iterable<any>): P;
54
+
55
+ /**
56
+ * Add values after a pointer position one by one.
57
+ * @param ptr - Pointer with an `addAfter` method.
58
+ * @param values - Iterable of values to add.
59
+ * @returns The pointer.
60
+ */
61
+ export function addValuesAfter<P extends object>(ptr: P, values: Iterable<any>): P;
62
+
63
+ /**
64
+ * Insert values before a pointer, using `insertBefore` if compatible, otherwise `addBefore`.
65
+ * @param ptr - Pointer with `addBefore` and optionally `insertBefore`.
66
+ * @param values - Iterable of values to insert.
67
+ * @returns The pointer.
68
+ */
69
+ export function insertValuesBefore<P extends object>(ptr: P, values: Iterable<any>): P;
70
+
71
+ /**
72
+ * Insert values after a pointer, using `insertAfter` if compatible, otherwise `addAfter`.
73
+ * @param ptr - Pointer with `addAfter` and optionally `insertAfter`.
74
+ * @param values - Iterable of values to insert.
75
+ * @returns The pointer.
76
+ */
77
+ export function insertValuesAfter<P extends object>(ptr: P, values: Iterable<any>): P;
78
+
79
+ /**
80
+ * Find the first node matching a condition.
81
+ * @param list - List with a `getNodeIterator` method.
82
+ * @param condition - Predicate receiving each node.
83
+ * @returns The matching node, or `null`.
84
+ */
85
+ export function findNodeBy<T extends object>(list: object, condition: (node: T) => boolean): T | null;
86
+
87
+ /**
88
+ * Find the first pointer whose node matches a condition.
89
+ * @param list - List with a `getPtrIterator` method.
90
+ * @param condition - Predicate receiving each node.
91
+ * @returns The matching pointer, or `null`.
92
+ */
93
+ export function findPtrBy(list: object, condition: (node: object) => boolean): object | null;
94
+
95
+ /**
96
+ * Remove the first node matching a condition.
97
+ * @param list - List with a `getPtrIterator` method.
98
+ * @param condition - Predicate receiving each node.
99
+ * @returns The removed node, or `null`.
100
+ */
101
+ export function removeNodeBy(list: object, condition: (node: object) => boolean): object | null;
102
+
103
+ /** Adapter returned by {@link backPusher}. */
104
+ export interface PusherAdapter {
105
+ /** Next link property name. */
106
+ nextName: string;
107
+ /** Previous link property name. */
108
+ prevName: string;
109
+ /** Push a node to the back and return it. */
110
+ pushBackNode(node: object): object;
111
+ /** Release the accumulated list. */
112
+ releaseList(): object;
113
+ }
114
+
115
+ /** Adapter returned by {@link frontPusher}. */
116
+ export interface FrontPusherAdapter {
117
+ /** Next link property name. */
118
+ nextName: string;
119
+ /** Previous link property name. */
120
+ prevName: string;
121
+ /** Push a node to the front and return it. */
122
+ pushFrontNode(node: object): object;
123
+ /** Release the accumulated list. */
124
+ releaseList(): object;
125
+ }
126
+
127
+ /**
128
+ * Create an adapter that accumulates nodes pushed to the back.
129
+ * @param ExtListClass - External list constructor.
130
+ * @param options - Link property names.
131
+ * @returns A pusher adapter.
132
+ */
133
+ export function backPusher(ExtListClass: new (...args: any[]) => any, options?: object): PusherAdapter;
134
+
135
+ /**
136
+ * Create an adapter that accumulates nodes pushed to the front.
137
+ * @param ExtListClass - External list constructor.
138
+ * @param options - Link property names.
139
+ * @returns A pusher adapter.
140
+ */
141
+ export function frontPusher(ExtListClass: new (...args: any[]) => any, options?: object): FrontPusherAdapter;
package/src/list-utils.js CHANGED
@@ -1,5 +1,8 @@
1
- 'use strict';
2
-
1
+ /**
2
+ * Validate that a circular DLL is well-formed (every next/prev pair is consistent).
3
+ * @param {object} list - Head node of the circular list (must have `nextName` and `prevName`).
4
+ * @returns {boolean} `true` if the list is valid.
5
+ */
3
6
  export const isValidList = list => {
4
7
  let current = list;
5
8
  do {
@@ -10,6 +13,11 @@ export const isValidList = list => {
10
13
  return true;
11
14
  };
12
15
 
16
+ /**
17
+ * Validate that a circular SLL is well-formed (every next link is truthy and loops back).
18
+ * @param {object} list - Head node of the circular list (must have `nextName`).
19
+ * @returns {boolean} `true` if the list is valid.
20
+ */
13
21
  export const isValidSList = list => {
14
22
  let current = list;
15
23
  do {
@@ -20,6 +28,12 @@ export const isValidSList = list => {
20
28
  return true;
21
29
  };
22
30
 
31
+ /**
32
+ * Push values to the front of a list one by one.
33
+ * @param {object} list - List with a `pushFront` method.
34
+ * @param {Iterable} values - Iterable of values to push.
35
+ * @returns {object} The list.
36
+ */
23
37
  export const pushValuesFront = (list, values) => {
24
38
  for (const value of values) {
25
39
  list.pushFront(value);
@@ -27,6 +41,12 @@ export const pushValuesFront = (list, values) => {
27
41
  return list;
28
42
  };
29
43
 
44
+ /**
45
+ * Push values to the back of a list one by one.
46
+ * @param {object} list - List with a `pushBack` method.
47
+ * @param {Iterable} values - Iterable of values to push.
48
+ * @returns {object} The list.
49
+ */
30
50
  export const pushValuesBack = (list, values) => {
31
51
  for (const value of values) {
32
52
  list.pushBack(value);
@@ -34,6 +54,12 @@ export const pushValuesBack = (list, values) => {
34
54
  return list;
35
55
  };
36
56
 
57
+ /**
58
+ * Append values to the front of a list, using `appendFront` if compatible, otherwise `pushFront`.
59
+ * @param {object} list - List with `pushFront` and optionally `appendFront`.
60
+ * @param {Iterable} values - Iterable or compatible list of values.
61
+ * @returns {object} The list.
62
+ */
37
63
  export const appendValuesFront = (list, values) => {
38
64
  if (typeof list.appendFront == 'function' && list.isCompatible(values)) {
39
65
  list.appendFront(values);
@@ -46,6 +72,12 @@ export const appendValuesFront = (list, values) => {
46
72
  return list;
47
73
  };
48
74
 
75
+ /**
76
+ * Append values to the back of a list, using `appendBack` if compatible, otherwise `pushBack`.
77
+ * @param {object} list - List with `pushBack` and optionally `appendBack`.
78
+ * @param {Iterable} values - Iterable or compatible list of values.
79
+ * @returns {object} The list.
80
+ */
49
81
  export const appendValuesBack = (list, values) => {
50
82
  if (typeof list.appendBack == 'function' && list.isCompatible(values)) {
51
83
  list.appendBack(values);
@@ -54,6 +86,12 @@ export const appendValuesBack = (list, values) => {
54
86
  return pushValuesBack(list, values);
55
87
  };
56
88
 
89
+ /**
90
+ * Add values before a pointer position one by one.
91
+ * @param {object} ptr - Pointer with an `addBefore` method.
92
+ * @param {Iterable} values - Iterable of values to add.
93
+ * @returns {object} The pointer.
94
+ */
57
95
  export const addValuesBefore = (ptr, values) => {
58
96
  for (const value of values) {
59
97
  ptr.addBefore(value);
@@ -61,6 +99,12 @@ export const addValuesBefore = (ptr, values) => {
61
99
  return ptr;
62
100
  };
63
101
 
102
+ /**
103
+ * Add values after a pointer position one by one.
104
+ * @param {object} ptr - Pointer with an `addAfter` method.
105
+ * @param {Iterable} values - Iterable of values to add.
106
+ * @returns {object} The pointer.
107
+ */
64
108
  export const addValuesAfter = (ptr, values) => {
65
109
  for (const value of values) {
66
110
  ptr.addAfter(value);
@@ -68,6 +112,12 @@ export const addValuesAfter = (ptr, values) => {
68
112
  return ptr;
69
113
  };
70
114
 
115
+ /**
116
+ * Insert values before a pointer, using `insertBefore` if compatible, otherwise `addBefore`.
117
+ * @param {object} ptr - Pointer with `addBefore` and optionally `insertBefore`.
118
+ * @param {Iterable} values - Iterable of values to insert.
119
+ * @returns {object} The pointer.
120
+ */
71
121
  export const insertValuesBefore = (ptr, values) => {
72
122
  if (typeof ptr.insertBefore == 'function' && ptr.list.isCompatible(values)) {
73
123
  ptr.insertBefore(ptr.list.makeFrom(values));
@@ -76,6 +126,12 @@ export const insertValuesBefore = (ptr, values) => {
76
126
  return addValuesBefore(ptr, values);
77
127
  };
78
128
 
129
+ /**
130
+ * Insert values after a pointer, using `insertAfter` if compatible, otherwise `addAfter`.
131
+ * @param {object} ptr - Pointer with `addAfter` and optionally `insertAfter`.
132
+ * @param {Iterable} values - Iterable of values to insert.
133
+ * @returns {object} The pointer.
134
+ */
79
135
  export const insertValuesAfter = (ptr, values) => {
80
136
  if (typeof ptr.insertAfter == 'function' && ptr.list.isCompatible(values)) {
81
137
  ptr.insertAfter(ptr.list.makeFrom(values));
@@ -88,6 +144,12 @@ export const insertValuesAfter = (ptr, values) => {
88
144
  return ptr;
89
145
  };
90
146
 
147
+ /**
148
+ * Find the first node matching a condition.
149
+ * @param {object} list - List with a `getNodeIterator` method.
150
+ * @param {Function} condition - Predicate receiving each node.
151
+ * @returns {object|null} The matching node, or `null`.
152
+ */
91
153
  export const findNodeBy = (list, condition) => {
92
154
  for (const node of list.getNodeIterator()) {
93
155
  if (condition(node)) return node;
@@ -95,6 +157,12 @@ export const findNodeBy = (list, condition) => {
95
157
  return null;
96
158
  };
97
159
 
160
+ /**
161
+ * Find the first pointer whose node matches a condition.
162
+ * @param {object} list - List with a `getPtrIterator` method.
163
+ * @param {Function} condition - Predicate receiving each node.
164
+ * @returns {object|null} The matching pointer, or `null`.
165
+ */
98
166
  export const findPtrBy = (list, condition) => {
99
167
  for (const ptr of list.getPtrIterator()) {
100
168
  if (condition(ptr.node)) return ptr;
@@ -102,6 +170,12 @@ export const findPtrBy = (list, condition) => {
102
170
  return null;
103
171
  };
104
172
 
173
+ /**
174
+ * Remove the first node matching a condition.
175
+ * @param {object} list - List with a `getPtrIterator` method.
176
+ * @param {Function} condition - Predicate receiving each node.
177
+ * @returns {object|null} The removed node, or `null`.
178
+ */
105
179
  export const removeNodeBy = (list, condition) => {
106
180
  for (const ptr of list.getPtrIterator()) {
107
181
  if (condition(ptr.node)) return ptr.removeCurrent();
@@ -109,6 +183,12 @@ export const removeNodeBy = (list, condition) => {
109
183
  return null;
110
184
  };
111
185
 
186
+ /**
187
+ * Create an adapter that accumulates nodes pushed to the back.
188
+ * @param {Function} ExtListClass - External list constructor.
189
+ * @param {object} [options] - Link property names.
190
+ * @returns {{nextName: string, prevName: string, pushBackNode: Function, releaseList: Function}} A pusher adapter.
191
+ */
112
192
  export const backPusher = (ExtListClass, options) => {
113
193
  const list = new ExtListClass(null, options),
114
194
  adapter = {
@@ -126,6 +206,12 @@ export const backPusher = (ExtListClass, options) => {
126
206
  return adapter;
127
207
  };
128
208
 
209
+ /**
210
+ * Create an adapter that accumulates nodes pushed to the front.
211
+ * @param {Function} ExtListClass - External list constructor.
212
+ * @param {object} [options] - Link property names.
213
+ * @returns {{nextName: string, prevName: string, pushFrontNode: Function, releaseList: Function}} A pusher adapter.
214
+ */
129
215
  export const frontPusher = (ExtListClass, options) => {
130
216
  const list = new ExtListClass(null, options),
131
217
  adapter = {
@@ -134,7 +220,7 @@ export const frontPusher = (ExtListClass, options) => {
134
220
 
135
221
  pushFrontNode: node => list.addNodeAfter(node).node,
136
222
 
137
- releaseList: () => this.make(list.detach())
223
+ releaseList: () => list.make(list.detach())
138
224
  };
139
225
  return adapter;
140
226
  };
package/src/list.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './list/core.js';
2
+ import List from './list/core.js';
3
+ export default List;
package/src/list.js CHANGED
@@ -1,5 +1,3 @@
1
- 'use strict';
2
-
3
1
  export * from './list/core.js';
4
2
  import List from './list/core.js';
5
3
 
@@ -0,0 +1,212 @@
1
+ /**
2
+ * Capitalize the first letter of a string.
3
+ * @param name - Input string.
4
+ * @returns The capitalized string.
5
+ */
6
+ export function capitalize(name: string): string;
7
+
8
+ /**
9
+ * Convert an array of name parts to camelCase.
10
+ * @param names - Name parts.
11
+ * @returns The camelCase string.
12
+ */
13
+ export function toCamelCase(names: string[]): string;
14
+
15
+ /**
16
+ * Split a camelCase string into parts.
17
+ * @param name - camelCase string.
18
+ * @returns Array of name parts.
19
+ */
20
+ export function fromCamelCase(name: string): string[];
21
+
22
+ /**
23
+ * Convert an array of name parts to PascalCase.
24
+ * @param names - Name parts.
25
+ * @returns The PascalCase string.
26
+ */
27
+ export function toPascalCase(names: string[]): string;
28
+
29
+ /**
30
+ * Split a PascalCase string into parts.
31
+ * @param name - PascalCase string.
32
+ * @returns Array of name parts.
33
+ */
34
+ export function fromPascalCase(name: string): string[];
35
+
36
+ /**
37
+ * Convert an array of name parts to ALL_CAPS_SNAKE_CASE.
38
+ * @param names - Name parts.
39
+ * @returns The ALL_CAPS_SNAKE_CASE string.
40
+ */
41
+ export function toAllCapsSnakeCase(names: string[]): string;
42
+
43
+ /**
44
+ * Convert an array of name parts to snake_case.
45
+ * @param names - Name parts.
46
+ * @returns The snake_case string.
47
+ */
48
+ export function toSnakeCase(names: string[]): string;
49
+
50
+ /**
51
+ * Split a snake_case string into parts.
52
+ * @param name - snake_case string.
53
+ * @returns Array of name parts.
54
+ */
55
+ export function fromSnakeCase(name: string): string[];
56
+
57
+ /**
58
+ * Convert an array of name parts to kebab-case.
59
+ * @param names - Name parts.
60
+ * @returns The kebab-case string.
61
+ */
62
+ export function toKebabCase(names: string[]): string;
63
+
64
+ /**
65
+ * Split a kebab-case string into parts.
66
+ * @param name - kebab-case string.
67
+ * @returns Array of name parts.
68
+ */
69
+ export function fromKebabCase(name: string): string[];
70
+
71
+ /** Default property descriptor: configurable and enumerable. */
72
+ export const defaultDescriptor: PropertyDescriptor;
73
+
74
+ /**
75
+ * Create a property descriptor from a getter function.
76
+ * @param getter - Getter function.
77
+ * @param defaultDescriptor - Base descriptor to extend.
78
+ * @returns A property descriptor with `get`.
79
+ */
80
+ export function fromGetter(getter: (() => any) | undefined, defaultDescriptor?: PropertyDescriptor): PropertyDescriptor;
81
+
82
+ /**
83
+ * Create a property descriptor from a setter function.
84
+ * @param setter - Setter function.
85
+ * @param defaultDescriptor - Base descriptor to extend.
86
+ * @returns A property descriptor with `set`.
87
+ */
88
+ export function fromSetter(setter: ((v: any) => void) | undefined, defaultDescriptor?: PropertyDescriptor): PropertyDescriptor;
89
+
90
+ /**
91
+ * Create a property descriptor from getter and setter functions.
92
+ * @param getter - Getter function.
93
+ * @param setter - Setter function.
94
+ * @param defaultDescriptor - Base descriptor to extend.
95
+ * @returns A property descriptor with `get` and/or `set`.
96
+ */
97
+ export function fromAccessors(
98
+ getter: (() => any) | undefined,
99
+ setter: ((v: any) => void) | undefined,
100
+ defaultDescriptor?: PropertyDescriptor
101
+ ): PropertyDescriptor;
102
+
103
+ /**
104
+ * Define a property descriptor on a target for one or more names.
105
+ * @param target - Object to define properties on.
106
+ * @param names - Comma-separated string, array, or single name/symbol.
107
+ * @param descriptor - Property descriptor to apply.
108
+ * @param force - If `true`, overwrite existing own properties.
109
+ * @returns The target object.
110
+ */
111
+ export function addDescriptor(target: object, names: string | PropertyKey[], descriptor: PropertyDescriptor | undefined, force?: boolean): object;
112
+
113
+ /**
114
+ * Define multiple property descriptors on a target.
115
+ * @param target - Object to define properties on.
116
+ * @param dict - Map of comma-separated names to descriptors.
117
+ * @param force - If `true`, overwrite existing own properties.
118
+ */
119
+ export function addDescriptors(target: object, dict: Record<string, PropertyDescriptor>, force?: boolean): void;
120
+
121
+ /**
122
+ * Define an accessor (getter/setter) on a target.
123
+ * @param target - Object to define the accessor on.
124
+ * @param names - Comma-separated string, array, or single name/symbol.
125
+ * @param getter - Getter function.
126
+ * @param setter - Setter function.
127
+ * @param force - If `true`, overwrite existing own properties.
128
+ * @returns The target object.
129
+ */
130
+ export function addAccessor(
131
+ target: object,
132
+ names: string | PropertyKey[],
133
+ getter: (() => any) | undefined,
134
+ setter: ((v: any) => void) | undefined,
135
+ force?: boolean
136
+ ): object;
137
+
138
+ /**
139
+ * Define multiple getter-based descriptors on a target.
140
+ * @param target - Object to define getters on.
141
+ * @param dict - Map of comma-separated names to getter functions.
142
+ * @param force - If `true`, overwrite existing own properties.
143
+ */
144
+ export function addGetters(target: object, dict: Record<string, () => any>, force?: boolean): void;
145
+
146
+ /**
147
+ * Copy property descriptors from a source to a target.
148
+ * @param target - Destination object.
149
+ * @param source - Source object.
150
+ * @param names - Names to copy (string, symbol, array, or alias map).
151
+ * @param force - If `true`, overwrite existing own properties.
152
+ * @returns The target object.
153
+ */
154
+ export function copyDescriptors(
155
+ target: object,
156
+ source: object,
157
+ names: string | symbol | PropertyKey[] | Record<string, string | PropertyKey[]>,
158
+ force?: boolean
159
+ ): object;
160
+
161
+ /**
162
+ * Create an alias for an existing property.
163
+ * @param object - Object owning the property.
164
+ * @param name - Original property name.
165
+ * @param aliases - Comma-separated alias names or array.
166
+ * @param force - If `true`, overwrite existing own properties.
167
+ * @returns The object.
168
+ */
169
+ export function addAlias(object: object, name: PropertyKey, aliases: string | PropertyKey[], force?: boolean): object;
170
+
171
+ /**
172
+ * Create multiple aliases from a dictionary.
173
+ * @param object - Object owning the properties.
174
+ * @param dict - Map of original names to comma-separated alias strings.
175
+ * @param force - If `true`, overwrite existing own properties.
176
+ * @returns The object.
177
+ */
178
+ export function addAliases(object: object, dict: Record<string, string>, force?: boolean): object;
179
+
180
+ /**
181
+ * Ensure an iterator object has a `[Symbol.iterator]` method.
182
+ * @param iterator - Iterator to augment.
183
+ * @returns The augmented iterator.
184
+ */
185
+ export function augmentIterator<T>(iterator: Iterator<T>): IterableIterator<T>;
186
+
187
+ /**
188
+ * Normalize an iterator, using `Iterator.from` when available.
189
+ * @param iterator - Iterator to normalize.
190
+ * @returns An iterable iterator.
191
+ */
192
+ export function normalizeIterator<T>(iterator: Iterator<T>): IterableIterator<T>;
193
+
194
+ /**
195
+ * Map over an iterator, producing a new iterable.
196
+ * @param iterator - Source iterable iterator.
197
+ * @param callbackFn - Mapping function receiving value and index.
198
+ * @returns An iterable of mapped values.
199
+ */
200
+ export function mapIterator<T, U>(iterator: Iterable<T>, callbackFn: (value: T, index: number) => U): Iterable<U>;
201
+
202
+ /** Map of `typeof` results that can have properties set on them. */
203
+ export const canHaveProps: Record<string, number>;
204
+
205
+ /**
206
+ * Copy option keys from a pattern and optional sources onto a target.
207
+ * @param target - Target object (created if falsy).
208
+ * @param pattern - Object defining which keys to copy and their defaults.
209
+ * @param sources - Additional source objects to override values from.
210
+ * @returns The target object.
211
+ */
212
+ export function copyOptions<T extends object>(target: T | null | undefined, pattern: T, ...sources: Array<Partial<T> | null | undefined>): T;