(key: K, callback: (value: T[K] | undefined) => void): () => void;
destroy(): void;
}
diff --git a/packages/js-toolkit/utils/string/changeCase.ts b/packages/js-toolkit/utils/string/changeCase.ts
index d32453324..6431e5ac3 100644
--- a/packages/js-toolkit/utils/string/changeCase.ts
+++ b/packages/js-toolkit/utils/string/changeCase.ts
@@ -40,7 +40,7 @@ function delimitedCase(string: string, delimiter: string): string {
/**
* Convert a string to lowercase.
* @link https://js-toolkit.studiometa.dev/utils/string/lowerCase.html
-*/
+ */
export function lowerCase(string: string): string {
return string.toLowerCase();
}
@@ -48,7 +48,7 @@ export function lowerCase(string: string): string {
/**
* Convert a string to UPPERCASE.
* @link https://js-toolkit.studiometa.dev/utils/string/upperCase.html
-*/
+ */
export function upperCase(string: string): string {
return string.toUpperCase();
}
@@ -56,7 +56,7 @@ export function upperCase(string: string): string {
/**
* Convert a string to camelCase.
* @link https://js-toolkit.studiometa.dev/utils/string/camelCase.html
-*/
+ */
export const camelCase = memo(function camelCase(string: string): string {
const result = pascalCase(string);
return lowerCase(result[0]) + result.slice(1);
@@ -65,7 +65,7 @@ export const camelCase = memo(function camelCase(string: string): string {
/**
* Convert a string to PascalCase.
* @link https://js-toolkit.studiometa.dev/utils/string/pascalCase.html
-*/
+ */
export const pascalCase = memo(function pascalCase(string: string): string {
return split(string)
.map((word) => upperCase(word[0]) + lowerCase(word.slice(1)))
@@ -75,7 +75,7 @@ export const pascalCase = memo(function pascalCase(string: string): string {
/**
* Convert a string to snake_case.
* @link https://js-toolkit.studiometa.dev/utils/string/snakeCase.html
-*/
+ */
export const snakeCase = memo(function snakeCase(string: string): string {
return delimitedCase(string, '_');
});
@@ -83,7 +83,7 @@ export const snakeCase = memo(function snakeCase(string: string): string {
/**
* Convert a string to dash-case.
* @link https://js-toolkit.studiometa.dev/utils/string/dashCase.html
-*/
+ */
export const dashCase = memo(function dashCase(string: string): string {
return delimitedCase(string, '-');
});
diff --git a/packages/js-toolkit/utils/string/withLeadingCharacters.ts b/packages/js-toolkit/utils/string/withLeadingCharacters.ts
index 4cefb3142..e3407b62d 100644
--- a/packages/js-toolkit/utils/string/withLeadingCharacters.ts
+++ b/packages/js-toolkit/utils/string/withLeadingCharacters.ts
@@ -7,7 +7,7 @@ import { withoutLeadingCharacters } from './withoutLeadingCharacters.js';
* @param {string} characters The characters to add to the start.
* @return {string}
* @link https://js-toolkit.studiometa.dev/utils/string/withLeadingCharacters.html
-*/
+ */
export function withLeadingCharacters(string: string, characters: string): string {
return `${characters}${withoutLeadingCharacters(string, characters)}`;
}
diff --git a/packages/js-toolkit/utils/string/withLeadingSlash.ts b/packages/js-toolkit/utils/string/withLeadingSlash.ts
index c0fa11c31..4bbdc0695 100644
--- a/packages/js-toolkit/utils/string/withLeadingSlash.ts
+++ b/packages/js-toolkit/utils/string/withLeadingSlash.ts
@@ -6,7 +6,7 @@ import { withLeadingCharacters } from './withLeadingCharacters.js';
* @param {string} string The string to modify.
* @return {string} The string with a leading slash.
* @link https://js-toolkit.studiometa.dev/utils/string/withLeadingSlash.html
-*/
+ */
export function withLeadingSlash(string: string): string {
return withLeadingCharacters(string, '/');
}
diff --git a/packages/js-toolkit/utils/string/withTrailingCharacters.ts b/packages/js-toolkit/utils/string/withTrailingCharacters.ts
index 28860fbd1..39e244fae 100644
--- a/packages/js-toolkit/utils/string/withTrailingCharacters.ts
+++ b/packages/js-toolkit/utils/string/withTrailingCharacters.ts
@@ -7,7 +7,7 @@ import { withoutTrailingCharacters } from './withoutTrailingCharacters.js';
* @param {string} characters The characters to add to the end.
* @return {string}
* @link https://js-toolkit.studiometa.dev/utils/string/withTrailingCharacters.html
-*/
+ */
export function withTrailingCharacters(string: string, characters: string): string {
return `${withoutTrailingCharacters(string, characters)}${characters}`;
}
diff --git a/packages/js-toolkit/utils/string/withTrailingSlash.ts b/packages/js-toolkit/utils/string/withTrailingSlash.ts
index 908fd58a2..4fc286990 100644
--- a/packages/js-toolkit/utils/string/withTrailingSlash.ts
+++ b/packages/js-toolkit/utils/string/withTrailingSlash.ts
@@ -6,7 +6,7 @@ import { withTrailingCharacters } from './withTrailingCharacters.js';
* @param {string} string The string to modify.
* @return {string} The string with a trailing slash.
* @link https://js-toolkit.studiometa.dev/utils/string/withTrailingSlash.html
-*/
+ */
export function withTrailingSlash(string: string): string {
return withTrailingCharacters(string, '/');
}
diff --git a/packages/js-toolkit/utils/string/withoutLeadingCharacters.ts b/packages/js-toolkit/utils/string/withoutLeadingCharacters.ts
index 3d28f3580..39e3c15bc 100644
--- a/packages/js-toolkit/utils/string/withoutLeadingCharacters.ts
+++ b/packages/js-toolkit/utils/string/withoutLeadingCharacters.ts
@@ -5,7 +5,7 @@
* @param {string} characters The characters to remove from the start.
* @return {string}
* @link https://js-toolkit.studiometa.dev/utils/string/withoutLeadingCharacters.html
-*/
+ */
export function withoutLeadingCharacters(string: string, characters: string): string {
return string.replace(new RegExp(`^${characters}`), '');
}
diff --git a/packages/js-toolkit/utils/string/withoutLeadingCharactersRecursive.ts b/packages/js-toolkit/utils/string/withoutLeadingCharactersRecursive.ts
index 58375e598..5c20c4034 100644
--- a/packages/js-toolkit/utils/string/withoutLeadingCharactersRecursive.ts
+++ b/packages/js-toolkit/utils/string/withoutLeadingCharactersRecursive.ts
@@ -7,7 +7,7 @@ import { withoutLeadingCharacters } from './withoutLeadingCharacters.js';
* @param {string} characters The characters to add to the start.
* @return {string}
* @link https://js-toolkit.studiometa.dev/utils/string/withoutLeadingCharactersRecursive.html
-*/
+ */
export function withoutLeadingCharactersRecursive(string: string, characters: string): string {
let str = withoutLeadingCharacters(string, characters);
const regex = new RegExp(`^${characters}`);
diff --git a/packages/js-toolkit/utils/string/withoutLeadingSlash.ts b/packages/js-toolkit/utils/string/withoutLeadingSlash.ts
index 37b386a27..3fa869356 100644
--- a/packages/js-toolkit/utils/string/withoutLeadingSlash.ts
+++ b/packages/js-toolkit/utils/string/withoutLeadingSlash.ts
@@ -6,7 +6,7 @@ import { withoutLeadingCharacters } from './withoutLeadingCharacters.js';
* @param {string} string The string to modify.
* @return {string} The string without leading slash.
* @link https://js-toolkit.studiometa.dev/utils/string/withoutLeadingSlash.html
-*/
+ */
export function withoutLeadingSlash(string: string): string {
return withoutLeadingCharacters(string, '/');
}
diff --git a/packages/js-toolkit/utils/string/withoutTrailingCharacters.ts b/packages/js-toolkit/utils/string/withoutTrailingCharacters.ts
index 101ae90dd..bb423fddf 100644
--- a/packages/js-toolkit/utils/string/withoutTrailingCharacters.ts
+++ b/packages/js-toolkit/utils/string/withoutTrailingCharacters.ts
@@ -5,7 +5,7 @@
* @param {string} characters The characters to remove from the end.
* @return {string}
* @link https://js-toolkit.studiometa.dev/utils/string/withoutTrailingCharacters.html
-*/
+ */
export function withoutTrailingCharacters(string: string, characters: string): string {
return string.replace(new RegExp(`${characters}$`), '');
}
diff --git a/packages/js-toolkit/utils/string/withoutTrailingCharactersRecursive.ts b/packages/js-toolkit/utils/string/withoutTrailingCharactersRecursive.ts
index c9016b37f..05a42a2df 100644
--- a/packages/js-toolkit/utils/string/withoutTrailingCharactersRecursive.ts
+++ b/packages/js-toolkit/utils/string/withoutTrailingCharactersRecursive.ts
@@ -7,7 +7,7 @@ import { withoutTrailingCharacters } from './withoutTrailingCharacters.js';
* @param {string} characters The characters to add to the start.
* @return {string}
* @link https://js-toolkit.studiometa.dev/utils/string/withoutTrailingCharactersRecursive.html
-*/
+ */
export function withoutTrailingCharactersRecursive(string: string, characters: string): string {
let str = withoutTrailingCharacters(string, characters);
const regex = new RegExp(`${characters}$`);
diff --git a/packages/js-toolkit/utils/string/withoutTrailingSlash.ts b/packages/js-toolkit/utils/string/withoutTrailingSlash.ts
index 1c90d0ad1..fcc86710a 100644
--- a/packages/js-toolkit/utils/string/withoutTrailingSlash.ts
+++ b/packages/js-toolkit/utils/string/withoutTrailingSlash.ts
@@ -6,7 +6,7 @@ import { withoutTrailingCharacters } from './withoutTrailingCharacters.js';
* @param {string} string The string to modify.
* @return {string} The string without trailing slash.
* @link https://js-toolkit.studiometa.dev/utils/string/withoutTrailingSlash.html
-*/
+ */
export function withoutTrailingSlash(string: string): string {
return withoutTrailingCharacters(string, '/');
}
diff --git a/packages/js-toolkit/utils/throttle.ts b/packages/js-toolkit/utils/throttle.ts
index 98dd4afd6..681866a59 100644
--- a/packages/js-toolkit/utils/throttle.ts
+++ b/packages/js-toolkit/utils/throttle.ts
@@ -5,7 +5,7 @@
* @param {number} [delay] The delay in ms
* @return {Function} The throttled function.
* @link https://js-toolkit.studiometa.dev/utils/throttle.html
-*/
+ */
export function throttle(
fn: (...args: unknown[]) => void,
delay = 16,
diff --git a/packages/js-toolkit/utils/trapFocus.ts b/packages/js-toolkit/utils/trapFocus.ts
index cb673d818..b26073938 100644
--- a/packages/js-toolkit/utils/trapFocus.ts
+++ b/packages/js-toolkit/utils/trapFocus.ts
@@ -30,7 +30,7 @@ export function saveActiveElement() {
* @param {HTMLElement} element The element in which to trap the tabulations.
* @param {KeyboardEvent} event The keydown or keyup event.
* @link https://js-toolkit.studiometa.dev/utils/trapFocus.html
-*/
+ */
export function trapFocus(element: HTMLElement, event: KeyboardEvent) {
if (event.keyCode !== keyCodes.TAB) {
return;
@@ -78,7 +78,7 @@ export function trapFocus(element: HTMLElement, event: KeyboardEvent) {
/**
* Untrap the tab navigation.
* @link https://js-toolkit.studiometa.dev/utils/trapFocus.html
-*/
+ */
export function untrapFocus() {
if (focusedBefore && isFunction(focusedBefore.focus)) {
focusedBefore.focus();
diff --git a/packages/tests/__benchmarks__/animate.bench.ts b/packages/tests/__benchmarks__/animate.bench.ts
index fd600f415..1e638200e 100644
--- a/packages/tests/__benchmarks__/animate.bench.ts
+++ b/packages/tests/__benchmarks__/animate.bench.ts
@@ -24,7 +24,10 @@ describe('animate', () => {
});
bench('create with transform keyframes (x, y)', () => {
- animate(el, [{ x: 0, y: 0 }, { x: 100, y: 100 }]);
+ animate(el, [
+ { x: 0, y: 0 },
+ { x: 100, y: 100 },
+ ]);
});
bench('create with multiple transforms', () => {
@@ -58,7 +61,10 @@ describe('animate', () => {
bench('create with all options', () => {
animate(
el,
- [{ x: 0, opacity: 1 }, { x: 100, opacity: 0 }],
+ [
+ { x: 0, opacity: 1 },
+ { x: 100, opacity: 0 },
+ ],
{
duration: 0.5,
delay: 0.1,
@@ -73,7 +79,10 @@ describe('animate', () => {
describe('progress updates (single element)', () => {
const animOpacity = animate(el, [{ opacity: 0 }, { opacity: 1 }]);
- const animTransform = animate(el, [{ x: 0, y: 0 }, { x: 100, y: 100 }]);
+ const animTransform = animate(el, [
+ { x: 0, y: 0 },
+ { x: 100, y: 100 },
+ ]);
const animMultiTransform = animate(el, [
{ x: 0, y: 0, scale: 1, rotate: 0, skewX: 0 },
{ x: 100, y: 100, scale: 2, rotate: 360, skewX: 15 },
@@ -111,7 +120,10 @@ describe('animate', () => {
});
describe('progress updates (multiple elements)', () => {
- const keyframes: Keyframe[] = [{ x: 0, opacity: 0 }, { x: 100, opacity: 1 }];
+ const keyframes: Keyframe[] = [
+ { x: 0, opacity: 0 },
+ { x: 100, opacity: 1 },
+ ];
const anim5 = animate(els5, keyframes);
const anim10 = animate(els10, keyframes);
const anim50 = animate(els50, keyframes);
@@ -130,7 +142,10 @@ describe('animate', () => {
});
describe('staggered animations', () => {
- const keyframes: Keyframe[] = [{ x: 0, opacity: 0 }, { x: 100, opacity: 1 }];
+ const keyframes: Keyframe[] = [
+ { x: 0, opacity: 0 },
+ { x: 100, opacity: 1 },
+ ];
const animStaggerNum = animate(els10, keyframes, { stagger: 0.1 });
const animStaggerFn = animate(els10, keyframes, { stagger: (_el, i) => i * 0.1 });
diff --git a/packages/tests/helpers/logTree.spec.ts b/packages/tests/helpers/logTree.spec.ts
index 050a33d12..07826662b 100644
--- a/packages/tests/helpers/logTree.spec.ts
+++ b/packages/tests/helpers/logTree.spec.ts
@@ -66,9 +66,7 @@ describe('logTree', () => {
});
it('should show mounted status indicator', async () => {
- const div = h('div', {}, [
- h('div', { dataComponent: 'Child' }),
- ]);
+ const div = h('div', {}, [h('div', { dataComponent: 'Child' })]);
const app = new App(div);
await app.$mount();
@@ -112,9 +110,7 @@ describe('logTree', () => {
it('should nest components correctly based on DOM structure', async () => {
const div = h('div', {}, [
- h('div', { dataComponent: 'Parent' }, [
- h('div', { dataComponent: 'Child' }),
- ]),
+ h('div', { dataComponent: 'Parent' }, [h('div', { dataComponent: 'Child' })]),
]);
const app = new App(div);
@@ -128,14 +124,14 @@ describe('logTree', () => {
logTree(app);
// Parent should be in a groupCollapsed (has children)
- const parentCall = groupCollapsedSpy.mock.calls.find((c) =>
- typeof c[0] === 'string' && c[0].includes('Parent'),
+ const parentCall = groupCollapsedSpy.mock.calls.find(
+ (c) => typeof c[0] === 'string' && c[0].includes('Parent'),
);
expect(parentCall).toBeDefined();
// Child should be in a log (leaf node)
- const childCall = logSpy.mock.calls.find((c) =>
- typeof c[0] === 'string' && c[0].includes('Child'),
+ const childCall = logSpy.mock.calls.find(
+ (c) => typeof c[0] === 'string' && c[0].includes('Child'),
);
expect(childCall).toBeDefined();
@@ -167,9 +163,7 @@ describe('logTree', () => {
}
const div = h('div', {}, [
- h('div', { dataComponent: 'DeepParent' }, [
- h('div', { dataComponent: 'GrandChild' }),
- ]),
+ h('div', { dataComponent: 'DeepParent' }, [h('div', { dataComponent: 'GrandChild' })]),
]);
const app = new DeepApp(div);
@@ -183,14 +177,16 @@ describe('logTree', () => {
logTree(app);
// DeepParent should be a group (has GrandChild)
- expect(groupCollapsedSpy.mock.calls.some((c) =>
- typeof c[0] === 'string' && c[0].includes('DeepParent'),
- )).toBe(true);
+ expect(
+ groupCollapsedSpy.mock.calls.some(
+ (c) => typeof c[0] === 'string' && c[0].includes('DeepParent'),
+ ),
+ ).toBe(true);
// GrandChild should be a leaf log
- expect(logSpy.mock.calls.some((c) =>
- typeof c[0] === 'string' && c[0].includes('GrandChild'),
- )).toBe(true);
+ expect(
+ logSpy.mock.calls.some((c) => typeof c[0] === 'string' && c[0].includes('GrandChild')),
+ ).toBe(true);
groupSpy.mockRestore();
groupCollapsedSpy.mockRestore();
@@ -217,8 +213,8 @@ describe('logTree', () => {
logTree(app);
// All 3 children should be logged as leaves
- const childLogs = logSpy.mock.calls.filter((c) =>
- typeof c[0] === 'string' && c[0].includes('Child'),
+ const childLogs = logSpy.mock.calls.filter(
+ (c) => typeof c[0] === 'string' && c[0].includes('Child'),
);
expect(childLogs).toHaveLength(3);
diff --git a/packages/tests/helpers/queryComponent.spec.ts b/packages/tests/helpers/queryComponent.spec.ts
index 3450f90ee..34d34a70d 100644
--- a/packages/tests/helpers/queryComponent.spec.ts
+++ b/packages/tests/helpers/queryComponent.spec.ts
@@ -81,7 +81,7 @@ describe('The `queryComponent` function', () => {
it('should return a single component matching the given query from the given root', async () => {
const name = randomName();
const div = h('div');
- const middle = h('div', [div])
+ const middle = h('div', [div]);
const root = h('div', [middle]);
const instance = new (withName(Base, name))(div);
await mount(instance);
diff --git a/packages/tests/services/DragService.spec.ts b/packages/tests/services/DragService.spec.ts
index f4dffba95..35ac51454 100644
--- a/packages/tests/services/DragService.spec.ts
+++ b/packages/tests/services/DragService.spec.ts
@@ -167,7 +167,7 @@ describe('The drag service', () => {
dispatch(div, 'pointerdown', { x: 0, y: 0, button: 0 });
dispatch(document, 'touchmove', { clientX: 10, clientY: 10, touches: [{}] });
expect(service.props().mode).toBe('drag');
- dispatch(document, 'touchmove', { clientX: 10, clientY: 10, buttons: [{},{}] });
+ dispatch(document, 'touchmove', { clientX: 10, clientY: 10, buttons: [{}, {}] });
expect(service.props().mode).toBe('drop');
});
});
diff --git a/packages/tests/services/RafService.spec.ts b/packages/tests/services/RafService.spec.ts
index 35d27bf27..f5df3dfe1 100644
--- a/packages/tests/services/RafService.spec.ts
+++ b/packages/tests/services/RafService.spec.ts
@@ -48,7 +48,7 @@ describe('useRaf', () => {
it('should update delta representing time between frames', async () => {
let firstTime, firstDelta, secondTime, secondDelta;
-
+
const trackValues = vi.fn((p) => {
if (!firstTime) {
firstTime = p.time;
@@ -58,16 +58,16 @@ describe('useRaf', () => {
secondDelta = p.delta;
}
});
-
+
add('trackValues', trackValues);
-
+
await advanceTimersByTimeAsync(16);
await advanceTimersByTimeAsync(16);
-
+
expect(firstDelta).toBeGreaterThanOrEqual(0);
expect(secondDelta).toBeGreaterThan(0);
expect(secondDelta).toBe(secondTime - firstTime);
-
+
remove('trackValues');
});
diff --git a/packages/tests/utils/dom/createElement.spec.ts b/packages/tests/utils/dom/createElement.spec.ts
index 9714e5e03..7da4f8df5 100644
--- a/packages/tests/utils/dom/createElement.spec.ts
+++ b/packages/tests/utils/dom/createElement.spec.ts
@@ -30,7 +30,8 @@ describe('The createElement function', () => {
});
it('should accept data as an object', () => {
- expect(createElement('div', { data: { optionFoo: 'foo', option_bar: 'bar' } }, [])).toMatchInlineSnapshot(`
+ expect(createElement('div', { data: { optionFoo: 'foo', option_bar: 'bar' } }, []))
+ .toMatchInlineSnapshot(`
{
`);
-
- expect(createElement('a', { href: '#' }, ['hello world', createElement('span')])).toMatchInlineSnapshot(`
+ expect(createElement('a', { href: '#' }, ['hello world', createElement('span')]))
+ .toMatchInlineSnapshot(`
diff --git a/packages/tests/utils/math/spring.spec.ts b/packages/tests/utils/math/spring.spec.ts
index 745d8ffa5..00303ac49 100644
--- a/packages/tests/utils/math/spring.spec.ts
+++ b/packages/tests/utils/math/spring.spec.ts
@@ -46,7 +46,7 @@ describe('spring method', () => {
let currentValue = 0;
let currentVelocity = 0;
const targetValue = 10;
-
+
// First step
const step1 = spring(targetValue, currentValue, currentVelocity, 0.2, 0.7);
expect(step1[0]).toBeCloseTo(2, 5);
diff --git a/packages/tests/utils/random.spec.ts b/packages/tests/utils/random.spec.ts
index 3f914cba8..543a50116 100644
--- a/packages/tests/utils/random.spec.ts
+++ b/packages/tests/utils/random.spec.ts
@@ -2,7 +2,7 @@ import { describe, it, expect } from 'vitest';
import { randomInt, randomItem } from '@studiometa/js-toolkit/utils';
describe('The random function', () => {
- it ('should return a random number between bounds values', ()=> {
+ it('should return a random number between bounds values', () => {
for (const [a, b] of Array.from({ length: 100 }).map(() => [0.5, 3.4])) {
const result1 = randomInt(a);
expect(result1).toBeGreaterThanOrEqual(0);
@@ -12,7 +12,7 @@ describe('The random function', () => {
expect(result2).toBeGreaterThanOrEqual(a);
expect(result2).toBeLessThanOrEqual(b);
}
- })
+ });
});
describe('The randomInt function,', () => {
diff --git a/packages/tests/utils/storage.spec.ts b/packages/tests/utils/storage.spec.ts
index 49079c070..e64f7885a 100644
--- a/packages/tests/utils/storage.spec.ts
+++ b/packages/tests/utils/storage.spec.ts
@@ -833,9 +833,8 @@ describe('Storage utilities', () => {
it('should no-op URL providers outside a browser context', async () => {
vi.stubGlobal('window', undefined);
- const { createUrlSearchParamsProvider, createUrlSearchParamsInHashProvider } = await import(
- '#private/utils/storage/providers.ts'
- );
+ const { createUrlSearchParamsProvider, createUrlSearchParamsInHashProvider } =
+ await import('#private/utils/storage/providers.ts');
const searchProvider = createUrlSearchParamsProvider({ push: true });
const hashProvider = createUrlSearchParamsInHashProvider({ push: true });
diff --git a/packages/tests/utils/tween.spec.ts b/packages/tests/utils/tween.spec.ts
index bacad75c4..8a77e9540 100644
--- a/packages/tests/utils/tween.spec.ts
+++ b/packages/tests/utils/tween.spec.ts
@@ -9,7 +9,7 @@ describe('tween method', () => {
it('should create a tween with control methods', () => {
const callback = vi.fn();
const tw = tween(callback);
-
+
expect(typeof tw.start).toBe('function');
expect(typeof tw.finish).toBe('function');
expect(typeof tw.pause).toBe('function');
@@ -20,10 +20,10 @@ describe('tween method', () => {
it('should execute callback with progress values', () => {
const callback = vi.fn();
const tw = tween(callback);
-
+
tw.progress(0.5);
expect(callback).toHaveBeenCalledWith(0.5);
-
+
tw.progress(1);
expect(callback).toHaveBeenCalledWith(1);
});
@@ -32,7 +32,7 @@ describe('tween method', () => {
const callback = vi.fn();
const customEase = (t: number) => t * t;
const tw = tween(callback, { easing: customEase });
-
+
tw.progress(0.5);
expect(callback).toHaveBeenCalledWith(0.25);
});
@@ -40,7 +40,7 @@ describe('tween method', () => {
it('should support bezier curve easing', () => {
const callback = vi.fn();
const tw = tween(callback, { easing: [0, 0, 1, 1] });
-
+
tw.progress(0.5);
expect(callback).toHaveBeenCalled();
const callValue = callback.mock.calls[0]?.[0];
@@ -50,10 +50,10 @@ describe('tween method', () => {
it('should support smooth mode', () => {
const callback = vi.fn();
const tw = tween(callback, { smooth: true });
-
+
tw.progress(1);
expect(callback).toHaveBeenCalled();
-
+
const callValue = callback.mock.calls[0]?.[0];
expect(typeof callValue).toBe('number');
});
@@ -61,7 +61,7 @@ describe('tween method', () => {
it('should support smooth mode with custom factor', () => {
const callback = vi.fn();
const tw = tween(callback, { smooth: 0.2 });
-
+
tw.progress(1);
expect(callback).toHaveBeenCalled();
});
@@ -69,10 +69,10 @@ describe('tween method', () => {
it('should support spring mode', () => {
const callback = vi.fn();
const tw = tween(callback, { spring: true });
-
+
tw.progress(1);
expect(callback).toHaveBeenCalled();
-
+
const callValue = callback.mock.calls[0]?.[0];
expect(typeof callValue).toBe('number');
});
@@ -80,7 +80,7 @@ describe('tween method', () => {
it('should support spring mode with custom stiffness', () => {
const callback = vi.fn();
const tw = tween(callback, { spring: 0.2 });
-
+
tw.progress(1);
expect(callback).toHaveBeenCalled();
});
@@ -88,7 +88,7 @@ describe('tween method', () => {
it('should support custom precision', () => {
const callback = vi.fn();
const tw = tween(callback, { precision: 0.01 });
-
+
tw.progress(0.999);
expect(callback).toHaveBeenCalled();
});
@@ -97,15 +97,15 @@ describe('tween method', () => {
const callback = vi.fn();
const onStart = vi.fn();
const onProgress = vi.fn();
-
+
const tw = tween(callback, {
onStart,
- onProgress
+ onProgress,
});
-
+
tw.start();
expect(onStart).toHaveBeenCalledWith(0);
-
+
tw.progress(0.5);
expect(onProgress).toHaveBeenCalledWith(0.5);
});
@@ -113,9 +113,9 @@ describe('tween method', () => {
it('should support manual progress control', () => {
const callback = vi.fn();
const tw = tween(callback);
-
+
expect(tw.progress()).toBe(0);
-
+
tw.progress(0.5);
expect(callback).toHaveBeenCalledWith(0.5);
expect(tw.progress()).toBe(0.5);
@@ -124,20 +124,20 @@ describe('tween method', () => {
it('should support finish method', () => {
const callback = vi.fn();
const tw = tween(callback);
-
+
tw.finish();
expect(callback).toHaveBeenCalledWith(1);
});
it('should handle spring and smooth mode parameters correctly', () => {
const callback = vi.fn();
-
+
const springTween = tween(callback, { spring: 0.3 });
springTween.progress(0.5);
expect(callback).toHaveBeenCalled();
-
+
callback.mockClear();
-
+
const smoothTween = tween(callback, { smooth: 0.4 });
smoothTween.progress(0.5);
expect(callback).toHaveBeenCalled();
@@ -146,10 +146,10 @@ describe('tween method', () => {
it('should work with different precision values', () => {
const callback = vi.fn();
const tw = tween(callback, { precision: 0.1 });
-
+
tw.progress(0.95);
expect(callback).toHaveBeenCalled();
-
+
const callValue = callback.mock.calls[0]?.[0];
expect(callValue).toBe(1);
});
diff --git a/tsconfig.build.json b/tsconfig.build.json
index 68e9e8fa1..80f2ca0e6 100644
--- a/tsconfig.build.json
+++ b/tsconfig.build.json
@@ -8,8 +8,5 @@
"emitDeclarationOnly": true,
"types": []
},
- "include": [
- "packages/global.d.ts",
- "packages/js-toolkit/**/*.ts"
- ]
+ "include": ["packages/global.d.ts", "packages/js-toolkit/**/*.ts"]
}
diff --git a/tsconfig.json b/tsconfig.json
index 330518f3c..81b4defda 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -2,7 +2,17 @@
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
- "lib": ["ESNext", "dom", "dom.iterable", "ES2015", "ES2016", "ES2017", "ES2018", "ES2019", "ES2020"],
+ "lib": [
+ "ESNext",
+ "dom",
+ "dom.iterable",
+ "ES2015",
+ "ES2016",
+ "ES2017",
+ "ES2018",
+ "ES2019",
+ "ES2020"
+ ],
"allowJs": true,
"checkJs": true,
"strict": false,
@@ -15,9 +25,5 @@
"#test-utils": ["./packages/tests/__utils__/index.ts"]
}
},
- "include": [
- "packages/global.d.ts",
- "packages/js-toolkit/**/*.ts",
- "packages/tests/**/*.ts"
- ]
+ "include": ["packages/global.d.ts", "packages/js-toolkit/**/*.ts", "packages/tests/**/*.ts"]
}
diff --git a/tsconfig.lint.json b/tsconfig.lint.json
index ee31e2dff..b6878cf7c 100644
--- a/tsconfig.lint.json
+++ b/tsconfig.lint.json
@@ -4,8 +4,5 @@
"noEmit": true,
"types": []
},
- "include": [
- "packages/global.d.ts",
- "packages/js-toolkit/**/*.ts"
- ]
+ "include": ["packages/global.d.ts", "packages/js-toolkit/**/*.ts"]
}