findAttr

Returns one of a node's attributes as the record the document holds, with its identifier and value, or undefined when the node does not write it.

@internote/canvas-sdkFunction
On this page
import { findAttr } from '@internote/canvas-sdk';

For the value alone, attrOf is the shorter read. The record is what a validator wants when it reports on an attribute, since the compiler's own attribute records carry the source position beside the value.

#Signature

<N extends NodeLike>(
    node: N,
    identifier: string,
): NonNullable<N["attributes"]>[number] | undefined

#Parameters

node
The node to read.
identifier
The attribute's canonical name.

Declared in packages/canvas-sdk/src/environment/node-attributes.ts:53.

Last updated