Skip to content

refactor: add @__NO_SIDE_EFFECTS__ annotations to all pure functions #4907

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jul 28, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
3dc5bd2
refactor: add treeshake annotation for `State` category
serkodev Jul 22, 2025
f4aee15
refactor: add treeshake annotation for `Elements` category
serkodev Jul 22, 2025
d34b929
refactor: add treeshake annotation for `Browser` category
serkodev Jul 23, 2025
70aaab1
refactor: add treeshake annotation for `Sensors` category
serkodev Jul 23, 2025
90135ee
chore: move `__NO_SIDE_EFFECTS__` into JSDocs
serkodev Jul 24, 2025
4a3917b
refactor: add treeshake annotation for `Animation` category
serkodev Jul 24, 2025
e3349f4
fix: `useVModel` JSDocs position
serkodev Jul 24, 2025
f64bff9
refactor: add treeshake annotation for `Component` category
serkodev Jul 24, 2025
331ba11
refactor: add treeshake annotation for `Reactivity` category
serkodev Jul 24, 2025
81d784e
refactor: add treeshake annotation for `Time` category
serkodev Jul 24, 2025
3cf0213
refactor: add treeshake annotation for `Array` category
serkodev Jul 24, 2025
79e5e4a
refactor: add full JSDocs to function overloads
serkodev Jul 24, 2025
83e0bdf
refactor: add treeshake annotation for lazy getter resolver functions
serkodev Jul 24, 2025
878d00a
refactor: add treeshake annotation for `Utilities` category
serkodev Jul 24, 2025
541af36
refactor: add treeshake annotation for `
serkodev Jul 24, 2025
a7d92d3
refactor: add treeshake annotation for `@Integrations` category
serkodev Jul 24, 2025
04f9b80
fix: update `useClamp` JSDocs position
serkodev Jul 24, 2025
bde435c
refactor: add treeshake annotation for `@Math` category
serkodev Jul 24, 2025
09bb0cf
refactor: add treeshake annotation for `@Router`, `@RxJS` category
serkodev Jul 24, 2025
e9e3936
Merge branch 'main' into refactor/side-effects
serkodev Jul 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: add treeshake annotation for @Math category
  • Loading branch information
serkodev committed Jul 24, 2025
commit bde435c552e559d0c79e7a742d947d11248abd9b
1 change: 1 addition & 0 deletions packages/math/createGenericProjection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export type ProjectorFunction<F, T> = (input: F, from: readonly [F, F], to: read

export type UseProjection<F, T> = (input: MaybeRefOrGetter<F>) => ComputedRef<T>

/* @__NO_SIDE_EFFECTS__ */
export function createGenericProjection<F = number, T = number>(
fromDomain: MaybeRefOrGetter<readonly [F, F]>,
toDomain: MaybeRefOrGetter<readonly [T, T]>,
Expand Down
1 change: 1 addition & 0 deletions packages/math/createProjection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ function defaultNumericProjector(input: number, from: readonly [number, number],
return (input - from[0]) / (from[1] - from[0]) * (to[1] - to[0]) + to[0]
}

/* @__NO_SIDE_EFFECTS__ */
export function createProjection(
fromDomain: MaybeRefOrGetter<readonly [number, number]>,
toDomain: MaybeRefOrGetter<readonly [number, number]>,
Expand Down
2 changes: 2 additions & 0 deletions packages/math/logicAnd/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { computed, toValue } from 'vue'
* `AND` conditions for refs.
*
* @see https://vueuse.org/logicAnd
*
* @__NO_SIDE_EFFECTS__
*/
export function logicAnd(...args: MaybeRefOrGetter<any>[]): ComputedRef<boolean> {
return computed(() => args.every(i => toValue(i)))
Expand Down
2 changes: 2 additions & 0 deletions packages/math/logicNot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { computed, toValue } from 'vue'
* `NOT` conditions for refs.
*
* @see https://vueuse.org/logicNot
*
* @__NO_SIDE_EFFECTS__
*/
export function logicNot(v: MaybeRefOrGetter<any>): ComputedRef<boolean> {
return computed(() => !toValue(v))
Expand Down
2 changes: 2 additions & 0 deletions packages/math/logicOr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { computed, toValue } from 'vue'
* `OR` conditions for refs.
*
* @see https://vueuse.org/logicOr
*
* @__NO_SIDE_EFFECTS__
*/
export function logicOr(...args: MaybeRefOrGetter<any>[]): ComputedRef<boolean> {
return computed(() => args.some(i => toValue(i)))
Expand Down
2 changes: 2 additions & 0 deletions packages/math/useAbs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { computed, toValue } from 'vue'
* Reactive `Math.abs`.
*
* @see https://vueuse.org/useAbs
*
* @__NO_SIDE_EFFECTS__
*/
export function useAbs(value: MaybeRefOrGetter<number>): ComputedRef<number> {
return computed(() => Math.abs(toValue(value)))
Expand Down
2 changes: 2 additions & 0 deletions packages/math/useAverage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export function useAverage(...args: MaybeRefOrGetter<number>[]): ComputedRef<num
* Get the average of an array reactively
*
* @see https://vueuse.org/useAverage
*
* @__NO_SIDE_EFFECTS__
*/
export function useAverage(...args: MaybeComputedRefArgs<number>): ComputedRef<number> {
return computed(() => {
Expand Down
2 changes: 2 additions & 0 deletions packages/math/useCeil/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { computed, toValue } from 'vue'
* Reactive `Math.ceil`.
*
* @see https://vueuse.org/useCeil
*
* @__NO_SIDE_EFFECTS__
*/
export function useCeil(value: MaybeRefOrGetter<number>): ComputedRef<number> {
return computed<number>(() => Math.ceil(toValue(value)))
Expand Down
13 changes: 13 additions & 0 deletions packages/math/useClamp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { computed, ref as deepRef, isReadonly, toValue } from 'vue'
* @param value number
* @param min
* @param max
*
* @__NO_SIDE_EFFECTS__
*/
export function useClamp(
value: ReadonlyRefOrGetter<number>,
Expand All @@ -21,6 +23,17 @@ export function useClamp(
min: MaybeRefOrGetter<number>,
max: MaybeRefOrGetter<number>,
): Ref<number>

/**
* Reactively clamp a value between two other values.
*
* @see https://vueuse.org/useClamp
* @param value number
* @param min
* @param max
*
* @__NO_SIDE_EFFECTS__
*/
export function useClamp(value: MaybeRefOrGetter<number>, min: MaybeRefOrGetter<number>, max: MaybeRefOrGetter<number>) {
if (typeof value === 'function' || isReadonly(value))
return computed(() => clamp(toValue(value), toValue(min), toValue(max)))
Expand Down
2 changes: 2 additions & 0 deletions packages/math/useFloor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { computed, toValue } from 'vue'
* Reactive `Math.floor`
*
* @see https://vueuse.org/useFloor
*
* @__NO_SIDE_EFFECTS__
*/
export function useFloor(value: MaybeRefOrGetter<number>): ComputedRef<number> {
return computed<number>(() => Math.floor(toValue(value)))
Expand Down
2 changes: 2 additions & 0 deletions packages/math/useMath/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export type UseMathKeys = keyof { [K in keyof Math as Math[K] extends (...args:
* Reactive `Math` methods.
*
* @see https://vueuse.org/useMath
*
* @__NO_SIDE_EFFECTS__
*/
export function useMath<K extends keyof Math>(
key: K,
Expand Down
2 changes: 2 additions & 0 deletions packages/math/useMax/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export function useMax(...args: MaybeRefOrGetter<number>[]): ComputedRef<number>
* Reactively get maximum of values.
*
* @see https://vueuse.org/useMax
*
* @__NO_SIDE_EFFECTS__
*/
export function useMax(...args: MaybeComputedRefArgs<number>) {
return computed<number>(() => {
Expand Down
2 changes: 2 additions & 0 deletions packages/math/useMin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export function useMin(...args: MaybeRefOrGetter<number>[]): ComputedRef<number>
* Reactive `Math.min`.
*
* @see https://vueuse.org/useMin
*
* @__NO_SIDE_EFFECTS__
*/
export function useMin(...args: MaybeComputedRefArgs<number>) {
return computed<number>(() => {
Expand Down
2 changes: 2 additions & 0 deletions packages/math/usePrecision/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export interface UsePrecisionOptions {
* Reactively set the precision of a number.
*
* @see https://vueuse.org/usePrecision
*
* @__NO_SIDE_EFFECTS__
*/
export function usePrecision(
value: MaybeRefOrGetter<number>,
Expand Down
2 changes: 2 additions & 0 deletions packages/math/useProjection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { createProjection } from '../createProjection'
* Reactive numeric projection from one domain to another.
*
* @see https://vueuse.org/useProjection
*
* @__NO_SIDE_EFFECTS__
*/
export function useProjection(
input: MaybeRefOrGetter<number>,
Expand Down
2 changes: 2 additions & 0 deletions packages/math/useRound/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { computed, toValue } from 'vue'
* Reactive `Math.round`.
*
* @see https://vueuse.org/useRound
*
* @__NO_SIDE_EFFECTS__
*/
export function useRound(value: MaybeRefOrGetter<number>): ComputedRef<number> {
return computed<number>(() => Math.round(toValue(value)))
Expand Down
2 changes: 2 additions & 0 deletions packages/math/useSum/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export function useSum(...args: MaybeRefOrGetter<number>[]): ComputedRef<number>
* Get the sum of a set of numbers.
*
* @see https://vueuse.org/useSum
*
* @__NO_SIDE_EFFECTS__
*/
export function useSum(...args: MaybeComputedRefArgs<number>): ComputedRef<number> {
return computed(() => toValueArgsFlat(args).reduce((sum, v) => sum += v, 0))
Expand Down
2 changes: 2 additions & 0 deletions packages/math/useTrunc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { computed, toValue } from 'vue'
* Reactive `Math.trunc`.
*
* @see https://vueuse.org/useTrunc
*
* @__NO_SIDE_EFFECTS__
*/
export function useTrunc(value: MaybeRefOrGetter<number>): ComputedRef<number> {
return computed<number>(() => Math.trunc(toValue(value)))
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy