{"_id":"@288-toolkit/math","_rev":"4-5c9f743527b7c2d07957d28b6ffd9cf2","name":"@288-toolkit/math","dist-tags":{"latest":"1.1.1"},"versions":{"1.0.0":{"name":"@288-toolkit/math","version":"1.0.0","author":{"name":"DeuxHuitHuit"},"license":"MIT","_id":"@288-toolkit/math@1.0.0","maintainers":[{"name":"nitriques","email":"open-source@deuxhuithuit.com"},{"name":"f-elix","email":"guerinfelix08@gmail.com"}],"dist":{"shasum":"7ece5990476ddf7f5e24ad2067b60878f27d96dc","tarball":"https://registry.npmjs.org/@288-toolkit/math/-/math-1.0.0.tgz","fileCount":10,"integrity":"sha512-hiWWmsmnF+VhthIzNc6rqyKlLMZx9h6XONLUJwzU4ZF6i4sd27XAWCv6Gbren6gBr6qd8qwDPIPlpL033oO8Lw==","signatures":[{"sig":"MEUCIQCQVFl75yqvDjMLvdsVc0buKlafSYPRr526FQbavXNYDwIgfr+wYn44A5jJbnWZBUXWprQSS2fvw3TAUsugXFYvcSw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6811},"type":"module","_from":"file:288-toolkit-math-1.0.0.tgz","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"scripts":{"lc":"npm run lint && npm run check","lint":"eslint --max-warnings=0 --cache .","test":"vitest run","build":"svelte-package -i src","check":"svelte-check --tsconfig ./tsconfig.json --fail-on-warnings","format":"npm run format:file .","lc:watch":"npm run lint && npm run check -- --watch","lint:fix":"npm run lint -- --fix","test:watch":"vitest","check:watch":"npm run check -- --watch","format:file":"npm run format:prettier -- --write","format:prettier":"prettier --config ./.prettierrc"},"_npmUser":{"name":"f-elix","email":"guerinfelix08@gmail.com"},"_resolved":"/tmp/d34faa08c7638bbb7cb6540354fcf2dd/288-toolkit-math-1.0.0.tgz","_integrity":"sha512-hiWWmsmnF+VhthIzNc6rqyKlLMZx9h6XONLUJwzU4ZF6i4sd27XAWCv6Gbren6gBr6qd8qwDPIPlpL033oO8Lw==","_npmVersion":"10.5.0","description":"```sh npm i @288-toolkit/math ```","directories":{},"_nodeVersion":"20.12.2","dependencies":{"just-clamp":"^4.2.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/math_1.0.0_1714586905671_0.4578512880025509","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"@288-toolkit/math","version":"1.1.0","author":{"name":"DeuxHuitHuit"},"license":"MIT","_id":"@288-toolkit/math@1.1.0","maintainers":[{"name":"nitriques","email":"open-source@deuxhuithuit.com"},{"name":"f-elix","email":"guerinfelix08@gmail.com"}],"dist":{"shasum":"af518cc85cb5e3b7df44bbfb76fa64640384004d","tarball":"https://registry.npmjs.org/@288-toolkit/math/-/math-1.1.0.tgz","fileCount":13,"integrity":"sha512-hbvnSuYO3Ulf/ODox/V0dXZmXuw8efPO9xdhysmrwD05MWN+5+FlK6pH9Wt0wEn1FeNTlLyku44A9g4TXS8Ufg==","signatures":[{"sig":"MEUCIDKG+JmWdAOIuTs3cvVEVP/H2HgSLp81mwJ6e9Uu7C9HAiEA3iZ9CtAavVcgRRRMtWXrQuEoYOaNLZGR8FzipQKPPfw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":8904},"type":"module","_from":"file:288-toolkit-math-1.1.0.tgz","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"scripts":{"lc":"npm run lint && npm run check","lint":"eslint --max-warnings=0 --cache .","test":"vitest run","build":"svelte-package -i src","check":"svelte-check --tsconfig ./tsconfig.json --fail-on-warnings","format":"npm run format:file .","lc:watch":"npm run lint && npm run check -- --watch","lint:fix":"npm run lint -- --fix","test:watch":"vitest","check:watch":"npm run check -- --watch","format:file":"npm run format:prettier -- --write","format:prettier":"prettier --config ./.prettierrc"},"_npmUser":{"name":"f-elix","email":"guerinfelix08@gmail.com"},"_resolved":"/tmp/714fc62995f85ae118d7a0ec3937cc29/288-toolkit-math-1.1.0.tgz","_integrity":"sha512-hbvnSuYO3Ulf/ODox/V0dXZmXuw8efPO9xdhysmrwD05MWN+5+FlK6pH9Wt0wEn1FeNTlLyku44A9g4TXS8Ufg==","_npmVersion":"10.9.0","description":"```sh npm i @288-toolkit/math ```","directories":{},"_nodeVersion":"22.12.0","dependencies":{"just-clamp":"^4.2.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/math_1.1.0_1746027595296_0.8677332362703172","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"@288-toolkit/math","version":"1.1.1","author":{"name":"DeuxHuitHuit"},"license":"MIT","_id":"@288-toolkit/math@1.1.1","maintainers":[{"name":"nitriques","email":"open-source@deuxhuithuit.com"},{"name":"f-elix","email":"guerinfelix08@gmail.com"}],"dist":{"shasum":"404d44680103c4132c74a29f987bf2bdd8733f58","tarball":"https://registry.npmjs.org/@288-toolkit/math/-/math-1.1.1.tgz","fileCount":13,"integrity":"sha512-b4LOjD0IrUmSuZcpgKE18Gjyf49TItqEAr051Ryig5t49A9QVVpp4p5l4zuDEwm05RXxNQ2ZWYxbHr4jxhxX5A==","signatures":[{"sig":"MEUCICtGf5QPQqcv7f6KizjF0j1qEsJzFv8UBLB1R/H6f8aZAiEA2VpOuH8xAbGBrNmW8Rr8hWjFtdoXq7dnXVs9xbutUrU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":8907},"type":"module","_from":"file:288-toolkit-math-1.1.1.tgz","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"scripts":{"lc":"npm run lint && npm run check","lint":"eslint --max-warnings=0 --cache .","test":"vitest run","build":"svelte-package -i src","check":"svelte-check --tsconfig ./tsconfig.json --fail-on-warnings","format":"npm run format:file .","lc:watch":"npm run lint && npm run check -- --watch","lint:fix":"npm run lint -- --fix","test:watch":"vitest","check:watch":"npm run check -- --watch","format:file":"npm run format:prettier -- --write","format:prettier":"prettier --config ./.prettierrc"},"_npmUser":{"name":"f-elix","email":"guerinfelix08@gmail.com"},"_resolved":"/tmp/27ba6167c7a3b566971a9f0d2236a658/288-toolkit-math-1.1.1.tgz","_integrity":"sha512-b4LOjD0IrUmSuZcpgKE18Gjyf49TItqEAr051Ryig5t49A9QVVpp4p5l4zuDEwm05RXxNQ2ZWYxbHr4jxhxX5A==","_npmVersion":"10.9.0","description":"```sh npm i @288-toolkit/math ```","directories":{},"_nodeVersion":"22.12.0","dependencies":{"just-clamp":"^4.2.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/math_1.1.1_1758637326926_0.4620445130232762","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2024-05-01T18:08:25.526Z","modified":"2025-09-23T15:34:43.682Z","1.0.0":"2024-05-01T18:08:25.819Z","1.1.0":"2025-04-30T15:39:55.499Z","1.1.1":"2025-09-23T14:22:07.125Z"},"author":{"name":"DeuxHuitHuit"},"license":"MIT","description":"```sh npm i @288-toolkit/math ```","maintainers":[{"email":"open-source@deuxhuithuit.com","name":"nitriques"}],"readme":"# Math\n\n```sh\nnpm i @288-toolkit/math\n```\n\nA collection of math related functions.\n\n## `randomInt()`\n\nGet a random integer between two integers. The given range includes both the min and the max.\n\nAsking for (1, 6) will simulate a d6 and (0, array.length - 1) will return a correct index. If the\nrange is negative, the min and max will be swapped.\n\nThis function tries to not be biased, by rejecting values that would cause a non-uniform\ndistribution. See https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle.\n\n## `hash()`\n\nCreate a hash of a string as a string.\n\n```ts\nconst hash = await hash('hello'); // sha-1 by default\nconst hash = await hash('hello', 'SHA-256'); // sha-256\n```\n\n## `lerp()`\n\nLinear interpolation function that returns a point between two bounds derived from a value between\ntwo other bounds. It makes sure to not divide or multiply by zero.\n\nX1 and x2 are the target bounds.\n\nY1 and y2 are the two bounds between which the new value should be found.\n\nTarget is the point between to bounds from which we derive a new value.\n\n```ts\nconst lerp: (x1: number, x2: number, y1: number, y2: number, target: number) => number;\n```\n\n```ts\n// Convert a `progress` value that's between 0 and 1 to a width between 300 and 500.\nconst newWidth = lerp(0, 1, 300, 500, progress);\n```\n\n## `clamp()`\n\nRestrict a number within a range.\n\nA re-export of https://github.com/angus-c/just/tree/master/packages/number-clamp\n\n## `computeGeoDistance()`\n\nComputes the distance between two points on the earth's surface, using the Haversine formula.\n\n```ts\nconst distance = computeGeoDistance(0.2323, 53530.3434);\n```\n","readmeFilename":"README.md"}