Files
excalidraw/packages/common
Mark Tolmacs 6219411171 feat(common): add isRecord and numeric coercion helpers
Adds helpers for validating untrusted scene data:

- `isRecord`: a non-null, non-array object whose keys can be read
- `toFiniteNumber`: accepts finite numbers and strings that are entirely
  a number (optionally with a `px` suffix). The regex is anchored so that
  e.g. dates or lists of numbers aren't truncated to their leading number,
  and is unambiguous so that it runs in linear time on untrusted input.
- `toPositiveNumber`: same, restricted to values > 0

`restoreFreedrawStrokeOptions` uses `isRecord` in place of its inline check.

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
2026-10-21 08:20:35 +00:00
..

@excalidraw/common

Install

npm install @excalidraw/common

If you prefer Yarn over npm, use this command to install the Excalidraw utils package:

yarn add @excalidraw/common

With PNPM, similarly install the package with this command:

pnpm add @excalidraw/common