{"id":12170,"library":"ts-easing","title":"TypeScript Easing Functions","description":"ts-easing is a lightweight, zero-dependency collection of standard easing functions written entirely in TypeScript. Currently at version 0.2.0, it provides common easing curves like quadratic, cubic, sinusoidal, exponential, and circular, among others. The library is designed for simplicity, accepting a single normalized input `t` in the range `[0, 1]` and returning an eased value also in `[0, 1]`. Due to its stable and self-contained nature, it likely has a very slow or infrequent release cadence, primarily for bug fixes or minor additions rather than frequent feature releases. Its key differentiator is its minimal footprint, strong TypeScript typing, and adherence to the standard easing function interface, making it suitable for animations and transitions in both browser and Node.js environments without external dependencies. It aims to be a straightforward utility for developers needing reliable easing logic for animation or UI interactions.","status":"active","version":"0.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/streamich/ts-easing","tags":["javascript","typescript"],"install":[{"cmd":"npm install ts-easing","lang":"bash","label":"npm"},{"cmd":"yarn add ts-easing","lang":"bash","label":"yarn"},{"cmd":"pnpm add ts-easing","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The library exports a single named object `easing` which contains all the individual easing functions (e.g., `easing.quadratic`). Individual functions are not directly exported from the top-level module.","wrong":"import easing from 'ts-easing';\n// OR\nimport { quadratic } from 'ts-easing';","symbol":"easing","correct":"import { easing } from 'ts-easing';"},{"note":"For CommonJS environments, destructure the `easing` object from the module export.","symbol":"easing (CommonJS)","correct":"const { easing } = require('ts-easing');"},{"note":"While `ts-easing` ships types, the basic type for its functions is a simple `(t: number) => number`, which can be defined directly or inferred. No specific named type like `EasingFunction` is explicitly exported from the library.","symbol":"EasingFunction type","correct":"type EasingFunction = (t: number) => number;"}],"quickstart":{"code":"import { easing } from 'ts-easing';\n\n// Demonstrating various easing functions at different progress points\nconst testPoints = [0, 0.25, 0.5, 0.75, 1];\n\nconsole.log(\"--- Easing Function Outputs ---\");\n\nconsole.log(\"\\nQuadratic Ease (ease.quadratic):\");\ntestPoints.forEach(t => {\n  const easedValue = easing.quadratic(t);\n  console.log(`t=${t.toFixed(2)} -> ${easedValue.toFixed(4)}`);\n});\n\nconsole.log(\"\\nCubic Ease (ease.cubic): \");\ntestPoints.forEach(t => {\n  const easedValue = easing.cubic(t);\n  console.log(`t=${t.toFixed(2)} -> ${easedValue.toFixed(4)}`);\n});\n\nconsole.log(\"\\nExponential Ease (ease.exponential): \");\ntestPoints.forEach(t => {\n  const easedValue = easing.exponential(t);\n  console.log(`t=${t.toFixed(2)} -> ${easedValue.toFixed(4)}`);\n});\n\nconsole.log(\"\\nSine Ease (ease.sine): \");\ntestPoints.forEach(t => {\n  const easedValue = easing.sine(t);\n  console.log(`t=${t.toFixed(2)} -> ${easedValue.toFixed(4)}`);\n});\n\n// In a real application, these functions would be used inside an animation loop\n// For example, to calculate an animated property based on time progress `t`.","lang":"typescript","description":"Demonstrates importing the `easing` object and using several common easing functions (quadratic, cubic, exponential, sine) at various input `t` values from 0 to 1, showing their output."},"warnings":[{"fix":"Ensure that the input parameter `t` is always normalized to a value between 0 and 1 before passing it to any easing function.","message":"Easing functions are designed for input values `t` strictly within the `[0, 1]` range. Providing values outside this range may lead to undefined or unexpected mathematical results, though typically still a number.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure you are destructuring the `easing` object correctly, or accessing functions as properties: `import { easing } from 'ts-easing'; console.log(easing.quadratic(0.5));`","cause":"Attempting to access an easing function (e.g., `quadratic`) directly when the library exports them as properties of a single `easing` object.","error":"TypeError: easing.quadratic is not a function"},{"fix":"Install the package using `npm install ts-easing` or `yarn add ts-easing`. Verify the import path is exactly `ts-easing`.","cause":"The package has not been installed or there is a typo in the import path.","error":"Cannot find module 'ts-easing'"}],"ecosystem":"npm"}