fit-dimensions
Version:
A tiny utility function to fit a source rectangle within a target rectangle using popular object-fit modes (contain, cover, fill, none, scale-down). Maintains aspect ratio as needed. Useful for images, videos, UI elements, and more.
67 lines • 1.75 kB
JSON
{
"name": "fit-dimensions",
"type": "module",
"version": "1.0.0",
"description": "A tiny utility function to fit a source rectangle within a target rectangle using popular object-fit modes (contain, cover, fill, none, scale-down). Maintains aspect ratio as needed. Useful for images, videos, UI elements, and more.",
"author": {
"name": "GloryWong",
"email": "glorywong1001@gmail.com",
"url": "https://glorywong.com"
},
"license": "MIT",
"homepage": "https://github.com/GloryWong/fit-dimensions#readme",
"repository": "github:GloryWong/fit-dimensions",
"bugs": "https://github.com/GloryWong/fit-dimensions/issues",
"keywords": [
"fit",
"scale",
"rectangle",
"aspect-ratio",
"object-fit",
"contain",
"cover",
"fill",
"scale-down",
"resize",
"geometry",
"utility",
"js",
"typescript"
],
"main": "index.js",
"types": "index.d.ts",
"files": [
"index.d.ts",
"index.js"
],
"engines": {
"node": ">=18"
},
"devDependencies": {
"@antfu/eslint-config": "^4.18.0",
"@commitlint/cli": "^19.8.1",
"@commitlint/config-conventional": "^19.8.1",
"@tsconfig/node18": "^18.2.4",
"@vitest/coverage-istanbul": "^3.2.4",
"eslint": "^9.31.0",
"lint-staged": "^16.1.2",
"simple-git-hooks": "^2.13.0",
"typescript": "^5.8.3",
"vitest": "^3.2.4"
},
"simple-git-hooks": {
"commit-msg": "pnpm commitlint --edit ${1}",
"pre-commit": "pnpm lint-staged"
},
"lint-staged": {
"*": "pnpm lint:fix"
},
"scripts": {
"build": "tsc",
"lint": "eslint .",
"lint:fix": "pnpm lint --fix",
"test": "vitest run",
"test:watch": "vitest",
"coverage": "vitest run --coverage.enabled"
}
}