atomic-fns 1.1.7 → 2.0.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 (216) hide show
  1. package/README.md +405 -60
  2. package/dist/array/index.d.ts +9 -0
  3. package/dist/array/index.js +9 -0
  4. package/dist/array/list.d.ts +99 -0
  5. package/dist/array/list.js +133 -0
  6. package/dist/array/sets.d.ts +130 -0
  7. package/dist/array/sets.js +213 -0
  8. package/dist/async/index.d.ts +6 -0
  9. package/dist/async/index.js +6 -0
  10. package/dist/async/retry.d.ts +38 -0
  11. package/dist/async/retry.js +56 -0
  12. package/dist/async/sleep.d.ts +42 -0
  13. package/dist/async/sleep.js +76 -0
  14. package/dist/collections/bisect.d.ts +103 -0
  15. package/dist/collections/bisect.js +157 -0
  16. package/dist/collections/deque.d.ts +67 -97
  17. package/dist/collections/deque.js +197 -249
  18. package/dist/collections/entries.d.ts +89 -0
  19. package/dist/collections/entries.js +131 -0
  20. package/dist/collections/frozen-set.d.ts +42 -0
  21. package/dist/collections/frozen-set.js +64 -0
  22. package/dist/collections/group.d.ts +141 -0
  23. package/dist/collections/group.js +241 -0
  24. package/dist/collections/heap.d.ts +64 -0
  25. package/dist/collections/heap.js +205 -0
  26. package/dist/collections/index.d.ts +15 -642
  27. package/dist/collections/index.js +14 -716
  28. package/dist/collections/internal/arrayKeys.d.ts +19 -0
  29. package/dist/collections/internal/arrayKeys.js +83 -0
  30. package/dist/collections/internal/invariants.d.ts +4 -0
  31. package/dist/collections/internal/invariants.js +12 -0
  32. package/dist/collections/internal/iterable.d.ts +25 -0
  33. package/dist/collections/internal/iterable.js +62 -0
  34. package/dist/collections/iterate.d.ts +162 -0
  35. package/dist/collections/iterate.js +188 -0
  36. package/dist/collections/lru-cache.d.ts +58 -0
  37. package/dist/collections/lru-cache.js +164 -0
  38. package/dist/collections/order.d.ts +19 -0
  39. package/dist/collections/order.js +38 -0
  40. package/dist/collections/shape.d.ts +32 -0
  41. package/dist/collections/shape.js +86 -0
  42. package/dist/collections/sorted-map.d.ts +171 -0
  43. package/dist/collections/sorted-map.js +845 -0
  44. package/dist/collections/sorted-set.d.ts +103 -0
  45. package/dist/collections/sorted-set.js +147 -0
  46. package/dist/collections/splay-tree.d.ts +82 -0
  47. package/dist/collections/splay-tree.js +354 -0
  48. package/dist/collections/trie.d.ts +58 -0
  49. package/dist/collections/trie.js +196 -0
  50. package/dist/decimal/currency.d.ts +211 -0
  51. package/dist/decimal/currency.js +321 -0
  52. package/dist/decimal/decimal.d.ts +299 -0
  53. package/dist/decimal/decimal.js +660 -0
  54. package/dist/decimal/index.d.ts +11 -145
  55. package/dist/decimal/index.js +10 -374
  56. package/dist/decimal/internal/bits.d.ts +2 -0
  57. package/dist/decimal/internal/bits.js +7 -0
  58. package/dist/decimal/internal/echo.d.ts +4 -0
  59. package/dist/decimal/internal/echo.js +6 -0
  60. package/dist/decimal/internal/isqrt.d.ts +9 -0
  61. package/dist/decimal/internal/isqrt.js +34 -0
  62. package/dist/decimal/internal/locale.d.ts +7 -0
  63. package/dist/decimal/internal/locale.js +24 -0
  64. package/dist/decimal/internal/minor-units.d.ts +2 -0
  65. package/dist/decimal/internal/minor-units.js +33 -0
  66. package/dist/decimal/internal/pow10.d.ts +24 -0
  67. package/dist/decimal/internal/pow10.js +96 -0
  68. package/dist/encoding/base64.d.ts +39 -0
  69. package/dist/encoding/base64.js +53 -0
  70. package/dist/encoding/hex.d.ts +23 -0
  71. package/dist/encoding/hex.js +34 -0
  72. package/dist/encoding/index.d.ts +6 -0
  73. package/dist/encoding/index.js +6 -0
  74. package/dist/function/debounce.d.ts +68 -0
  75. package/dist/function/debounce.js +203 -0
  76. package/dist/function/index.d.ts +6 -0
  77. package/dist/function/index.js +6 -0
  78. package/dist/function/shared.d.ts +2 -0
  79. package/dist/function/shared.js +5 -0
  80. package/dist/function/wrap.d.ts +130 -0
  81. package/dist/function/wrap.js +113 -0
  82. package/dist/hash/digest.d.ts +18 -0
  83. package/dist/hash/digest.js +26 -0
  84. package/dist/hash/hash.d.ts +22 -0
  85. package/dist/hash/hash.js +252 -0
  86. package/dist/hash/hashString.d.ts +13 -0
  87. package/dist/hash/hashString.js +53 -0
  88. package/dist/hash/index.d.ts +8 -0
  89. package/dist/hash/index.js +8 -0
  90. package/dist/hash/stableStringify.d.ts +19 -0
  91. package/dist/hash/stableStringify.js +102 -0
  92. package/dist/id/index.d.ts +7 -0
  93. package/dist/id/index.js +7 -0
  94. package/dist/id/nanoid.d.ts +16 -0
  95. package/dist/id/nanoid.js +65 -0
  96. package/dist/id/uniqueId.d.ts +14 -0
  97. package/dist/id/uniqueId.js +20 -0
  98. package/dist/id/uuid.d.ts +25 -0
  99. package/dist/id/uuid.js +64 -0
  100. package/dist/index.d.ts +15 -8
  101. package/dist/index.js +15 -8
  102. package/dist/internal/bytes.d.ts +11 -0
  103. package/dist/internal/bytes.js +33 -0
  104. package/dist/internal/codec.d.ts +11 -0
  105. package/dist/internal/codec.js +84 -0
  106. package/dist/internal/compare.d.ts +10 -0
  107. package/dist/internal/compare.js +26 -0
  108. package/dist/internal/crypto.d.ts +5 -0
  109. package/dist/internal/crypto.js +11 -0
  110. package/dist/internal/keys.d.ts +12 -0
  111. package/dist/internal/keys.js +23 -0
  112. package/dist/internal/kind.d.ts +44 -0
  113. package/dist/internal/kind.js +139 -0
  114. package/dist/internal/sparse.d.ts +51 -0
  115. package/dist/internal/sparse.js +104 -0
  116. package/dist/internal/text.d.ts +7 -0
  117. package/dist/internal/text.js +15 -0
  118. package/dist/internal/timer.d.ts +10 -0
  119. package/dist/internal/timer.js +17 -0
  120. package/dist/internal/truncate.d.ts +10 -0
  121. package/dist/internal/truncate.js +22 -0
  122. package/dist/internal/walk.d.ts +47 -0
  123. package/dist/internal/walk.js +100 -0
  124. package/dist/is/index.d.ts +8 -0
  125. package/dist/is/index.js +8 -0
  126. package/dist/is/isArrayLike.d.ts +18 -0
  127. package/dist/is/isArrayLike.js +25 -0
  128. package/dist/is/isError.d.ts +13 -0
  129. package/dist/is/isError.js +18 -0
  130. package/dist/is/isNil.d.ts +12 -0
  131. package/dist/is/isNil.js +14 -0
  132. package/dist/is/isPlainObject.d.ts +15 -0
  133. package/dist/is/isPlainObject.js +34 -0
  134. package/dist/number/index.d.ts +7 -0
  135. package/dist/number/index.js +7 -0
  136. package/dist/number/round.d.ts +86 -0
  137. package/dist/number/round.js +130 -0
  138. package/dist/number/stats.d.ts +52 -0
  139. package/dist/number/stats.js +115 -0
  140. package/dist/object/cloneDeep.d.ts +28 -0
  141. package/dist/object/cloneDeep.js +200 -0
  142. package/dist/object/index.d.ts +14 -0
  143. package/dist/object/index.js +13 -0
  144. package/dist/object/isEqual.d.ts +64 -0
  145. package/dist/object/isEqual.js +289 -0
  146. package/dist/object/matches.d.ts +40 -0
  147. package/dist/object/matches.js +284 -0
  148. package/dist/object/merge.d.ts +66 -0
  149. package/dist/object/merge.js +272 -0
  150. package/dist/object/parsePath.d.ts +22 -0
  151. package/dist/object/parsePath.js +111 -0
  152. package/dist/object/path.d.ts +85 -0
  153. package/dist/object/path.js +208 -0
  154. package/dist/object/pick.d.ts +91 -0
  155. package/dist/object/pick.js +180 -0
  156. package/dist/object/reshape.d.ts +73 -0
  157. package/dist/object/reshape.js +144 -0
  158. package/dist/random/index.d.ts +96 -32
  159. package/dist/random/index.js +215 -50
  160. package/dist/string/case.d.ts +71 -0
  161. package/dist/string/case.js +152 -0
  162. package/dist/string/fold.d.ts +35 -0
  163. package/dist/string/fold.js +100 -0
  164. package/dist/string/index.d.ts +6 -187
  165. package/dist/string/index.js +6 -226
  166. package/dist/string/truncate.d.ts +25 -0
  167. package/dist/string/truncate.js +44 -0
  168. package/dist/string/words.d.ts +27 -0
  169. package/dist/string/words.js +241 -0
  170. package/package.json +101 -58
  171. package/dist/collections/BTree.d.ts +0 -229
  172. package/dist/collections/BTree.js +0 -1165
  173. package/dist/collections/Heap.d.ts +0 -69
  174. package/dist/collections/Heap.js +0 -181
  175. package/dist/collections/LRUCache.d.ts +0 -80
  176. package/dist/collections/LRUCache.js +0 -126
  177. package/dist/collections/SortedMap.d.ts +0 -92
  178. package/dist/collections/SortedMap.js +0 -131
  179. package/dist/collections/SortedSet.d.ts +0 -69
  180. package/dist/collections/SortedSet.js +0 -99
  181. package/dist/collections/SortedTree.d.ts +0 -103
  182. package/dist/collections/SortedTree.js +0 -141
  183. package/dist/collections/SplayTree.d.ts +0 -105
  184. package/dist/collections/SplayTree.js +0 -338
  185. package/dist/collections/Trie.d.ts +0 -42
  186. package/dist/collections/Trie.js +0 -104
  187. package/dist/collections/abc.d.ts +0 -152
  188. package/dist/collections/abc.js +0 -39
  189. package/dist/collections/frozenset.d.ts +0 -19
  190. package/dist/collections/frozenset.js +0 -30
  191. package/dist/functools/index.d.ts +0 -130
  192. package/dist/functools/index.js +0 -235
  193. package/dist/globals/index.d.ts +0 -285
  194. package/dist/globals/index.js +0 -463
  195. package/dist/i18n/currency.d.ts +0 -24
  196. package/dist/i18n/currency.js +0 -85
  197. package/dist/i18n/date/index.d.ts +0 -203
  198. package/dist/i18n/date/index.js +0 -531
  199. package/dist/i18n/date/utils.d.ts +0 -65
  200. package/dist/i18n/date/utils.js +0 -290
  201. package/dist/i18n/duration.d.ts +0 -112
  202. package/dist/i18n/duration.js +0 -392
  203. package/dist/i18n/format.d.ts +0 -31
  204. package/dist/i18n/format.js +0 -506
  205. package/dist/i18n/index.d.ts +0 -8
  206. package/dist/i18n/index.js +0 -8
  207. package/dist/itertools/index.d.ts +0 -255
  208. package/dist/itertools/index.js +0 -437
  209. package/dist/math/index.d.ts +0 -96
  210. package/dist/math/index.js +0 -98
  211. package/dist/mod.d.ts +0 -1
  212. package/dist/mod.js +0 -1
  213. package/dist/operators/index.d.ts +0 -152
  214. package/dist/operators/index.js +0 -305
  215. package/dist/types.d.ts +0 -19
  216. package/dist/types.js +0 -1
@@ -1,645 +1,18 @@
1
1
  /**
2
- * This module includes classes and functions to work with Container types.
3
- *
2
+ * Iteration over objects, arrays, strings, maps, sets and other iterables.
3
+ * Sorted containers, trees, heaps, deques, caches, tries and bisect.
4
4
  * @module collections
5
5
  */
6
- import { compare } from '../operators/index.js';
7
- import { Iteratee } from '../types';
8
- export * from './abc.js';
9
- export * from './BTree.js';
10
- export * from './deque.js';
11
- export * from './frozenset.js';
12
- export * from './Heap.js';
13
- export * from './LRUCache.js';
14
- export * from './SortedMap.js';
15
- export * from './SortedSet.js';
16
- export * from './SortedTree.js';
17
- export * from './SplayTree.js';
18
- export * from './Trie.js';
19
- /**
20
- * Creates a new array with all falsy and empty values removed.
21
- * @param arr The array to compact
22
- * @example
23
- ```js
24
- compact([0, 1, false, 2, '', 3])
25
- // [1, 2, 3]
26
- ```
27
- * @returns A new array with the filtered values
28
- */
29
- export declare function compact<T>(arr: T[]): T[];
30
- export declare function compact<T>(arr: T): Partial<T>;
31
- /**
32
- * Creates an object composed of keys from the results of running elements of `collection` thru `iteratee`. The corresponding value of each key is the number of times the key was returned by `iteratee`.
33
- * @param iterable
34
- * @param func
35
- * @returns {Object} Returns an Object with the frequency values
36
- * @example
37
- ```js
38
- count([6.1, 4.2, 6.3], Math.floor);
39
- // { '4': 1, '6': 2 }
40
-
41
- // property iteratee shorthand.
42
- count(['one', 'two', 'three'], x => x.length);
43
- // { '3': 2, '5': 1 }
44
- ```
45
- */
46
- export declare function count<T>(obj: T[], fn: Iteratee<T>): Record<string, number>;
47
- export declare function count<T>(obj: Object, fn: Iteratee<T>): Record<string, number>;
48
- /**
49
- * Iterates over elements of collection, returning an array of all elements where predicate returns truthy value.
50
- *
51
- * The predicate is invoked with three arguments: `(value, index|key, arr)`.
52
- *
53
- * @example
54
- ```js
55
- let users = [
56
- { 'user': 'barney', 'age': 36, 'active': true },
57
- { 'user': 'fred', 'age': 40, 'active': false }
58
- ]
59
-
60
- filter(users, o => !o.active)
61
- // objects for ['fred']
62
-
63
- // The shape iteratee shorthand.
64
- filter(users, { age: 36, active: true })
65
- // objects for ['barney']
66
-
67
- // The property iteratee shorthand.
68
- filter(users, 'active')
69
- // objects for ['barney']
70
- ```
71
- * @param {Array} arr The collection to iterate over
72
- * @param {Function} fn The predicate function invoked for each item
73
- * @returns {Array} The new filtered array
74
- */
75
- export declare function filter<T>(arr: T[], fn?: Iteratee<T>): T[];
76
- export declare function filter<T>(arr: T[], fn?: Object): T[];
77
- export declare function filter<T>(arr: Object, fn?: Iteratee<T>): T[];
78
- export declare function filter<T>(arr: Object, fn?: Object): T[];
79
- /**
80
- * Iterates over elements of collection, returning the first element where predicate returns truthy value. The predicate is invoked with three arguments: `(value, index|key, collection)`.
81
- * @example
82
- ```js
83
- let users = [
84
- { 'user': 'barney', 'age': 36, 'active': true },
85
- { 'user': 'fred', 'age': 40, 'active': false },
86
- { 'user': 'pebbles', 'age': 1, 'active': true }
87
- ]
88
-
89
- find(users, o => o.age < 40)
90
- // object for 'barney'
91
-
92
- // The shape iteratee shorthand.
93
- find(users, { 'age': 1, 'active': true })
94
- // object for 'pebbles'
95
-
96
- // The `property` iteratee shorthand.
97
- find(users, 'active')
98
- // object for 'barney'
99
- ```
100
- * @param {Array} arr The collection to iterate over.
101
- * @param {Function} fn The function invoked per iteration.
102
- * @returns {*} The matched element, else `undefined`.
103
- * @see {@link findLast}
104
- */
105
- export declare function find<T>(arr: T[], fn: Iteratee<T>): T | undefined;
106
- export declare function find<T>(arr: T[], fn: Object): T | undefined;
107
- export declare function find<T>(arr: T[], fn: PropertyKey): T | undefined;
108
- export declare function find<T>(arr: Object, fn: Iteratee<T>): T | undefined;
109
- export declare function find<T>(arr: Object, fn: Object): T | undefined;
110
- export declare function find<T>(arr: Object, fn: PropertyKey): T | undefined;
111
- /**
112
- * Performs an efficient array insert operation in the given array. If the index or the array is invalid, it just returns the given array.
113
- *
114
- * **Note:** Uses the same behavior as `Array.splice`.
115
- *
116
- * @param {Array<*>} arr The given array to insert into
117
- * @param {number} index The index of the array insert operation.
118
- * @param {*} value The value to insert in the array at the given `index`.
119
- * @returns {Array<*>} The given array.
120
- */
121
- export declare function insert<T>(arr: T[], index: number, value: T): T[];
122
- /**
123
- * Creates a function that performs a partial deep comparison between a given object and `shape`, returning `true` if the given object has equivalent property values, else `false`.
124
- * @example
125
- ```js
126
- let objects = [
127
- { a: 1, b: 2, c: 3 },
128
- { a: 4, b: 5, c: 6 }
129
- ]
130
-
131
- filter(objects, matches({ a: 4, c: 6 }))
132
- // [{ a: 4, b: 5, c: 6 }]
133
- ```
134
- * @param shape
135
- * @returns
136
- */
137
- export declare function matches(shape: any): (obj: any) => boolean;
138
- /**
139
- * Iterates over elements of collection and invokes `iteratee` for each element. The iteratee is invoked with three arguments: `(value, index|key, collection)`. Iteratee functions may exit iteration early by explicitly returning `false`.
140
- * @example
141
- ```js
142
- forEach([1, 2], (value) => {
143
- console.log(value)
144
- })
145
- // 1
146
- // 2
147
-
148
- forEach({ 'a': 1, 'b': 2 }, (value, key) => {
149
- console.log(key)
150
- })
151
- // 'a'
152
- // 'b'
153
- ```
154
- * @param {Array|Object} collection The collection to iterate over.
155
- * @param {Iteratee} fn The function invoked per iteration.
156
- * @returns {*} Returns `collection`.
157
- * @see {@link forEachRight}
158
- * @see {@link filter}
159
- * @see {@link map}
160
- */
161
- export declare function forEach<T>(collection: Iterable<T>, fn: Iteratee<T>): void;
162
- export declare function forEach<T>(collection: Object, fn: Iteratee<T>): void;
163
- /**
164
- * This method is like {@link find} except that it iterates from right to left.
165
- * @example
166
- ```js
167
- findLast([1, 2, 3, 4], n => n % 2 === 1)
168
- // 3
169
- ```
170
- * @param {Array} arr The collection to iterate over.
171
- * @param {Function} fn The function invoked per iteration.
172
- * @returns {*} The matched element, else `undefined`.
173
- * @see {@link find}
174
- */
175
- export declare function findLast<T>(arr: Iterable<T>, fn: Iteratee<T>): T | undefined;
176
- export declare function findLast<T>(arr: Iterable<T>, fn: Object): T | undefined;
177
- export declare function findLast<T>(arr: Object, fn: Iteratee<T>): T | undefined;
178
- export declare function findLast<T>(arr: Object, fn: Object): T | undefined;
179
- /**
180
- * This method is like {@link forEach} except that it iterates over the collection from right to left.
181
-
182
- * @example
183
- ```js
184
- forEachRight([1, 2], console.log)
185
- // 2
186
- // 1
187
- ```
188
- * @param {Array|Object} collection The collection to iterate over.
189
- * @param {Iteratee} fn The function invoked per iteration.
190
- * @returns {*} Returns `collection`.
191
- * @see {@link forEach}
192
- * @see {@link filter}
193
- * @see {@link map}
194
- */
195
- export declare function forEachRight<T>(collection: T[], fn: Iteratee<T>): void;
196
- export declare function forEachRight<T>(collection: Object, fn: Iteratee<T>): void;
197
- /**
198
- * Flattens an array or object. Arrays will be flattened recursively up to `depth` times. Objects will be flattened recursively.
199
- * @example
200
- ```js
201
- flatten([1, [2, [3, [4]], 5]])
202
- // [1, 2, [3, [4]], 5]
203
-
204
- flatten({
205
- dates: {
206
- expiry_date: '30 sep 2018',
207
- available: '30 sep 2017',
208
- min_contract_period: [
209
- {
210
- id: 1,
211
- name: '1 month'
212
- }
213
- ]
214
- },
215
- price: {
216
- currency: 'RM',
217
- value: 1500
218
- }
219
- })
220
- // {
221
- 'dates.expiry_date': '30 sep 2018',
222
- 'dates.available': '30 sep 2017',
223
- 'dates.min_contract_period[0].id': 1,
224
- 'dates.min_contract_period[0].name': '1 month',
225
- 'price.currency': 'RM',
226
- 'price.value': 1500
227
- }
228
- ```
229
- * @param {Array|Object} arr The array or object to flatten.
230
- * @param {number} [depth=1] The max recursion depth.
231
- * @returns {*} The new flattened array or object.
232
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat Array.flat()}
233
- */
234
- export declare function flatten<T>(arr: T[], depth?: boolean | number): T[];
235
- export declare function flatten<T>(arr: Object, depth?: boolean | number): Object;
236
- /**
237
- * Creates an array of values by running each element in collection thru iteratee. The iteratee is invoked with three arguments: `(value, index|key, collection)`.
238
- * @example
239
- ```js
240
- function square(n) {
241
- return n * n
242
- }
243
-
244
- map([4, 8], square)
245
- // [16, 64]
246
-
247
- map({ a: 4, b: 8 }, square)
248
- // [16, 64] (iteration order is not guaranteed)
249
-
250
- let users = [
251
- { user: 'barney' },
252
- { user: 'fred' }
253
- ]
254
-
255
- // The `property` iteratee shorthand.
256
- map(users, 'user')
257
- // ['barney', 'fred']
258
- ```
259
- * @param {Array|Object} arr The collection to iterate over.
260
- * @param {Iteratee} fn The function invoked per iteration.
261
- * @returns Returns the new mapped array.
262
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map Array.map()}
263
- */
264
- export declare function map<T, TResult>(arr: T[], fn: Iteratee<T, PropertyKey, TResult>): TResult[];
265
- export declare function map<T, TResult>(arr: T[], fn: PropertyKey): TResult[];
266
- export declare function map<T, TResult>(arr: Object, fn: Iteratee<T, PropertyKey, TResult>): TResult[];
267
- export declare function map<T, TResult>(arr: Object, fn: PropertyKey): TResult[];
268
- /**
269
- * Creates an object composed of the picked object properties.
270
- * @param {Object} obj The source object.
271
- * @param {Iteratee|PropertyKey[]} paths The properties to pick. If `paths` is a function, it will be invoked per property with two values `(value, key)`.
272
- * @returns A new object with the properties.
273
- * @example
274
- ```js
275
- let object = { a: 1, b: '2', c: 3 }
276
-
277
- pick(object, ['a', 'c'])
278
- // { a: 1, c: 3 }
279
-
280
- pick(object, x => isNumber(x))
281
- // { a: 1, c: 3 }
282
- ```
283
- *
284
- * @see {@link omit}
285
- */
286
- export declare function pick<T>(obj: T, paths: Iteratee): Partial<T>;
287
- export declare function pick<T>(obj: T, paths: PropertyKey[]): Partial<T>;
288
- /**
289
- * The opposite of {@link pick} - this method creates an object composed of the own and inherited enumerable property paths of `object` that are not omitted.
290
- * @example
291
- ```js
292
- let object = { 'a': 1, 'b': '2', 'c': 3 }
293
-
294
- omit(object, ['a', 'c'])
295
- // { 'b': '2' }
296
-
297
- omit(object, x => isNumber(x))
298
- // { 'b': '2' }
299
- ```
300
- * @param {Object} obj The source object.
301
- * @param {Iteratee|PropertyKey[]} paths The property paths to omit.
302
- * @returns {Object} Returns the new object.
303
- * @see {@link pick}
304
- */
305
- export declare function omit<T>(obj: T, paths: Iteratee): Partial<T>;
306
- export declare function omit<T>(obj: T, paths: PropertyKey[]): Partial<T>;
307
- /**
308
- * This method is like {@link find} except that it returns the index of the first element `predicate` returns truthy for instead of the element itself.
309
- * @param {Array} obj The array to inspect.
310
- * @param {string|Object|Iteratee} fn The predicate function
311
- * @param {number} [start=0] The index to search from.
312
- * @returns {number} The index of the found value, else -1
313
- * @example
314
- ```js
315
- let users = [
316
- { 'user': 'barney', 'active': false },
317
- { 'user': 'fred', 'active': false },
318
- { 'user': 'pebbles', 'active': true }
319
- ]
320
-
321
- findIndex(users, o => o.user == 'barney')
322
- // 0
323
-
324
- // The `shape` iteratee shorthand.
325
- findIndex(users, { 'user': 'fred', 'active': false })
326
- // 1
327
-
328
- // The `property` iteratee shorthand.
329
- findIndex(users, 'active')
330
- // 2
331
- ```
332
- * @see {@link indexOf}
333
- * @see {@link findLastIndex}
334
- *
335
- */
336
- export declare function findIndex<T>(obj: T[], fn: Iteratee<T>, start?: number): number;
337
- export declare function findIndex<T>(obj: T[], fn: Object, start?: number): number;
338
- export declare function findIndex<T>(obj: T[], fn: PropertyKey, start?: number): number;
339
- /**
340
- * This method is like {@link findIndex} except that it searches for a given value directly, instead of using a predicate function.
341
- * @param {Array} obj The array to inspect.
342
- * @param {*} value The value to find
343
- * @param {number} [start=0] The index to search from.
344
- * @returns {number} The index of the found value, else -1
345
- * @example
346
- ```js
347
- indexOf([1, 2, 1, 2], 2)
348
- // 1
349
-
350
- // Search from a `start` index.
351
- indexOf([1, 2, 1, 2], 2, 2)
352
- // 3
353
- ```
354
- * @see {@link findIndex}
355
- * @see {@link lastIndexOf}
356
- */
357
- export declare function indexOf<T>(obj: T[], value: T, start?: number): number;
358
- /**
359
- * This method is like {@link findIndex} except that it iterates the collection from right to left.
360
- * @param {Array} arr The array to inspect.
361
- * @param {string|Iteratee|Object} fn The function invoked per iteration.
362
- * @param {number} [start] The index to search from.
363
- * @returns {number} The index of the found value, else -1
364
- * @example
365
- ```js
366
- let users = [
367
- { 'user': 'barney', 'active': true },
368
- { 'user': 'fred', 'active': false },
369
- { 'user': 'pebbles', 'active': false }
370
- ]
371
-
372
- findLastIndex(users, o => o.user == 'pebbles')
373
- // 2
374
-
375
- // The `shape` iteratee shorthand.
376
- findLastIndex(users, { 'user': 'barney', 'active': true })
377
- // 0
378
-
379
- // The `property` iteratee shorthand.
380
- findLastIndex(users, 'active')
381
- // 0
382
- ```
383
- * @see {@link findIndex}
384
- * @see {@link lastIndexOf}
385
- */
386
- export declare function findLastIndex<T>(arr: T[], fn: Iteratee<T>, start?: number): number;
387
- export declare function findLastIndex<T>(arr: T[], fn: Object, start?: number): number;
388
- export declare function findLastIndex<T>(arr: T[], fn: PropertyKey, start?: number): number;
389
- /**
390
- * This method is like {@link indexOf} except that it iterates the collection from right to left.
391
- * @param {Array} obj The array to inspect.
392
- * @param {*} value The value to find
393
- * @param {number} [start] The index to search from.
394
- * @returns {number} The index of the found value, else -1
395
- * @example
396
- ```js
397
- lastIndexOf([1, 2, 1, 2], 2)
398
- // 3
399
-
400
- // Search from the `fromIndex`.
401
- lastIndexOf([1, 2, 1, 2], 2, 2)
402
- // 1
403
- ```
404
- * @see {@link findLastIndex}
405
- * @see {@link indexOf}
406
- */
407
- export declare function lastIndexOf<T>(obj: T[], value: T, start?: number): number;
408
- /**
409
- * Creates a shallow clone of `value`. If `deep` is `true` it will clone it recursively.
410
- * @param {*} value
411
- * @param {boolean} [deep=false]
412
- * @return The clone value
413
- * @see {@link cloneArray}
414
- * @see {@link cloneTypedArray}
415
- */
416
- export declare function clone<T>(value: T, deep?: boolean): T;
417
- export declare function clone<T>(value: T[], deep?: boolean): T[];
418
- /**
419
- * Clones an array. If `deep` is `false` (default) the clone will be shallow. Otherwise {@link https://developer.mozilla.org/en-US/docs/Web/API/structuredClone structuredClone} is used.
420
- * @param arr The array to clone
421
- * @param [deep=false] Creates a deep clone using `structuredClone` if true.
422
- * @returns The new array
423
- * @see {@link clone}
424
- */
425
- export declare function cloneArray<T>(arr: T[], deep?: boolean): T[];
426
- /**
427
- * Clones a typed array. If `deep` is `false` (default) the clone will be shallow. Otherwise {@link https://developer.mozilla.org/en-US/docs/Web/API/structuredClone structuredClone} is used.
428
- * @param arr The array to clone
429
- * @param [deep=false] Creates a deep clone using `structuredClone` if true.
430
- * @returns The new array
431
- * @see {@link clone}
432
- */
433
- export declare function cloneTypedArray(typedArray: any, isDeep?: boolean): any;
434
- /**
435
- * Creates a duplicate-free version of an array, using a `Set` for equality comparisons, in which only the first occurrence of each element is kept. The order of result values is not guaranteed.
436
- * @param arr The array containing duplicated elements
437
- * @param fn The iteratee invoked per element.
438
- * @returns Returns the new duplicate free array.
439
- * @example
440
- ```js
441
- uniq([2, 1, 2])
442
- // [2, 1]
443
-
444
- uniq([2.1, 1.2, 2.3], Math.floor)
445
- // [2.1, 1.2]
446
- ```
447
- *
448
- * @see {@link sortedUniq}
449
- */
450
- export declare function uniq<T>(arr: Iterable<T>, fn?: Iteratee<T>): T[];
451
- export declare function uniq<T>(arr: Iterable<T>, fn?: PropertyKey): T[];
452
- /**
453
- * This method is like {@link uniq} except that it sorts the results in ascending order
454
- * @param arr The array containing duplicated elements
455
- * @param fn The iteratee invoked per element.
456
- * @returns Returns the new duplicate free array
457
- * @example
458
- ```js
459
- uniq([2, 1, 2])
460
- // [1, 2]
461
- ```
462
- * @see {@link uniq}
463
- */
464
- export declare function sortedUniq<T>(arr: Iterable<T>, fn?: Iteratee<T>): T[];
465
- export declare function sortedUniq<T>(arr: Iterable<T>, fn?: PropertyKey): T[];
466
- /**
467
- * Recursively merges own and inherited enumerable string keyed properties of source objects into the destination object. Source properties that resolve to `undefined` are skipped if a destination value exists. Array and plain object properties are merged recursively. Other objects and value types are overridden by assignment. Source objects are applied from left to right. Subsequent sources overwrite property assignments of previous sources.
468
- *
469
- * Note: this method mutates `object`
470
- *
471
- *
472
- * @param {Object} object The destination object.
473
- * @param {...Object} sources The source objects.
474
- * @returns Returns `object`.
475
- *
476
- * @example
477
- ```js
478
- let object = {
479
- 'a': [{ 'b': 2 }, { 'd': 4 }]
480
- }
481
-
482
- let other = {
483
- 'a': [{ 'c': 3 }, { 'e': 5 }]
484
- }
485
-
486
- merge(object, other)
487
- // { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
488
- ```
489
- */
490
- export declare function merge(object: Object, ...sources: Object[]): Object;
491
- /**
492
- * Assigns own and inherited enumerable string keyed properties of source objects to the destination object for all destination properties that resolve to `undefined`. Source objects are applied from left to right. Once a property is set, additional values of the same property are ignored.
493
- * **Note:** This method mutates `object`.
494
-
495
- * @param {Object} object The destination object.
496
- * @param {...Object} [sources] The source objects.
497
- * @returns Returns `object`.
498
- * @example
499
- ```js
500
- defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 })
501
- // { 'a': 1, 'b': 2 }
502
- ```
503
- */
504
- export declare function defaults(object: Object, ...sources: Object[]): Object;
505
- /**
506
- * Returns a generator of array values not included in the other given arrays using a `Set` for equality comparisons. The order and references of result values are not guaranteed.
507
- * @param args The initial arrays
508
- * @example
509
- ```js
510
- [...difference([2, 1], [2, 3])]
511
- // [1]
512
- ```
513
- * @see {@link union}
514
- * @see {@link intersection}
515
- */
516
- export declare function difference<T>(...args: Array<Iterable<T>>): Generator<T>;
517
- /**
518
- * Creates a generator of unique values that are included in all given arrays.
519
- * @param args The arrays to inspect
520
- * @example
521
- ```js
522
- [...intersection([2, 1], [2, 3])]
523
- // [2]
524
- ```
525
- * @see {@link difference}
526
- * @see {@link union}
527
- */
528
- export declare function intersection<T>(...args: Array<Iterable<T>>): Generator<T>;
529
- /**
530
- * Creates a generator of unique values from all given arrays using `Set` for equality comparisons.
531
- * @param args The arrays to perform union on.
532
- * @example
533
- ```js
534
- [...union([2], [1, 2])]
535
- // [2, 1]
536
- ```
537
- * @see {@link difference}
538
- * @see {@link intersection}
539
- */
540
- export declare function union<T>(...args: Array<Iterable<T>>): Generator<T>;
541
- /**
542
- * Creates an object composed of keys generated from the results of running each element of `arr` thru `func`. The order of grouped values is determined by the order they occur in `arr`. The corresponding value of each key is an array of elements responsible for generating the key.
543
- *
544
- * @param arr The collection to iterate over.
545
- * @param [func=id] The iteratee to transform keys.
546
- * @returns Returns the aggregated object.
547
- *
548
- * @example
549
- ```js
550
- groupBy([6.1, 4.2, 6.3], Math.floor)
551
- // { '4': [4.2], '6': [6.1, 6.3] }
552
-
553
- // The `property` iteratee shorthand.
554
- groupBy(['one', 'two', 'three'], 'length')
555
- // { '3': ['one', 'two'], '5': ['three'] }
556
- ```
557
- */
558
- export declare function groupBy<T>(arr: Iterable<T>, fn: Iteratee<T>): Record<PropertyKey, T[]>;
559
- export declare function groupBy<T>(arr: Iterable<T>, fn: PropertyKey): Record<PropertyKey, T[]>;
560
- export declare function groupBy<T>(arr: Object, fn: Iteratee<T>): Record<PropertyKey, T[]>;
561
- export declare function groupBy<T>(arr: Object, fn: PropertyKey): Record<PropertyKey, T[]>;
562
- /**
563
- * Similar to {@link groupBy} but it returns a {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map Map} object with the results.
564
- *
565
- * @param arr The collection to iterate over.
566
- * @param {Function | PropertyKey} [func=id] The iteratee to transform keys.
567
- * @returns {Map} Returns the aggregated map object.
568
- * @template K, V
569
- *
570
- * @example
571
- ```js
572
- groupByMap([6.1, 4.2, 6.3], Math.floor)
573
- // Map { 4: [4.2], 6: [6.1, 6.3] }
574
-
575
- // The `property` iteratee shorthand.
576
- groupByMap(['one', 'two', 'three'], 'length')
577
- // Map { 3: ['one', 'two'], 5: ['three'] }
578
- ```
579
- */
580
- export declare function groupByMap<V>(arr: Iterable<V>, fn: Iteratee<V>): Map<any, V[]>;
581
- export declare function groupByMap<V>(arr: Iterable<V>, fn: PropertyKey): Map<any, V[]>;
582
- export declare function groupByMap<V>(arr: Object, fn: Iteratee<V>): Map<any, V[]>;
583
- export declare function groupByMap<V>(arr: Object, fn: PropertyKey): Map<any, V[]>;
584
- /**
585
- * Removes all elements from array that `func` returns truthy for and returns an array of the removed elements.
586
- * @param arr The array to remove from.
587
- * @param func The function invoked per iteration or value(s) or value to remove.
588
- * @returns
589
- */
590
- export declare function remove<T>(arr: T[], func: T): T[];
591
- export declare function remove<T>(arr: T[], func: T[]): T[];
592
- export declare function remove<T>(arr: T[], func: Iteratee<T>): T[];
593
- /**
594
- * Returns the index of `x` in a **sorted** array if found, in `O(log n)` using binary search.
595
- * If the element is not found, returns a negative integer.
596
- * @param arr The array to sort
597
- * @param x The element to find
598
- * @param lo The starting index
599
- * @param hi The end index to search within
600
- * @param comp The compare function to check for `x`
601
- * @returns {number} The index if the element is found or a negative integer.
602
- */
603
- export declare function binarySearch(arr: any[], x: any, lo?: number, hi?: any, comp?: typeof compare): number;
604
- /**
605
- * Returns an insertion index which comes after any existing entries of `x` in a **sorted** array, using binary search.
606
- * @param arr The array to sort
607
- * @param x The element to find
608
- * @param lo The starting index
609
- * @param hi The end index to search within
610
- * @param comp The compare function to check for `x`
611
- * @returns {number}
612
- */
613
- export declare function bisect(arr: any[], x: any, lo?: number, hi?: any, comp?: typeof compare): number;
614
- /**
615
- * Returns an insertion index which comes before any existing entries of `x` in a **sorted** array, using binary search.
616
- * @param arr The array to sort
617
- * @param x The element to find
618
- * @param lo The starting index
619
- * @param hi The end index to search within
620
- * @param comp The compare function to check for `x`
621
- * @returns {number}
622
- */
623
- export declare function bisectLeft(arr: any[], x: any, lo?: number, hi?: any, comp?: typeof compare): number;
624
- /**
625
- * Runs {@link bisect} first to locate an insertion point, and inserts the value `x` in the sorted array after any existing entries of `x` to maintain sort order.
626
- * Please note this method is `O(n)` because insertion resizes the array.
627
- * @param arr The array to insert into
628
- * @param x The element to insert
629
- * @param lo The starting index
630
- * @param hi The end index to search within
631
- * @param comp The compare function to check for `x`
632
- * @returns {Array}
633
- */
634
- export declare function insort<T>(arr: T[], x: any, lo?: number, hi?: any, comp?: typeof compare): T[];
635
- /**
636
- * Runs {@link bisectLeft} first to locate an insertion point, and inserts the value `x` in the sorted array before any existing entries of `x` to maintain sort order.
637
- * Please note this method is `O(n)` because insertion resizes the array.
638
- * @param arr The array to insert into
639
- * @param x The element to insert
640
- * @param lo The starting index
641
- * @param hi The end index to search within
642
- * @param comp The compare function to check for `x`
643
- * @returns {Array}
644
- */
645
- export declare function insortLeft<T>(arr: T[], x: any, lo?: number, hi?: any, comp?: typeof compare): T[];
6
+ export { entries, includes, isEmpty, keys, size, values } from './entries.js';
7
+ export { countBy, groupBy, keyBy, maxBy, meanBy, minBy, orderBy, partition, type SortKey, type SortOrder, sortBy, sumBy } from './group.js';
8
+ export { type CollectionReducer, every, filter, find, findLast, flatMap, forEach, forEachRight, map, reduce, reduceRight, reject, some } from './iterate.js';
9
+ export type { Collection, CollectionCallback, CollectionKey, CollectionValue } from './shape.js';
10
+ export { binarySearch, bisect, bisectLeft, bisectRight, insort, insortLeft } from './bisect.js';
11
+ export { Deque } from './deque.js';
12
+ export { FrozenSet } from './frozen-set.js';
13
+ export { Heap } from './heap.js';
14
+ export { LRUCache } from './lru-cache.js';
15
+ export { SortedMap } from './sorted-map.js';
16
+ export { SortedSet } from './sorted-set.js';
17
+ export { SplayTree } from './splay-tree.js';
18
+ export { Trie } from './trie.js';