mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-12-04 17:09:07 +00:00
* update nitro * try this? * Try this * update vercel output * Add await * Fix endpoints * Adjust 404 catch all * Fix output * Adjust react in api * Fix types * Remove @resvg/resvg-wasm * Format code * Fix failing check * Apply feedback * Format code
20 lines
561 B
TypeScript
20 lines
561 B
TypeScript
import { memoize } from 'lodash-es';
|
|
import SVGPathCommander from 'svg-path-commander';
|
|
import { Path } from './types';
|
|
|
|
function pathToPoints({ d, prev, next }: Path, interval = 1) {
|
|
const commander = new SVGPathCommander(d);
|
|
const points = [];
|
|
try {
|
|
const totalLength = commander.getTotalLength();
|
|
points.push(prev);
|
|
for (let i = interval; i < totalLength - interval; i += interval) {
|
|
points.push(commander.getPointAtLength(i));
|
|
}
|
|
points.push(next);
|
|
} catch (err) {}
|
|
return points;
|
|
}
|
|
|
|
export default memoize(pathToPoints);
|