numberAttr
Returns an attribute as a number, or the fallback when it is absent or anything else.
@internote/canvas-sdkOn this page
import { numberAttr } from '@internote/canvas-sdk';A string, a binding and an unresolved track all give the fallback. NaN is a number and is passed through, as a typeof test would.
#Signature
(
attrs: Readonly<Record<string, unknown>>,
identifier: string,
fallback: number,
): number
(
attrs: Readonly<Record<string, unknown>>,
identifier: string,
): number | undefined#Parameters
attrsAn attribute map, such as
ctx.animation.attrValuesOf(node).identifierThe attribute's canonical name.
fallbackWhat to return when the attribute is not a number.
#Example
const attrs = ctx.animation.attrValuesOf(node);
const radius = numberAttr(attrs, 'radius', 4);Declared in packages/canvas-sdk/src/environment/node-attributes.ts:103.