atomic-fns 1.2.0 → 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 +397 -91
  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 -256
  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 -623
  27. package/dist/collections/index.js +14 -844
  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 -148
  55. package/dist/decimal/index.js +10 -410
  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 -53
  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 -224
  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 +99 -51
  171. package/dist/collections/BTree.d.ts +0 -230
  172. package/dist/collections/BTree.js +0 -1143
  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 -83
  176. package/dist/collections/LRUCache.js +0 -139
  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 -142
  183. package/dist/collections/SplayTree.d.ts +0 -107
  184. package/dist/collections/SplayTree.js +0 -351
  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 -33
  191. package/dist/functools/index.d.ts +0 -106
  192. package/dist/functools/index.js +0 -203
  193. package/dist/globals/index.d.ts +0 -268
  194. package/dist/globals/index.js +0 -447
  195. package/dist/i18n/currency.d.ts +0 -27
  196. package/dist/i18n/currency.js +0 -100
  197. package/dist/i18n/date/index.d.ts +0 -210
  198. package/dist/i18n/date/index.js +0 -552
  199. package/dist/i18n/date/utils.d.ts +0 -64
  200. package/dist/i18n/date/utils.js +0 -192
  201. package/dist/i18n/duration.d.ts +0 -113
  202. package/dist/i18n/duration.js +0 -398
  203. package/dist/i18n/format.d.ts +0 -34
  204. package/dist/i18n/format.js +0 -378
  205. package/dist/i18n/index.d.ts +0 -9
  206. package/dist/i18n/index.js +0 -8
  207. package/dist/itertools/index.d.ts +0 -251
  208. package/dist/itertools/index.js +0 -434
  209. package/dist/math/index.d.ts +0 -79
  210. package/dist/math/index.js +0 -81
  211. package/dist/mod.d.ts +0 -1
  212. package/dist/mod.js +0 -1
  213. package/dist/operators/index.d.ts +0 -148
  214. package/dist/operators/index.js +0 -325
  215. package/dist/types.d.ts +0 -19
  216. package/dist/types.js +0 -1
@@ -1,626 +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 type { Iteratee } from '../types.js';
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
- count(['one', 'two', 'three'], x => x.length);
42
- // { '3': 2, '5': 1 }
43
- ```
44
- */
45
- export declare function count<T>(obj: T[], fn: Iteratee<T>): Record<string, number>;
46
- export declare function count<T>(obj: Object, fn: Iteratee<T>): Record<string, number>;
47
- /**
48
- * Iterates over elements of collection, returning an array of all elements where predicate returns truthy value.
49
- *
50
- * The predicate is invoked with three arguments: `(value, index|key, arr)`.
51
- *
52
- * @example
53
- ```js
54
- let users = [
55
- { 'user': 'barney', 'age': 36, 'active': true },
56
- { 'user': 'fred', 'age': 40, 'active': false }
57
- ]
58
-
59
- filter(users, o => !o.active)
60
- // objects for ['fred']
61
-
62
- // The shape iteratee shorthand.
63
- filter(users, { age: 36, active: true })
64
- // objects for ['barney']
65
-
66
- // The property iteratee shorthand.
67
- filter(users, 'active')
68
- // objects for ['barney']
69
- ```
70
- * @param {Array} arr The collection to iterate over
71
- * @param {Function} fn The predicate function invoked for each item
72
- * @returns {Array} The new filtered array
73
- */
74
- export declare function filter<T>(arr: T[], fn?: Iteratee<T>): T[];
75
- export declare function filter<T>(arr: T[], fn?: Object): T[];
76
- export declare function filter<T>(arr: Object, fn?: Iteratee<T>): T[];
77
- export declare function filter<T>(arr: Object, fn?: Object): T[];
78
- /**
79
- * 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)`.
80
- * @example
81
- ```js
82
- let users = [
83
- { 'user': 'barney', 'age': 36, 'active': true },
84
- { 'user': 'fred', 'age': 40, 'active': false },
85
- { 'user': 'pebbles', 'age': 1, 'active': true }
86
- ]
87
-
88
- find(users, o => o.age < 40)
89
- // object for 'barney'
90
-
91
- // The shape iteratee shorthand.
92
- find(users, { 'age': 1, 'active': true })
93
- // object for 'pebbles'
94
-
95
- // The `property` iteratee shorthand.
96
- find(users, 'active')
97
- // object for 'barney'
98
- ```
99
- * @param {Array} arr The collection to iterate over.
100
- * @param {Function} fn The function invoked per iteration.
101
- * @returns {*} The matched element, else `undefined`.
102
- * @see {@link findLast}
103
- */
104
- export declare function find<T>(arr: T[], fn: Iteratee<T>): T | undefined;
105
- export declare function find<T>(arr: T[], fn: Object): T | undefined;
106
- export declare function find<T>(arr: T[], fn: PropertyKey): T | undefined;
107
- export declare function find<T>(arr: Object, fn: Iteratee<T>): T | undefined;
108
- export declare function find<T>(arr: Object, fn: Object): T | undefined;
109
- export declare function find<T>(arr: Object, fn: PropertyKey): T | undefined;
110
- /**
111
- * Performs an efficient array insert operation in the given array. If the index or the array is invalid, it just returns the given array.
112
- *
113
- * **Note:** Uses the same behavior as `Array.splice`.
114
- *
115
- * @param {Array<*>} arr The given array to insert into
116
- * @param {number} index The index of the array insert operation.
117
- * @param {*} value The value to insert in the array at the given `index`.
118
- * @returns {Array<*>} The given array.
119
- */
120
- export declare function insert<T>(arr: T[], index: number, value: T): T[];
121
- /**
122
- * 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`.
123
- * @example
124
- ```js
125
- let objects = [
126
- { a: 1, b: 2, c: 3 },
127
- { a: 4, b: 5, c: 6 }
128
- ]
129
-
130
- filter(objects, matches({ a: 4, c: 6 }))
131
- // [{ a: 4, b: 5, c: 6 }]
132
- ```
133
- * @param shape
134
- * @returns
135
- */
136
- export declare function matches(shape: any): (obj: any) => boolean;
137
- /**
138
- * 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`.
139
- * @example
140
- ```js
141
- forEach([1, 2], (value) => {
142
- console.log(value)
143
- })
144
- // 1
145
- // 2
146
-
147
- forEach({ 'a': 1, 'b': 2 }, (value, key) => {
148
- console.log(key)
149
- })
150
- // 'a'
151
- // 'b'
152
- ```
153
- * @param {Array|Object} collection The collection to iterate over.
154
- * @param {Iteratee} fn The function invoked per iteration.
155
- * @returns {void}
156
- * @see {@link forEachRight}
157
- * @see {@link filter}
158
- * @see {@link map}
159
- */
160
- export declare function forEach<T>(collection: Iterable<T>, fn: Iteratee<T>): void;
161
- export declare function forEach<T>(collection: Object, fn: Iteratee<T>): void;
162
- /**
163
- * This method is like {@link find} except that it iterates from right to left.
164
- * @example
165
- ```js
166
- findLast([1, 2, 3, 4], n => n % 2 === 1)
167
- // 3
168
- ```
169
- * @param {Array} arr The collection to iterate over.
170
- * @param {Function} fn The function invoked per iteration.
171
- * @returns {*} The matched element, else `undefined`.
172
- * @see {@link find}
173
- */
174
- export declare function findLast<T>(arr: Iterable<T>, fn: Iteratee<T>): T | undefined;
175
- export declare function findLast<T>(arr: Iterable<T>, fn: Object): T | undefined;
176
- export declare function findLast<T>(arr: Object, fn: Iteratee<T>): T | undefined;
177
- export declare function findLast<T>(arr: Object, fn: Object): T | undefined;
178
- /**
179
- * This method is like {@link forEach} except that it iterates over the collection from right to left.
180
-
181
- * @example
182
- ```js
183
- forEachRight([1, 2], console.log)
184
- // 2
185
- // 1
186
- ```
187
- * @param {Array|Object} collection The collection to iterate over.
188
- * @param {Iteratee} fn The function invoked per iteration.
189
- * @returns {void}
190
- * @see {@link forEach}
191
- * @see {@link filter}
192
- * @see {@link map}
193
- */
194
- export declare function forEachRight<T>(collection: T[], fn: Iteratee<T>): void;
195
- export declare function forEachRight<T>(collection: Object, fn: Iteratee<T>): void;
196
- /**
197
- * Flattens an array or object. Arrays will be flattened recursively up to `depth` times. Objects will be flattened recursively.
198
- * @example
199
- ```js
200
- flatten([1, [2, [3, [4]], 5]])
201
- // [1, 2, [3, [4]], 5]
202
-
203
- flatten({
204
- dates: {
205
- expiry_date: '30 sep 2018',
206
- available: '30 sep 2017',
207
- min_contract_period: [
208
- {
209
- id: 1,
210
- name: '1 month'
211
- }
212
- ]
213
- },
214
- price: {
215
- currency: 'RM',
216
- value: 1500
217
- }
218
- })
219
- // {
220
- 'dates.expiry_date': '30 sep 2018',
221
- 'dates.available': '30 sep 2017',
222
- 'dates.min_contract_period[0].id': 1,
223
- 'dates.min_contract_period[0].name': '1 month',
224
- 'price.currency': 'RM',
225
- 'price.value': 1500
226
- }
227
- ```
228
- * @param {Array|Object} arr The array or object to flatten.
229
- * @param {number} [depth=1] The max recursion depth.
230
- * @returns {*} The new flattened array or object.
231
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat Array.flat()}
232
- */
233
- export declare function flatten<T>(arr: T[], depth?: boolean | number): T[];
234
- export declare function flatten<T>(arr: Object, depth?: boolean | number): Object;
235
- /**
236
- * Creates an array of values by running each element in collection thru iteratee. The iteratee is invoked with three arguments: `(value, index|key, collection)`.
237
- * @example
238
- ```js
239
- function square(n) {
240
- return n * n
241
- }
242
-
243
- map([4, 8], square)
244
- // [16, 64]
245
-
246
- map({ a: 4, b: 8 }, square)
247
- // [16, 64] (iteration order is not guaranteed)
248
-
249
- let users = [
250
- { user: 'barney' },
251
- { user: 'fred' }
252
- ]
253
-
254
- // The `property` iteratee shorthand.
255
- map(users, 'user')
256
- // ['barney', 'fred']
257
- ```
258
- * @param {Array|Object} arr The collection to iterate over.
259
- * @param {Iteratee} fn The function invoked per iteration.
260
- * @returns Returns the new mapped array.
261
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map Array.map()}
262
- */
263
- export declare function map<T, TResult>(arr: T[], fn: Iteratee<T, PropertyKey, TResult>): TResult[];
264
- export declare function map<T, TResult>(arr: T[], fn: PropertyKey): TResult[];
265
- export declare function map<T, TResult>(arr: Object, fn: Iteratee<T, PropertyKey, TResult>): TResult[];
266
- export declare function map<T, TResult>(arr: Object, fn: PropertyKey): TResult[];
267
- /**
268
- * Creates an object composed of the picked object properties.
269
- * @param {Object} obj The source object.
270
- * @param {Iteratee|PropertyKey[]} paths The properties to pick. If `paths` is a function, it will be invoked per property with two values `(value, key)`.
271
- * @returns A new object with the properties.
272
- * @example
273
- ```js
274
- let object = { a: 1, b: '2', c: 3 }
275
-
276
- pick(object, ['a', 'c'])
277
- // { a: 1, c: 3 }
278
-
279
- pick(object, x => isNumber(x))
280
- // { a: 1, c: 3 }
281
- ```
282
- *
283
- * @see {@link omit}
284
- */
285
- export declare function pick<T>(obj: T, paths: Iteratee): Partial<T>;
286
- export declare function pick<T>(obj: T, paths: PropertyKey[]): Partial<T>;
287
- /**
288
- * The opposite of {@link pick} - this method creates an object composed of the own enumerable properties of `object` that are not omitted.
289
- * @example
290
- ```js
291
- let object = { 'a': 1, 'b': '2', 'c': 3 }
292
-
293
- omit(object, ['a', 'c'])
294
- // { 'b': '2' }
295
-
296
- omit(object, x => isNumber(x))
297
- // { 'b': '2' }
298
- ```
299
- * @param {Object} obj The source object.
300
- * @param {Iteratee|PropertyKey[]} paths The property paths to omit.
301
- * @returns {Object} Returns the new object.
302
- * @see {@link pick}
303
- */
304
- export declare function omit<T>(obj: T, paths: Iteratee): Partial<T>;
305
- export declare function omit<T>(obj: T, paths: PropertyKey[]): Partial<T>;
306
- /**
307
- * 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.
308
- * @param {Array} obj The array to inspect.
309
- * @param {string|Object|Iteratee} fn The predicate function
310
- * @param {number} [start=0] The index to search from.
311
- * @returns {number} The index of the found value, else -1
312
- * @example
313
- ```js
314
- let users = [
315
- { 'user': 'barney', 'active': false },
316
- { 'user': 'fred', 'active': false },
317
- { 'user': 'pebbles', 'active': true }
318
- ]
319
-
320
- findIndex(users, o => o.user == 'barney')
321
- // 0
322
-
323
- // The `shape` iteratee shorthand.
324
- findIndex(users, { 'user': 'fred', 'active': false })
325
- // 1
326
-
327
- // The `property` iteratee shorthand.
328
- findIndex(users, 'active')
329
- // 2
330
- ```
331
- * @see {@link indexOf}
332
- * @see {@link findLastIndex}
333
- *
334
- */
335
- export declare function findIndex<T>(obj: T[], fn: Iteratee<T>, start?: number): number;
336
- export declare function findIndex<T>(obj: T[], fn: Object, start?: number): number;
337
- export declare function findIndex<T>(obj: T[], fn: PropertyKey, start?: number): number;
338
- /**
339
- * This method is like {@link findIndex} except that it searches for a given value directly, instead of using a predicate function.
340
- * @param {Array} obj The array to inspect.
341
- * @param {*} value The value to find
342
- * @param {number} [start=0] The index to search from.
343
- * @returns {number} The index of the found value, else -1
344
- * @example
345
- ```js
346
- indexOf([1, 2, 1, 2], 2)
347
- // 1
348
-
349
- // Search from a `start` index.
350
- indexOf([1, 2, 1, 2], 2, 2)
351
- // 3
352
- ```
353
- * @see {@link findIndex}
354
- * @see {@link lastIndexOf}
355
- */
356
- export declare function indexOf<T>(obj: T[], value: T, start?: number): number;
357
- /**
358
- * This method is like {@link findIndex} except that it iterates the collection from right to left.
359
- * @param {Array} arr The array to inspect.
360
- * @param {string|Iteratee|Object} fn The function invoked per iteration.
361
- * @param {number} [start] The index to search from.
362
- * @returns {number} The index of the found value, else -1
363
- * @example
364
- ```js
365
- let users = [
366
- { 'user': 'barney', 'active': true },
367
- { 'user': 'fred', 'active': false },
368
- { 'user': 'pebbles', 'active': false }
369
- ]
370
-
371
- findLastIndex(users, o => o.user == 'pebbles')
372
- // 2
373
-
374
- // The `shape` iteratee shorthand.
375
- findLastIndex(users, { 'user': 'barney', 'active': true })
376
- // 0
377
-
378
- // The `property` iteratee shorthand.
379
- findLastIndex(users, 'active')
380
- // 0
381
- ```
382
- * @see {@link findIndex}
383
- * @see {@link lastIndexOf}
384
- */
385
- export declare function findLastIndex<T>(arr: T[], fn: Iteratee<T>, start?: number): number;
386
- export declare function findLastIndex<T>(arr: T[], fn: Object, start?: number): number;
387
- export declare function findLastIndex<T>(arr: T[], fn: PropertyKey, start?: number): number;
388
- /**
389
- * This method is like {@link indexOf} except that it iterates the collection from right to left.
390
- * @param {Array} obj The array to inspect.
391
- * @param {*} value The value to find
392
- * @param {number} [start] The index to search from.
393
- * @returns {number} The index of the found value, else -1
394
- * @example
395
- ```js
396
- lastIndexOf([1, 2, 1, 2], 2)
397
- // 3
398
-
399
- // Search from the `fromIndex`.
400
- lastIndexOf([1, 2, 1, 2], 2, 2)
401
- // 1
402
- ```
403
- * @see {@link findLastIndex}
404
- * @see {@link indexOf}
405
- */
406
- export declare function lastIndexOf<T>(obj: T[], value: T, start?: number): number;
407
- /**
408
- * Creates a shallow clone of `value`. If `deep` is `true` it will clone it recursively.
409
- * @param {*} value
410
- * @param {boolean} [deep=false]
411
- * @return The clone value
412
- */
413
- export declare function clone<T>(value: T, deep?: boolean): T;
414
- export declare function clone<T>(value: T[], deep?: boolean): T[];
415
- /**
416
- * 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.
417
- * @param arr The array containing duplicated elements
418
- * @param fn The iteratee invoked per element.
419
- * @returns Returns the new duplicate free array.
420
- * @example
421
- ```js
422
- uniq([2, 1, 2])
423
- // [2, 1]
424
-
425
- uniq([2.1, 1.2, 2.3], Math.floor)
426
- // [2.1, 1.2]
427
- ```
428
- *
429
- * @see {@link sortedUniq}
430
- */
431
- export declare function uniq<T>(arr: Iterable<T>, fn?: Iteratee<T>): T[];
432
- export declare function uniq<T>(arr: Iterable<T>, fn?: PropertyKey): T[];
433
- /**
434
- * This method is like {@link uniq} except that it sorts the results in ascending order
435
- * @param arr The array containing duplicated elements
436
- * @param fn The iteratee invoked per element.
437
- * @returns Returns the new duplicate free array
438
- * @example
439
- ```js
440
- sortedUniq([2, 1, 2])
441
- // [1, 2]
442
- ```
443
- * @see {@link uniq}
444
- */
445
- export declare function sortedUniq<T>(arr: Iterable<T>, fn?: Iteratee<T>): T[];
446
- export declare function sortedUniq<T>(arr: Iterable<T>, fn?: PropertyKey): T[];
447
- /**
448
- * Recursively merges own 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.
449
- *
450
- * Note: this method mutates `object`
451
- *
452
- *
453
- * @param {Object} object The destination object.
454
- * @param {...Object} sources The source objects.
455
- * @returns Returns `object`.
456
- *
457
- * @example
458
- ```js
459
- let object = {
460
- 'a': [{ 'b': 2 }, { 'd': 4 }]
461
- }
462
-
463
- let other = {
464
- 'a': [{ 'c': 3 }, { 'e': 5 }]
465
- }
466
-
467
- merge(object, other)
468
- // { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
469
- ```
470
- */
471
- export declare function merge(object: Object, ...sources: Object[]): Object;
472
- /**
473
- * 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.
474
- * **Note:** This method mutates `object`.
475
-
476
- * @param {Object} object The destination object.
477
- * @param {...Object} [sources] The source objects.
478
- * @returns Returns `object`.
479
- * @example
480
- ```js
481
- defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 })
482
- // { 'a': 1, 'b': 2 }
483
- ```
484
- */
485
- export declare function defaults(object: Object, ...sources: Object[]): Object;
486
- /**
487
- * 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.
488
- * @param args The initial arrays
489
- * @example
490
- ```js
491
- [...difference([2, 1], [2, 3])]
492
- // [1]
493
- ```
494
- * @see {@link union}
495
- * @see {@link intersection}
496
- */
497
- export declare function difference<T>(...args: Array<Iterable<T>>): Generator<T>;
498
- /**
499
- * Creates a generator of unique values that are included in all given arrays.
500
- * @param args The arrays to inspect
501
- * @example
502
- ```js
503
- [...intersection([2, 1], [2, 3])]
504
- // [2]
505
- ```
506
- * @see {@link difference}
507
- * @see {@link union}
508
- */
509
- export declare function intersection<T>(...args: Array<Iterable<T>>): Generator<T>;
510
- /**
511
- * Creates a generator of unique values from all given arrays using `Set` for equality comparisons.
512
- * @param args The arrays to perform union on.
513
- * @example
514
- ```js
515
- [...union([2], [1, 2])]
516
- // [2, 1]
517
- ```
518
- * @see {@link difference}
519
- * @see {@link intersection}
520
- */
521
- export declare function union<T>(...args: Array<Iterable<T>>): Generator<T>;
522
- /**
523
- * 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.
524
- *
525
- * @param arr The collection to iterate over.
526
- * @param [func=identity] The iteratee to transform keys.
527
- * @returns Returns the aggregated object.
528
- *
529
- * @example
530
- ```js
531
- groupBy([6.1, 4.2, 6.3], Math.floor)
532
- // { '4': [4.2], '6': [6.1, 6.3] }
533
-
534
- // The `property` iteratee shorthand.
535
- groupBy(['one', 'two', 'three'], 'length')
536
- // { '3': ['one', 'two'], '5': ['three'] }
537
- ```
538
- */
539
- export declare function groupBy<T>(arr: Iterable<T>, fn: Iteratee<T>): Record<PropertyKey, T[]>;
540
- export declare function groupBy<T>(arr: Iterable<T>, fn: PropertyKey): Record<PropertyKey, T[]>;
541
- export declare function groupBy<T>(arr: Object, fn: Iteratee<T>): Record<PropertyKey, T[]>;
542
- export declare function groupBy<T>(arr: Object, fn: PropertyKey): Record<PropertyKey, T[]>;
543
- /**
544
- * 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.
545
- *
546
- * @param arr The collection to iterate over.
547
- * @param {Function | PropertyKey} [func=identity] The iteratee to transform keys.
548
- * @returns {Map} Returns the aggregated map object.
549
- * @template K, V
550
- *
551
- * @example
552
- ```js
553
- groupByMap([6.1, 4.2, 6.3], Math.floor)
554
- // Map { 6: [6.1, 6.3], 4: [4.2] }
555
-
556
- // The `property` iteratee shorthand.
557
- groupByMap(['one', 'two', 'three'], 'length')
558
- // Map { 3: ['one', 'two'], 5: ['three'] }
559
- ```
560
- */
561
- export declare function groupByMap<V>(arr: Iterable<V>, fn: Iteratee<V>): Map<any, V[]>;
562
- export declare function groupByMap<V>(arr: Iterable<V>, fn: PropertyKey): Map<any, V[]>;
563
- export declare function groupByMap<V>(arr: Object, fn: Iteratee<V>): Map<any, V[]>;
564
- export declare function groupByMap<V>(arr: Object, fn: PropertyKey): Map<any, V[]>;
565
- /**
566
- * Removes all elements from array that `func` returns truthy for and returns an array of the removed elements.
567
- * @param arr The array to remove from.
568
- * @param func The function invoked per iteration or value(s) or value to remove.
569
- * @returns
570
- */
571
- export declare function remove<T>(arr: T[], func: T): T[];
572
- export declare function remove<T>(arr: T[], func: T[]): T[];
573
- export declare function remove<T>(arr: T[], func: Iteratee<T>): T[];
574
- /**
575
- * Returns the index of `x` in a **sorted** array if found, in `O(log n)` using binary search.
576
- * If the element is not found, returns `-n - 1`, where `n` is the index to insert `x` at.
577
- * @param arr The sorted array
578
- * @param x The element to find
579
- * @param lo The starting index
580
- * @param hi The end index to search within
581
- * @param comp The compare function to check for `x`
582
- * @returns {number} The index if the element is found or a negative integer.
583
- */
584
- export declare function binarySearch(arr: any[], x: any, lo?: number, hi?: any, comp?: typeof compare): number;
585
- /**
586
- * Returns an insertion index which comes after any existing entries of `x` in a **sorted** array, using binary search.
587
- * @param arr The sorted array
588
- * @param x The element to find
589
- * @param lo The starting index
590
- * @param hi The end index to search within
591
- * @param comp The compare function to check for `x`
592
- * @returns {number}
593
- */
594
- export declare function bisect(arr: any[], x: any, lo?: number, hi?: any, comp?: typeof compare): number;
595
- /**
596
- * Returns an insertion index which comes before any existing entries of `x` in a **sorted** array, using binary search.
597
- * @param arr The sorted array
598
- * @param x The element to find
599
- * @param lo The starting index
600
- * @param hi The end index to search within
601
- * @param comp The compare function to check for `x`
602
- * @returns {number}
603
- */
604
- export declare function bisectLeft(arr: any[], x: any, lo?: number, hi?: any, comp?: typeof compare): number;
605
- /**
606
- * 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.
607
- * Please note this method is `O(n)` because insertion resizes the array.
608
- * @param arr The array to insert into
609
- * @param x The element to insert
610
- * @param lo The starting index
611
- * @param hi The end index to search within
612
- * @param comp The compare function to check for `x`
613
- * @returns {Array}
614
- */
615
- export declare function insort<T>(arr: T[], x: any, lo?: number, hi?: any, comp?: typeof compare): T[];
616
- /**
617
- * 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.
618
- * Please note this method is `O(n)` because insertion resizes the array.
619
- * @param arr The array to insert into
620
- * @param x The element to insert
621
- * @param lo The starting index
622
- * @param hi The end index to search within
623
- * @param comp The compare function to check for `x`
624
- * @returns {Array}
625
- */
626
- 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';