@ls-stack/utils 3.18.0 → 3.20.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 (115) hide show
  1. package/README.md +1 -15
  2. package/docs/README.md +72 -0
  3. package/docs/_media/modules.md +52 -0
  4. package/docs/arrayUtils/-internal-.md +17 -0
  5. package/docs/arrayUtils/README.md +423 -0
  6. package/docs/assertions/-internal-.md +63 -0
  7. package/docs/assertions/README.md +565 -0
  8. package/docs/asyncQueue/-internal-.md +815 -0
  9. package/docs/asyncQueue/README.md +75 -0
  10. package/docs/awaitDebounce.md +66 -0
  11. package/docs/cache/-internal-.md +168 -0
  12. package/docs/cache/README.md +360 -0
  13. package/docs/castValues.md +47 -0
  14. package/docs/concurrentCalls/-internal-.md +416 -0
  15. package/docs/concurrentCalls/README.md +77 -0
  16. package/docs/consoleFmt.md +91 -0
  17. package/docs/conversions.md +27 -0
  18. package/docs/createThrottleController/-internal-.md +73 -0
  19. package/docs/createThrottleController/README.md +31 -0
  20. package/docs/debounce.md +188 -0
  21. package/docs/dedent/-internal-.md +17 -0
  22. package/docs/dedent/README.md +204 -0
  23. package/docs/deepEqual.md +94 -0
  24. package/docs/enhancedMap.md +358 -0
  25. package/docs/exhaustiveMatch/-internal-.md +39 -0
  26. package/docs/exhaustiveMatch/README.md +146 -0
  27. package/docs/getAutoIncrementId.md +93 -0
  28. package/docs/getCompositeKey.md +39 -0
  29. package/docs/getValueStableKey.md +57 -0
  30. package/docs/hash.md +31 -0
  31. package/docs/interpolate/-internal-.md +61 -0
  32. package/docs/interpolate/README.md +62 -0
  33. package/docs/levenshtein.md +93 -0
  34. package/docs/main.md +21 -0
  35. package/docs/mathUtils.md +137 -0
  36. package/docs/modules.md +52 -0
  37. package/docs/objUtils.md +237 -0
  38. package/docs/parallelAsyncCalls/-internal-.md +347 -0
  39. package/docs/parallelAsyncCalls/README.md +45 -0
  40. package/docs/promiseUtils/-internal-.md +69 -0
  41. package/docs/promiseUtils/README.md +31 -0
  42. package/docs/retryOnError.md +67 -0
  43. package/docs/runShellCmd/-internal-.md +111 -0
  44. package/docs/runShellCmd/README.md +201 -0
  45. package/docs/safeJson.md +51 -0
  46. package/docs/saferTyping.md +228 -0
  47. package/docs/serializeXML.md +100 -0
  48. package/docs/shallowEqual.md +33 -0
  49. package/docs/sleep.md +27 -0
  50. package/docs/stringUtils/-internal-.md +17 -0
  51. package/docs/stringUtils/README.md +166 -0
  52. package/docs/testUtils.md +315 -0
  53. package/docs/throttle/-internal-.md +47 -0
  54. package/docs/throttle/README.md +178 -0
  55. package/docs/time.md +274 -0
  56. package/docs/timers.md +256 -0
  57. package/docs/tsResult/-internal-.md +327 -0
  58. package/docs/tsResult/README.md +696 -0
  59. package/docs/typeGuards.md +399 -0
  60. package/docs/typingFnUtils/-internal-.md +27 -0
  61. package/docs/typingFnUtils/README.md +293 -0
  62. package/docs/typingTestUtils.md +172 -0
  63. package/docs/typingUtils.md +111 -0
  64. package/docs/yamlStringify.md +45 -0
  65. package/lib/arrayUtils.js +3 -3
  66. package/lib/assertions.js +2 -2
  67. package/lib/awaitDebounce.cjs +106 -0
  68. package/lib/awaitDebounce.d.cts +38 -0
  69. package/lib/awaitDebounce.d.ts +38 -0
  70. package/lib/awaitDebounce.js +28 -0
  71. package/lib/cache.js +2 -2
  72. package/lib/{chunk-NH2LCAQS.js → chunk-6FIBVC2P.js} +1 -1
  73. package/lib/{chunk-GKOTKAIV.js → chunk-7CQPOM5I.js} +1 -1
  74. package/lib/{chunk-WS4WEVHU.js → chunk-C2SVCIWE.js} +1 -1
  75. package/lib/{chunk-SSKW673U.js → chunk-JF2MDHOJ.js} +5 -1
  76. package/lib/chunk-NW5H5EW7.js +100 -0
  77. package/lib/{chunk-DMW5Q4T2.js → chunk-SRVMMYSW.js} +1 -1
  78. package/lib/concurrentCalls.js +3 -3
  79. package/lib/createThrottleController.js +3 -3
  80. package/lib/debounce.js +4 -95
  81. package/lib/dedent.cjs +31 -3
  82. package/lib/dedent.d.cts +61 -1
  83. package/lib/dedent.d.ts +61 -1
  84. package/lib/dedent.js +31 -3
  85. package/lib/enhancedMap.js +3 -3
  86. package/lib/getAutoIncrementId.cjs +44 -0
  87. package/lib/getAutoIncrementId.d.cts +44 -0
  88. package/lib/getAutoIncrementId.d.ts +44 -0
  89. package/lib/getAutoIncrementId.js +18 -0
  90. package/lib/getCompositeKey.js +3 -3
  91. package/lib/getValueStableKey.js +3 -3
  92. package/lib/interpolate.js +2 -2
  93. package/lib/parallelAsyncCalls.js +2 -2
  94. package/lib/runShellCmd.d.cts +50 -0
  95. package/lib/runShellCmd.d.ts +50 -0
  96. package/lib/serializeXML.cjs +7 -2
  97. package/lib/serializeXML.d.cts +1 -1
  98. package/lib/serializeXML.d.ts +1 -1
  99. package/lib/serializeXML.js +7 -5
  100. package/lib/testUtils.js +3 -3
  101. package/lib/throttle.cjs +250 -0
  102. package/lib/throttle.d.cts +89 -0
  103. package/lib/throttle.d.ts +89 -0
  104. package/lib/throttle.js +38 -0
  105. package/lib/tsResult.js +2 -2
  106. package/lib/typeGuards.cjs +7 -2
  107. package/lib/typeGuards.d.cts +2 -1
  108. package/lib/typeGuards.d.ts +2 -1
  109. package/lib/typeGuards.js +5 -3
  110. package/lib/typingFnUtils.cjs +5 -1
  111. package/lib/typingFnUtils.d.cts +1 -1
  112. package/lib/typingFnUtils.d.ts +1 -1
  113. package/lib/typingFnUtils.js +5 -1
  114. package/lib/yamlStringify.js +5 -5
  115. package/package.json +22 -12
@@ -0,0 +1,166 @@
1
+ [**@ls-stack/utils**](../README.md)
2
+
3
+ ***
4
+
5
+ [@ls-stack/utils](../modules.md) / stringUtils
6
+
7
+ # stringUtils
8
+
9
+ ## Modules
10
+
11
+ - [\<internal\>](-internal-.md)
12
+
13
+ ## Variables
14
+
15
+ ### ~~joinStrings()~~
16
+
17
+ ```ts
18
+ const joinStrings: (...args) => string = concatStrings;
19
+ ```
20
+
21
+ Defined in: [packages/utils/src/stringUtils.ts:33](https://github.com/lucasols/utils/blob/main/packages/utils/src/stringUtils.ts#L33)
22
+
23
+ A util to create more legible conditional concatenated strings
24
+
25
+ #### Parameters
26
+
27
+ ##### args
28
+
29
+ ...([`Arg`](-internal-.md#arg) \| [`Arg`](-internal-.md#arg)[])[]
30
+
31
+ #### Returns
32
+
33
+ `string`
34
+
35
+ #### Example
36
+
37
+ ```ts
38
+ joinStrings('a', 'b', 'c') // 'abc'
39
+ joinStrings('a', false, 'c') // 'ac'
40
+ joinStrings('a', addBString ? 'b' : null, 'c') // 'ac' if addBString is false, 'abc' if addBString is true
41
+ ```
42
+
43
+ #### Deprecated
44
+
45
+ Use [concatStrings](#concatstrings) instead
46
+
47
+ ## Functions
48
+
49
+ ### concatStrings()
50
+
51
+ ```ts
52
+ function concatStrings(...args): string;
53
+ ```
54
+
55
+ Defined in: [packages/utils/src/stringUtils.ts:11](https://github.com/lucasols/utils/blob/main/packages/utils/src/stringUtils.ts#L11)
56
+
57
+ A util to create more legible conditional concatenated strings
58
+
59
+ #### Parameters
60
+
61
+ ##### args
62
+
63
+ ...([`Arg`](-internal-.md#arg) \| [`Arg`](-internal-.md#arg)[])[]
64
+
65
+ #### Returns
66
+
67
+ `string`
68
+
69
+ #### Example
70
+
71
+ ```ts
72
+ joinStrings('a', 'b', 'c') // 'abc'
73
+ joinStrings('a', false, 'c') // 'ac'
74
+ joinStrings('a', addBString ? 'b' : null, 'c') // 'ac' if addBString is false, 'abc' if addBString is true
75
+ ```
76
+
77
+ ***
78
+
79
+ ### convertToSnakeCase()
80
+
81
+ ```ts
82
+ function convertToSnakeCase(str): string;
83
+ ```
84
+
85
+ Defined in: [packages/utils/src/stringUtils.ts:46](https://github.com/lucasols/utils/blob/main/packages/utils/src/stringUtils.ts#L46)
86
+
87
+ #### Parameters
88
+
89
+ ##### str
90
+
91
+ `string`
92
+
93
+ #### Returns
94
+
95
+ `string`
96
+
97
+ ***
98
+
99
+ ### formatNum()
100
+
101
+ ```ts
102
+ function formatNum(num): string;
103
+ ```
104
+
105
+ Defined in: [packages/utils/src/stringUtils.ts:35](https://github.com/lucasols/utils/blob/main/packages/utils/src/stringUtils.ts#L35)
106
+
107
+ #### Parameters
108
+
109
+ ##### num
110
+
111
+ `number`
112
+
113
+ #### Returns
114
+
115
+ `string`
116
+
117
+ ***
118
+
119
+ ### isSnakeCase()
120
+
121
+ ```ts
122
+ function isSnakeCase(str): boolean;
123
+ ```
124
+
125
+ Defined in: [packages/utils/src/stringUtils.ts:42](https://github.com/lucasols/utils/blob/main/packages/utils/src/stringUtils.ts#L42)
126
+
127
+ #### Parameters
128
+
129
+ ##### str
130
+
131
+ `string`
132
+
133
+ #### Returns
134
+
135
+ `boolean`
136
+
137
+ ***
138
+
139
+ ### truncateString()
140
+
141
+ ```ts
142
+ function truncateString(
143
+ str,
144
+ length,
145
+ ellipsis): string;
146
+ ```
147
+
148
+ Defined in: [packages/utils/src/stringUtils.ts:53](https://github.com/lucasols/utils/blob/main/packages/utils/src/stringUtils.ts#L53)
149
+
150
+ #### Parameters
151
+
152
+ ##### str
153
+
154
+ `string`
155
+
156
+ ##### length
157
+
158
+ `number`
159
+
160
+ ##### ellipsis
161
+
162
+ `string` = `'…'`
163
+
164
+ #### Returns
165
+
166
+ `string`
@@ -0,0 +1,315 @@
1
+ [**@ls-stack/utils**](README.md)
2
+
3
+ ***
4
+
5
+ [@ls-stack/utils](modules.md) / testUtils
6
+
7
+ # testUtils
8
+
9
+ ## Functions
10
+
11
+ ### createLoggerStore()
12
+
13
+ ```ts
14
+ function createLoggerStore(__namedParameters): object;
15
+ ```
16
+
17
+ Defined in: [packages/utils/src/testUtils.ts:8](https://github.com/lucasols/utils/blob/main/packages/utils/src/testUtils.ts#L8)
18
+
19
+ #### Parameters
20
+
21
+ ##### \_\_namedParameters
22
+
23
+ ###### arrays?
24
+
25
+ \| `"length"`
26
+ \| `"all"`
27
+ \| `"firstAndLast"`
28
+ \| \{
29
+ `firstNItems`: `number`;
30
+ \} = `...`
31
+
32
+ ###### changesOnly?
33
+
34
+ `boolean` = `false`
35
+
36
+ ###### filterKeys?
37
+
38
+ `string`[]
39
+
40
+ ###### fromLastSnapshot?
41
+
42
+ `boolean` = `false`
43
+
44
+ ###### maxLineLengthBeforeSplit?
45
+
46
+ `number` = `80`
47
+
48
+ ###### rejectKeys?
49
+
50
+ `string`[]
51
+
52
+ ###### splitLongLines?
53
+
54
+ `true` = `true`
55
+
56
+ ###### useEmojiForBooleans?
57
+
58
+ `boolean` = `true`
59
+
60
+ #### Returns
61
+
62
+ `object`
63
+
64
+ ##### add()
65
+
66
+ ```ts
67
+ add: (render) => void;
68
+ ```
69
+
70
+ ###### Parameters
71
+
72
+ ###### render
73
+
74
+ `Record`\<`string`, `unknown`\> | readonly `Record`\<`string`, `unknown`\>[]
75
+
76
+ ###### Returns
77
+
78
+ `void`
79
+
80
+ ##### addMark()
81
+
82
+ ```ts
83
+ addMark: (label) => void;
84
+ ```
85
+
86
+ ###### Parameters
87
+
88
+ ###### label
89
+
90
+ `string`
91
+
92
+ ###### Returns
93
+
94
+ `void`
95
+
96
+ ##### getSnapshot()
97
+
98
+ ```ts
99
+ getSnapshot: (__namedParameters) => string;
100
+ ```
101
+
102
+ ###### Parameters
103
+
104
+ ###### \_\_namedParameters
105
+
106
+ ###### arrays?
107
+
108
+ \| `"length"`
109
+ \| `"all"`
110
+ \| `"firstAndLast"`
111
+ \| \{
112
+ `firstNItems`: `number`;
113
+ \} = `defaultArrays`
114
+
115
+ ###### changesOnly?
116
+
117
+ `boolean` = `defaultChangesOnly`
118
+
119
+ ###### filterKeys?
120
+
121
+ `string`[] = `defaultFilterKeys`
122
+
123
+ ###### fromLastSnapshot?
124
+
125
+ `boolean` = `defaultFromLastSnapshot`
126
+
127
+ ###### includeLastSnapshotEndMark?
128
+
129
+ `boolean` = `true`
130
+
131
+ ###### maxLineLengthBeforeSplit?
132
+
133
+ `number` = `defaultMaxLineLengthBeforeSplit`
134
+
135
+ ###### rejectKeys?
136
+
137
+ `string`[] = `defaultRejectKeys`
138
+
139
+ ###### splitLongLines?
140
+
141
+ `boolean` = `defaultSplitLongLines`
142
+
143
+ ###### useEmojiForBooleans?
144
+
145
+ `boolean` = `defaultUseEmojiForBooleans`
146
+
147
+ ###### Returns
148
+
149
+ `string`
150
+
151
+ ##### logsCount()
152
+
153
+ ```ts
154
+ logsCount: () => number;
155
+ ```
156
+
157
+ ###### Returns
158
+
159
+ `number`
160
+
161
+ ##### reset()
162
+
163
+ ```ts
164
+ reset: (keepLastRender) => void;
165
+ ```
166
+
167
+ ###### Parameters
168
+
169
+ ###### keepLastRender
170
+
171
+ `boolean` = `false`
172
+
173
+ ###### Returns
174
+
175
+ `void`
176
+
177
+ ##### waitNextLog()
178
+
179
+ ```ts
180
+ waitNextLog: (timeout) => Promise<void>;
181
+ ```
182
+
183
+ ###### Parameters
184
+
185
+ ###### timeout
186
+
187
+ `number` = `50`
188
+
189
+ ###### Returns
190
+
191
+ `Promise`\<`void`\>
192
+
193
+ ##### changesSnapshot
194
+
195
+ ###### Get Signature
196
+
197
+ ```ts
198
+ get changesSnapshot(): string;
199
+ ```
200
+
201
+ ###### Returns
202
+
203
+ `string`
204
+
205
+ ##### rendersTime
206
+
207
+ ###### Get Signature
208
+
209
+ ```ts
210
+ get rendersTime(): number[];
211
+ ```
212
+
213
+ ###### Returns
214
+
215
+ `number`[]
216
+
217
+ ##### snapshot
218
+
219
+ ###### Get Signature
220
+
221
+ ```ts
222
+ get snapshot(): string;
223
+ ```
224
+
225
+ ###### Returns
226
+
227
+ `string`
228
+
229
+ ##### snapshotFromLast
230
+
231
+ ###### Get Signature
232
+
233
+ ```ts
234
+ get snapshotFromLast(): string;
235
+ ```
236
+
237
+ ###### Returns
238
+
239
+ `string`
240
+
241
+ ***
242
+
243
+ ### getResultFn()
244
+
245
+ ```ts
246
+ function getResultFn<T>(fnGetter, wrapper?): T;
247
+ ```
248
+
249
+ Defined in: [packages/utils/src/testUtils.ts:274](https://github.com/lucasols/utils/blob/main/packages/utils/src/testUtils.ts#L274)
250
+
251
+ #### Type Parameters
252
+
253
+ ##### T
254
+
255
+ `T` *extends* (...`args`) => `any`
256
+
257
+ #### Parameters
258
+
259
+ ##### fnGetter
260
+
261
+ () => `T`
262
+
263
+ ##### wrapper?
264
+
265
+ (...`args`) => `any`
266
+
267
+ #### Returns
268
+
269
+ `T`
270
+
271
+ ***
272
+
273
+ ### waitController()
274
+
275
+ ```ts
276
+ function waitController(): object;
277
+ ```
278
+
279
+ Defined in: [packages/utils/src/testUtils.ts:289](https://github.com/lucasols/utils/blob/main/packages/utils/src/testUtils.ts#L289)
280
+
281
+ #### Returns
282
+
283
+ `object`
284
+
285
+ ##### stopWaiting()
286
+
287
+ ```ts
288
+ stopWaiting: () => void;
289
+ ```
290
+
291
+ ###### Returns
292
+
293
+ `void`
294
+
295
+ ##### stopWaitingAfter()
296
+
297
+ ```ts
298
+ stopWaitingAfter: (ms) => void;
299
+ ```
300
+
301
+ ###### Parameters
302
+
303
+ ###### ms
304
+
305
+ `number`
306
+
307
+ ###### Returns
308
+
309
+ `void`
310
+
311
+ ##### wait
312
+
313
+ ```ts
314
+ wait: Promise<void>;
315
+ ```
@@ -0,0 +1,47 @@
1
+ [**@ls-stack/utils**](../README.md)
2
+
3
+ ***
4
+
5
+ [@ls-stack/utils](../modules.md) / [throttle](README.md) / \<internal\>
6
+
7
+ # \<internal\>
8
+
9
+ ## Interfaces
10
+
11
+ ### ThrottleSettings
12
+
13
+ Defined in: [packages/utils/src/throttle.ts:7](https://github.com/lucasols/utils/blob/main/packages/utils/src/throttle.ts#L7)
14
+
15
+ #### Properties
16
+
17
+ ##### leading?
18
+
19
+ ```ts
20
+ optional leading: boolean;
21
+ ```
22
+
23
+ Defined in: [packages/utils/src/throttle.ts:12](https://github.com/lucasols/utils/blob/main/packages/utils/src/throttle.ts#L12)
24
+
25
+ Specify invoking on the leading edge of the timeout.
26
+
27
+ ###### Default
28
+
29
+ ```ts
30
+ true
31
+ ```
32
+
33
+ ##### trailing?
34
+
35
+ ```ts
36
+ optional trailing: boolean;
37
+ ```
38
+
39
+ Defined in: [packages/utils/src/throttle.ts:17](https://github.com/lucasols/utils/blob/main/packages/utils/src/throttle.ts#L17)
40
+
41
+ Specify invoking on the trailing edge of the timeout.
42
+
43
+ ###### Default
44
+
45
+ ```ts
46
+ true
47
+ ```
@@ -0,0 +1,178 @@
1
+ [**@ls-stack/utils**](../README.md)
2
+
3
+ ***
4
+
5
+ [@ls-stack/utils](../modules.md) / throttle
6
+
7
+ # throttle
8
+
9
+ ## Modules
10
+
11
+ - [\<internal\>](-internal-.md)
12
+
13
+ ## Functions
14
+
15
+ ### createThrottledFunctionFactory()
16
+
17
+ ```ts
18
+ function createThrottledFunctionFactory<T, R>(
19
+ wait,
20
+ callback,
21
+ options?): object;
22
+ ```
23
+
24
+ Defined in: [packages/utils/src/throttle.ts:104](https://github.com/lucasols/utils/blob/main/packages/utils/src/throttle.ts#L104)
25
+
26
+ Creates a factory for throttled functions that caches throttled instances based on function arguments.
27
+ Each unique set of arguments gets its own throttled function instance, allowing for fine-grained
28
+ throttling control per argument combination.
29
+
30
+ This is useful when you want to throttle calls to the same function but with different parameters
31
+ independently. For example, throttling API calls per user ID or throttling UI updates per component.
32
+
33
+ #### Type Parameters
34
+
35
+ ##### T
36
+
37
+ `T` *extends* `undefined` \| `null` \| `string` \| `number` \| `boolean`
38
+
39
+ The type of arguments the callback function accepts
40
+
41
+ ##### R
42
+
43
+ `R`
44
+
45
+ The return type of the callback function
46
+
47
+ #### Parameters
48
+
49
+ ##### wait
50
+
51
+ `number`
52
+
53
+ The number of milliseconds to throttle invocations to
54
+
55
+ ##### callback
56
+
57
+ (...`args`) => `R`
58
+
59
+ The function to throttle
60
+
61
+ ##### options?
62
+
63
+ [`ThrottleSettings`](-internal-.md#throttlesettings)
64
+
65
+ The throttle options (leading/trailing behavior)
66
+
67
+ #### Returns
68
+
69
+ `object`
70
+
71
+ An object with a `call` method that accepts the callback arguments
72
+
73
+ ##### call()
74
+
75
+ ```ts
76
+ call: (...args) => undefined | R;
77
+ ```
78
+
79
+ ###### Parameters
80
+
81
+ ###### args
82
+
83
+ ...`T`[]
84
+
85
+ ###### Returns
86
+
87
+ `undefined` \| `R`
88
+
89
+ #### Examples
90
+
91
+ ```ts
92
+ const apiThrottle = createThrottledFunctionFactory(
93
+ 1000,
94
+ (userId: string, action: string) => callAPI(userId, action)
95
+ );
96
+
97
+ // Each user gets their own throttled instance
98
+ apiThrottle.call('user1', 'update'); // Executes immediately
99
+ apiThrottle.call('user2', 'update'); // Executes immediately (different user)
100
+ apiThrottle.call('user1', 'update'); // Throttled (same user)
101
+ ```
102
+
103
+ ```ts
104
+ // Throttle UI updates per component
105
+ const updateThrottle = createThrottledFunctionFactory(
106
+ 100,
107
+ (componentId: string, data: any) => updateComponent(componentId, data)
108
+ );
109
+ ```
110
+
111
+ ***
112
+
113
+ ### throttle()
114
+
115
+ ```ts
116
+ function throttle<T>(
117
+ func,
118
+ wait,
119
+ options?): DebouncedFunc<T>;
120
+ ```
121
+
122
+ Defined in: [packages/utils/src/throttle.ts:51](https://github.com/lucasols/utils/blob/main/packages/utils/src/throttle.ts#L51)
123
+
124
+ Creates a throttled function that only invokes the provided function at most once per every `wait` milliseconds.
125
+ The throttled function comes with a `cancel` method to cancel delayed invocations and a `flush` method to immediately invoke them.
126
+
127
+ Throttling is useful for rate-limiting events that fire frequently, like scroll or resize handlers.
128
+ Unlike debouncing, throttling guarantees the function is called at regular intervals.
129
+
130
+ #### Type Parameters
131
+
132
+ ##### T
133
+
134
+ `T` *extends* [`__LEGIT_ANY_FUNCTION__`](../saferTyping.md#__legit_any_function__)
135
+
136
+ The type of the function to throttle
137
+
138
+ #### Parameters
139
+
140
+ ##### func
141
+
142
+ `T`
143
+
144
+ The function to throttle
145
+
146
+ ##### wait
147
+
148
+ `number`
149
+
150
+ The number of milliseconds to throttle invocations to
151
+
152
+ ##### options?
153
+
154
+ [`ThrottleSettings`](-internal-.md#throttlesettings)
155
+
156
+ The options object
157
+
158
+ #### Returns
159
+
160
+ [`DebouncedFunc`](../debounce.md#debouncedfunc)\<`T`\>
161
+
162
+ Returns the new throttled function
163
+
164
+ #### Examples
165
+
166
+ ```ts
167
+ const throttledSave = throttle(saveData, 1000);
168
+
169
+ // Will only call saveData at most once per second
170
+ throttledSave();
171
+ throttledSave();
172
+ throttledSave();
173
+ ```
174
+
175
+ ```ts
176
+ // Only invoke on trailing edge
177
+ const throttledHandler = throttle(handleScroll, 100, { leading: false });
178
+ ```