numberAttr

Returns an attribute as a number, or the fallback when it is absent or anything else.

@internote/canvas-sdkFunction
On 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

attrs
An attribute map, such as ctx.animation.attrValuesOf(node).
identifier
The attribute's canonical name.
fallback
What 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.

Last updated