@reause/math 0.1.2

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 hairyf
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,585 @@
1
+ //#region useProjection/index.d.ts
2
+ /**
3
+ * Projection function type — `ProjectorFunction<F, T>` maps an input from the
4
+ * source domain to the target domain.
5
+ */
6
+ export type ProjectorFunction<F, T> = (input: F, from: readonly [F, F], to: readonly [T, T]) => T;
7
+ /**
8
+ * React port of VueUse's `useProjection`.
9
+ *
10
+ * Map from @vueuse/math `useProjection`
11
+ * Mapping: `ComputedRef<number>` → plain number recomputed from the current
12
+ * value on every render; pure derived value — no reactive `.value`, the caller
13
+ * drives re-renders.
14
+ *
15
+ * React divergence: `input`, `fromDomain` and `toDomain` are all plain
16
+ * read-only values, not upstream's `MaybeRefOrGetter<...>`. In particular the
17
+ * getter form (`() => number`) is NOT accepted — getters as data sources are
18
+ * rejected repo-wide (issue #462). The caller re-renders with new values (e.g.
19
+ * from `useState`) and the hook recomputes. Like upstream, the projection is
20
+ * delegated to `createProjection` (its default projector is the linear numeric
21
+ * projector), so the projector function is not duplicated here.
22
+ *
23
+ * @param input - The input value to project.
24
+ * @param fromDomain - The source domain (a plain `readonly [number, number]`).
25
+ * @param toDomain - The target domain (a plain `readonly [number, number]`).
26
+ * @param projector - The projector function (defaults to the linear numeric projector).
27
+ * @returns The projected number.
28
+ *
29
+ * @__NO_SIDE_EFFECTS__
30
+ * @example
31
+ * const projected = useProjection(5, [0, 10], [0, 100]) // 50
32
+ */
33
+ export declare function useProjection(input: number, fromDomain: readonly [number, number], toDomain: readonly [number, number], projector?: ProjectorFunction<number, number>): number;
34
+ //#endregion
35
+ //#region createGenericProjection/index.d.ts
36
+ /**
37
+ * A projector built by `createGenericProjection`: takes the input value and
38
+ * returns the projected value of type `T`.
39
+ */
40
+ export type UseProjection<F, T> = (input: F) => T;
41
+ /**
42
+ * React port of VueUse's `createGenericProjection`.
43
+ *
44
+ * Map from @vueuse/math `createGenericProjection`
45
+ * Mapping: `ComputedRef<T>` → a plain projector function returning a plain `T`.
46
+ * React has no reactive graph, so the returned projector recomputes the
47
+ * projection on every call (nothing is memoized) and the caller drives
48
+ * re-renders. Domains and input are plain values (`MaybeRefOrGetter` is not
49
+ * supported) — re-create the projector when a domain changes.
50
+ *
51
+ * @__NO_SIDE_EFFECTS__
52
+ * @example
53
+ * const projector = createGenericProjection(
54
+ * [0, 10],
55
+ * ['low', 'high'],
56
+ * (input, from, to) => (input > (from[0] + from[1]) / 2 ? to[1] : to[0]),
57
+ * )
58
+ * projector(8) // 'high'
59
+ */
60
+ export declare function createGenericProjection<F = number, T = number>(fromDomain: readonly [F, F], toDomain: readonly [T, T], projector: ProjectorFunction<F, T>): UseProjection<F, T>;
61
+ //#endregion
62
+ //#region createProjection/index.d.ts
63
+ /**
64
+ * React port of VueUse's `createProjection`.
65
+ *
66
+ * Map from @vueuse/math `createProjection`
67
+ * Mapping: `ComputedRef<number>` → a plain projector function returning a plain
68
+ * `number`. React has no reactive graph, so the returned projector recomputes
69
+ * the numeric projection on every call and the caller drives re-renders; the
70
+ * domains are plain values (`MaybeRefOrGetter` is not supported) — re-create the
71
+ * projector when a domain changes. Delegates to `createGenericProjection` with
72
+ * the default numeric projector.
73
+ *
74
+ * @__NO_SIDE_EFFECTS__
75
+ * @example
76
+ * const projector = createProjection([0, 10], [0, 100])
77
+ * projector(5) // 50
78
+ */
79
+ export declare function createProjection(fromDomain: readonly [number, number], toDomain: readonly [number, number], projector?: ProjectorFunction<number, number>): UseProjection<number, number>;
80
+ //#endregion
81
+ //#region logicAnd/index.d.ts
82
+ /**
83
+ * `AND` condition for values — `true` only when every argument is truthy.
84
+ *
85
+ * Map from @vueuse/math `logicAnd`
86
+ * (`source/vueuse/packages/math/logicAnd/`). Upstream wraps the evaluation in
87
+ * `computed(() => ...)` and returns a `ComputedRef<boolean>`; the reause
88
+ * version is a pure function that evaluates every plain argument and returns a
89
+ * plain `boolean` on each call — there is no reactivity, so re-renders (or
90
+ * effects) drive re-evaluation (SSR-safe).
91
+ *
92
+ * React divergence: arguments are plain values, not upstream's
93
+ * `MaybeRefOrGetter<any>[]`.
94
+ *
95
+ * @__NO_SIDE_EFFECTS__
96
+ *
97
+ * @example
98
+ * logicAnd(true, 1, 'foo') // true
99
+ * logicAnd(true, false) // false
100
+ *
101
+ * @param args - Values to test.
102
+ * @returns `true` when every argument is truthy, `false` otherwise.
103
+ */
104
+ export declare function logicAnd(...args: any[]): boolean;
105
+ //#endregion
106
+ //#region logicNot/index.d.ts
107
+ /**
108
+ * `NOT` condition for values — the logical complement of the given value.
109
+ *
110
+ * Map from @vueuse/math `logicNot`
111
+ * (`source/vueuse/packages/math/logicNot/`). Upstream wraps the evaluation in
112
+ * `computed(() => ...)` and returns a `ComputedRef<boolean>`; the reause
113
+ * version is a pure function that evaluates the plain argument and returns a
114
+ * plain `boolean` on each call — there is no reactivity, so re-renders (or
115
+ * effects) drive re-evaluation (SSR-safe).
116
+ *
117
+ * React divergence: the argument is a plain value, not upstream's
118
+ * `MaybeRefOrGetter<any>`.
119
+ *
120
+ * @__NO_SIDE_EFFECTS__
121
+ *
122
+ * @example
123
+ * logicNot(true) // false
124
+ * logicNot(0) // true
125
+ * logicNot('foo') // false
126
+ *
127
+ * @param v - A value to negate.
128
+ * @returns `true` when the value is falsy, `false` otherwise.
129
+ */
130
+ export declare function logicNot(v: any): boolean;
131
+ //#endregion
132
+ //#region logicOr/index.d.ts
133
+ /**
134
+ * `OR` conditions for values.
135
+ *
136
+ * Map from @vueuse/math `logicOr`
137
+ * (`source/vueuse/packages/math/logicOr/`). Compute the logical `OR` of any
138
+ * number of values.
139
+ *
140
+ * Adjustment for React: upstream wraps the computation in `computed(() => ...)`
141
+ * and returns a `ComputedRef<boolean>`; the reause version is a pure utility
142
+ * function — all plain arguments are evaluated on every call and the plain
143
+ * boolean result is returned directly, with no effects and no `.value` wrapper
144
+ * (SSR-safe). The caller re-invokes it to react to changing values.
145
+ *
146
+ * React divergence: arguments are plain values, not upstream's
147
+ * `MaybeRefOrGetter<any>[]`.
148
+ *
149
+ * @see https://vueuse.org/math/logicOr/
150
+ *
151
+ * @__NO_SIDE_EFFECTS__
152
+ *
153
+ * @example
154
+ * logicOr(true, false) // true
155
+ * logicOr(false, 0, '') // false
156
+ *
157
+ * @param args - Values to evaluate.
158
+ * @returns `true` if any argument is truthy, `false` otherwise.
159
+ */
160
+ export declare function logicOr(...args: any[]): boolean;
161
+ //#endregion
162
+ //#region useAbs/index.d.ts
163
+ /**
164
+ * React port of VueUse's `useAbs`.
165
+ *
166
+ * Map from @vueuse/math `useAbs`
167
+ * (`source/vueuse/packages/math/useAbs/`). Reactive `Math.abs`.
168
+ *
169
+ * Adjustment for React: upstream wraps the computation in `computed(() => ...)`
170
+ * and returns a `ComputedRef<number>`; the reause version is a pure derived
171
+ * hook — the plain `number` argument is read at render time and `Math.abs` is
172
+ * applied directly, with no effects and no `.value` wrapper (SSR-safe).
173
+ *
174
+ * React divergence: `value` is a plain read-only `number`, not upstream's
175
+ * `MaybeRefOrGetter<number>`. The caller re-renders with a new value (e.g. from
176
+ * `useState`) and the hook recomputes.
177
+ *
178
+ * @see https://vueuse.org/math/useAbs/
179
+ *
180
+ * @__NO_SIDE_EFFECTS__
181
+ *
182
+ * @example
183
+ * const result = useAbs(-23) // 23
184
+ *
185
+ * @param value - The number to compute the absolute value of.
186
+ * @returns The absolute value of the value.
187
+ */
188
+ export declare function useAbs(value: number): number;
189
+ //#endregion
190
+ //#region useAverage/index.d.ts
191
+ /**
192
+ * React port of VueUse's `useAverage`.
193
+ *
194
+ * Map from @vueuse/math `useAverage`
195
+ * (`source/vueuse/packages/math/useAverage/`). Reactively get the average of values.
196
+ *
197
+ * Adjustment for React: upstream wraps the computation in `computed(() => ...)`
198
+ * and returns a `ComputedRef<number>`; the reause version is a pure derived
199
+ * hook — the plain numbers (variadic arguments or a single `readonly number[]`)
200
+ * are read at render time and the average is returned directly as a `number`,
201
+ * with no `.value` wrapper (SSR-safe).
202
+ *
203
+ * React divergence: arguments are plain read-only numbers, not upstream's
204
+ * `MaybeRefOrGetter<number>[]`. The caller re-renders with new values (e.g. from
205
+ * `useState`) and the hook recomputes.
206
+ *
207
+ * @see https://vueuse.org/math/useAverage/
208
+ *
209
+ * @__NO_SIDE_EFFECTS__
210
+ *
211
+ * @example
212
+ * const array = [1, 2, 3, 4]
213
+ * const average = useAverage(array) // 2.5
214
+ *
215
+ * const average2 = useAverage(1, 3, 2) // 2
216
+ *
217
+ * @param array - An array of numbers.
218
+ * @returns The average of the given numbers (`0` when called with no arguments).
219
+ */
220
+ export declare function useAverage(array: readonly number[]): number;
221
+ export declare function useAverage(...args: number[]): number;
222
+ //#endregion
223
+ //#region useCeil/index.d.ts
224
+ /**
225
+ * React port of VueUse's `useCeil`.
226
+ *
227
+ * Map from @vueuse/math `useCeil`
228
+ * (`source/vueuse/packages/math/useCeil/`). Reactive `Math.ceil`.
229
+ *
230
+ * Adjustment for React: upstream wraps the computation in `computed(() => ...)`
231
+ * and returns a `ComputedRef<number>`; the reause version is a pure derived
232
+ * hook — the plain `number` argument is read at render time and `Math.ceil` is
233
+ * applied directly, with no effects and no `.value` wrapper (SSR-safe).
234
+ *
235
+ * React divergence: `value` is a plain read-only `number`, not upstream's
236
+ * `MaybeRefOrGetter<number>`. The caller re-renders with a new value (e.g. from
237
+ * `useState`) and the hook recomputes.
238
+ *
239
+ * @see https://vueuse.org/math/useCeil/
240
+ *
241
+ * @__NO_SIDE_EFFECTS__
242
+ *
243
+ * @example
244
+ * const result = useCeil(0.95) // 1
245
+ *
246
+ * @param value - The number to ceil.
247
+ * @returns The ceil of the value.
248
+ */
249
+ export declare function useCeil(value: number): number;
250
+ //#endregion
251
+ //#region useClamp/index.d.ts
252
+ /**
253
+ * Reactively clamp a value between two other values.
254
+ *
255
+ * Map from @vueuse/math `useClamp`
256
+ * (`source/vueuse/packages/math/useClamp/`). React port of VueUse's writable
257
+ * `useClamp` — returns a `[value, setValue]` tuple whose setter clamps on
258
+ * write. `value`, `min` and `max` are plain read-only numbers resolved on every
259
+ * render: `value` seeds the hook's internal state (and re-syncs when it
260
+ * changes), and bounds are re-resolved on every render and on every set, so
261
+ * shrinking `max` / raising `min` re-clamps the current value automatically.
262
+ *
263
+ * React divergence: all three parameters are plain `number`, not upstream's
264
+ * `MaybeRefOrGetter<number>`. The caller re-renders with new values (e.g. from
265
+ * `useState`) instead of passing a ref/getter. Upstream's writable computed
266
+ * also writes the clamped value back into its internal ref on every read, so an
267
+ * out-of-bounds seed stays clamped even after the bounds loosen; here `value`
268
+ * is a plain prop that re-seeds internal state when it changes and the raw seed
269
+ * is re-clamped on every render, so loosening the bounds re-exposes the raw
270
+ * seed until the next `setValue`.
271
+ *
272
+ * @__NO_SIDE_EFFECTS__
273
+ *
274
+ * @example
275
+ * const [value, setValue] = useClamp(0, 0, 10)
276
+ * setValue(15) // value is 10
277
+ * setValue(-5) // value is 0
278
+ *
279
+ * @param value - The value to clamp.
280
+ * @param min - The lower bound.
281
+ * @param max - The upper bound.
282
+ * @returns A `[value, setValue]` pair; `setValue` clamps into `[min, max]`.
283
+ */
284
+ export declare function useClamp(value: number, min: number, max: number): [number, (value: number) => void];
285
+ //#endregion
286
+ //#region useFloor/index.d.ts
287
+ /**
288
+ * React port of VueUse's `useFloor`.
289
+ *
290
+ * Map from @vueuse/math `useFloor`
291
+ * (`source/vueuse/packages/math/useFloor/`). Reactive `Math.floor`.
292
+ *
293
+ * Adjustment for React: upstream wraps the computation in `computed(() => ...)`
294
+ * and returns a `ComputedRef<number>`; the reause version is a pure derived
295
+ * hook — the plain `number` argument is read at render time and `Math.floor` is
296
+ * applied directly, with no effects and no `.value` wrapper (SSR-safe).
297
+ *
298
+ * React divergence: `value` is a plain read-only `number`, not upstream's
299
+ * `MaybeRefOrGetter<number>`. The caller re-renders with a new value (e.g. from
300
+ * `useState`) and the hook recomputes.
301
+ *
302
+ * @see https://vueuse.org/math/useFloor/
303
+ *
304
+ * @__NO_SIDE_EFFECTS__
305
+ *
306
+ * @example
307
+ * const result = useFloor(45.95) // 45
308
+ *
309
+ * @param value - The number to floor.
310
+ * @returns The floor of the value.
311
+ */
312
+ export declare function useFloor(value: number): number;
313
+ //#endregion
314
+ //#region useMath/index.d.ts
315
+ /** String keys of `Math` that are methods (callables), mirroring upstream's `UseMathKeys`. */
316
+ export type UseMathKeys = keyof { [K in keyof Math as Math[K] extends ((...args: any) => any) ? K : never]: unknown; };
317
+ /**
318
+ * Return type — `Math` methods always return a `number`. The arguments stay
319
+ * plain values (see `PlainMathMethod`), not upstream's reactified ones.
320
+ */
321
+ export type UseMathReturn<K extends keyof Math> = ReturnType<PlainMathMethod<Math[K]>>;
322
+ /**
323
+ * Arguments of a plain function — a local copy of VueUse shared's
324
+ * `ArgumentsType` (reause has no shared equivalent).
325
+ */
326
+ type ArgumentsType<T> = T extends ((...args: infer U) => any) ? U : never;
327
+ /**
328
+ * A `Math` method whose arguments stay plain values — deliberately NOT VueUse's
329
+ * `Reactified<T, Computed>` (which wraps every argument in `MaybeRefOrGetter`
330
+ * and resolves getters via `toValue`). Getters as data sources are rejected
331
+ * repo-wide (rule 1, issue #462); the reause hook reads the plain arguments at
332
+ * render time and returns the computed `number` directly.
333
+ */
334
+ type PlainMathMethod<T> = T extends ((...args: infer A) => infer R) ? (...args: A) => R : never;
335
+ /**
336
+ * React port of VueUse's `useMath`.
337
+ *
338
+ * Map from @vueuse/math `useMath`
339
+ * (`source/vueuse/packages/math/useMath/`). Reactive `Math` methods — pass a
340
+ * `Math` method name as the key and its plain numeric arguments; the result is
341
+ * recomputed on every render and returned directly, with no `.value` wrapper
342
+ * and no effects (SSR-safe).
343
+ *
344
+ * Adjustment for React: upstream wraps the computation in `computed(() => ...)`
345
+ * via `reactify` and returns a `ComputedRef<number>`; the reause version is a
346
+ * pure derived hook — `key` and every argument are read at render time and
347
+ * `Math[key]` is invoked immediately, so the returned number always reflects
348
+ * the latest values.
349
+ *
350
+ * React divergence: arguments are plain numbers, not upstream's
351
+ * `MaybeRefOrGetter`. In particular the getter form (`() => number`) is NOT
352
+ * accepted — getters as data sources are rejected repo-wide (issue #462). The
353
+ * caller re-renders with new values (e.g. from `useState`).
354
+ *
355
+ * @see https://vueuse.org/math/useMath/
356
+ *
357
+ * @__NO_SIDE_EFFECTS__
358
+ *
359
+ * @example
360
+ * const result = useMath('pow', 2, 3) // 8
361
+ *
362
+ * const power = useMath('pow', 2, 3) // 8
363
+ *
364
+ * const root = useMath('sqrt', 4) // 2
365
+ *
366
+ * const rounded = useMath('round', 2.5) // 3
367
+ *
368
+ * @param key - The `Math` method name to call (e.g. `'pow'`, `'sqrt'`).
369
+ * @param args - Plain numeric arguments to pass to the `Math` method.
370
+ * @returns The result of calling `Math[key]` with the arguments.
371
+ */
372
+ export declare function useMath<K extends keyof Math>(key: K, ...args: ArgumentsType<PlainMathMethod<Math[K]>>): UseMathReturn<K>;
373
+ //#endregion
374
+ //#region useMax/index.d.ts
375
+ /**
376
+ * React port of VueUse's `useMax`.
377
+ *
378
+ * Map from @vueuse/math `useMax`
379
+ * (`source/vueuse/packages/math/useMax/`). Reactively get maximum of values.
380
+ *
381
+ * Adjustment for React: upstream wraps the computation in `computed(() => ...)`
382
+ * and returns a `ComputedRef<number>`; the reause version is a pure derived
383
+ * hook — the plain numbers (variadic arguments or a single `readonly number[]`)
384
+ * are read at render time and the maximum is returned directly as a `number`,
385
+ * with no `.value` wrapper (SSR-safe).
386
+ *
387
+ * React divergence: arguments are plain read-only numbers, not upstream's
388
+ * `MaybeRefOrGetter<number>[]`. The caller re-renders with new values (e.g. from
389
+ * `useState`) and the hook recomputes.
390
+ *
391
+ * @see https://vueuse.org/math/useMax/
392
+ *
393
+ * @__NO_SIDE_EFFECTS__
394
+ *
395
+ * @example
396
+ * const array = [1, 2, 3, 4]
397
+ * const max = useMax(array) // 4
398
+ *
399
+ * const max2 = useMax(1, 3, 2) // 3
400
+ *
401
+ * @param array - An array of values.
402
+ * @returns The maximum of the given values (`Number.NEGATIVE_INFINITY` when
403
+ * called with no arguments).
404
+ */
405
+ export declare function useMax(array: readonly number[]): number;
406
+ export declare function useMax(...args: number[]): number;
407
+ //#endregion
408
+ //#region useMin/index.d.ts
409
+ /**
410
+ * React port of VueUse's `useMin`.
411
+ *
412
+ * Map from @vueuse/math `useMin`
413
+ * (`source/vueuse/packages/math/useMin/`). Reactively calculate the minimum of
414
+ * the given numbers — the React analog of reactive `Math.min`.
415
+ *
416
+ * Adjustment for React: upstream wraps the computation in `computed(() => ...)`
417
+ * and returns a `ComputedRef<number>`; the reause version is a pure derived
418
+ * hook — the plain numbers (variadic arguments or a single `readonly number[]`)
419
+ * are read at render time and the minimum is returned directly, with no effects
420
+ * and no `.value` wrapper (SSR-safe).
421
+ *
422
+ * React divergence: arguments are plain read-only numbers, not upstream's
423
+ * `MaybeRefOrGetter<number>[]`. The caller re-renders with new values (e.g. from
424
+ * `useState`) and the hook recomputes.
425
+ *
426
+ * @see https://vueuse.org/math/useMin/
427
+ *
428
+ * @__NO_SIDE_EFFECTS__
429
+ *
430
+ * @example
431
+ * const array = [1, 2, 3, 4]
432
+ * const min = useMin(array) // 1
433
+ *
434
+ * const min2 = useMin(1, 3, 2) // 1
435
+ *
436
+ * @param array - A set of numbers to find the minimum of.
437
+ * @returns The minimum of the given numbers, or `Number.POSITIVE_INFINITY` when
438
+ * no arguments are passed (matching `Math.min()` semantics).
439
+ */
440
+ export declare function useMin(array: readonly number[]): number;
441
+ export declare function useMin(...args: number[]): number;
442
+ //#endregion
443
+ //#region usePrecision/index.d.ts
444
+ export interface UsePrecisionOptions {
445
+ /**
446
+ * Method to use for rounding.
447
+ *
448
+ * @default 'round'
449
+ */
450
+ math?: 'floor' | 'ceil' | 'round';
451
+ }
452
+ /**
453
+ * React port of VueUse's `usePrecision`.
454
+ *
455
+ * Map from @vueuse/math `usePrecision`
456
+ * (`source/vueuse/packages/math/usePrecision/`). Reactively set the precision
457
+ * of a number.
458
+ *
459
+ * Adjustment for React: upstream wraps the computation in `computed(() => ...)`
460
+ * and returns a `ComputedRef<number>`; the reause version is a pure derived
461
+ * hook — the plain `value`, `digits` and `options` are read at render time and
462
+ * the precision-adjusted number is memoized and returned directly, with no
463
+ * effects and no `.value` wrapper (SSR-safe).
464
+ *
465
+ * React divergence: parameters are plain read-only values, not upstream's
466
+ * `MaybeRefOrGetter<...>`. The caller re-renders with new values (e.g. from
467
+ * `useState`).
468
+ *
469
+ * @see https://vueuse.org/math/usePrecision/
470
+ *
471
+ * @__NO_SIDE_EFFECTS__
472
+ *
473
+ * @example
474
+ * const result = usePrecision(3.1415, 2) // 3.14
475
+ *
476
+ * const ceilResult = usePrecision(3.1415, 2, {
477
+ * math: 'ceil',
478
+ * }) // 3.15
479
+ *
480
+ * const floorResult = usePrecision(3.1415, 3, {
481
+ * math: 'floor',
482
+ * }) // 3.141
483
+ *
484
+ * @param value - The value to set the precision of.
485
+ * @param digits - The number of digits to keep.
486
+ * @param options - The rounding method to use (`round` by default).
487
+ * @returns The value with the applied precision.
488
+ */
489
+ export declare function usePrecision(value: number, digits: number, options?: UsePrecisionOptions): number;
490
+ //#endregion
491
+ //#region useRound/index.d.ts
492
+ /**
493
+ * React port of VueUse's `useRound`.
494
+ *
495
+ * Map from @vueuse/math `useRound`
496
+ * (`source/vueuse/packages/math/useRound/`). Reactive `Math.round`.
497
+ *
498
+ * Adjustment for React: upstream wraps the computation in `computed(() => ...)`
499
+ * and returns a `ComputedRef<number>`; the reause version is a pure derived
500
+ * hook — the plain `number` argument is read at render time and `Math.round` is
501
+ * applied directly, with no effects and no `.value` wrapper (SSR-safe).
502
+ *
503
+ * React divergence: `value` is a plain read-only `number`, not upstream's
504
+ * `MaybeRefOrGetter<number>`. The caller re-renders with a new value (e.g. from
505
+ * `useState`) and the hook recomputes.
506
+ *
507
+ * @see https://vueuse.org/math/useRound/
508
+ *
509
+ * @__NO_SIDE_EFFECTS__
510
+ *
511
+ * @example
512
+ * const result = useRound(20.49) // 20
513
+ *
514
+ * @param value - The number to round.
515
+ * @returns The value rounded to the nearest integer.
516
+ */
517
+ export declare function useRound(value: number): number;
518
+ //#endregion
519
+ //#region useSum/index.d.ts
520
+ /**
521
+ * React port of VueUse's `useSum`.
522
+ *
523
+ * Map from @vueuse/math `useSum`
524
+ * (`source/vueuse/packages/math/useSum/`). Reactively get the sum of values.
525
+ *
526
+ * Adjustment for React: upstream wraps the computation in `computed(() => ...)`
527
+ * and returns a `ComputedRef<number>`; the reause version is a pure derived
528
+ * hook — the plain numbers (variadic arguments or a single `readonly number[]`)
529
+ * are read at render time and the sum is returned directly as a `number`, with
530
+ * no `.value` wrapper (SSR-safe).
531
+ *
532
+ * React divergence: arguments are plain read-only numbers, not upstream's
533
+ * `MaybeRefOrGetter<number>[]`. In particular, the getter form (`() => number`)
534
+ * is NOT accepted — getters as data sources are rejected repo-wide (issue #462)
535
+ * — so the upstream getter test is intentionally not ported. The caller
536
+ * re-renders with new values (e.g. from `useState`) and the hook recomputes.
537
+ *
538
+ * @see https://vueuse.org/math/useSum/
539
+ *
540
+ * @__NO_SIDE_EFFECTS__
541
+ *
542
+ * @example
543
+ * const array = [1, 2, 3, 4]
544
+ * const sum = useSum(array) // 10
545
+ *
546
+ * const [a, setA] = useState(1)
547
+ * const [b, setB] = useState(3)
548
+ * const sum2 = useSum(a, b, 2) // 6
549
+ *
550
+ * @param array - An array of numbers.
551
+ * @returns The sum of the given numbers (`0` when called with no arguments).
552
+ */
553
+ export declare function useSum(array: readonly number[]): number;
554
+ export declare function useSum(...args: number[]): number;
555
+ //#endregion
556
+ //#region useTrunc/index.d.ts
557
+ /**
558
+ * React port of VueUse's `useTrunc`.
559
+ *
560
+ * Map from @vueuse/math `useTrunc`
561
+ * (`source/vueuse/packages/math/useTrunc/`). Reactively truncates a number,
562
+ * removing the fractional digits toward zero.
563
+ *
564
+ * Adjustment for React: upstream wraps the computation in `computed(() => ...)`
565
+ * and returns a `ComputedRef<number>`; the reause version is a pure derived
566
+ * hook — the plain `number` argument is read at render time and the truncated
567
+ * number is returned directly, with no effects and no `.value` wrapper
568
+ * (SSR-safe).
569
+ *
570
+ * React divergence: `value` is a plain read-only `number`, not upstream's
571
+ * `MaybeRefOrGetter<number>`. The caller re-renders with a new value (e.g. from
572
+ * `useState`) and the hook recomputes.
573
+ *
574
+ * @see https://vueuse.org/math/useTrunc/
575
+ *
576
+ * @__NO_SIDE_EFFECTS__
577
+ *
578
+ * @example
579
+ * const result = useTrunc(0.95) // 0
580
+ *
581
+ * @param value - The number to truncate.
582
+ * @returns The truncated number.
583
+ */
584
+ export declare function useTrunc(value: number): number;
585
+ //#endregion