Search


Search something to see results

RenderResult

Render result.

The generated css is stored as UTF-8 bytes in RenderResult.write: it can be written to a file or sent over the network as is. RenderResult.code decodes the bytes the first time it is read, the string is kept.

import {render} from '@tbela99/css-parser';
import {writeFile} from 'node:fs/promises';

const result = render(parseResult.arena, parseResult.ast);

// bytes, no string conversion
await writeFile('out.css', result.write);

// string, decoded once
console.log(result.code);

Hierarchy (View Summary)

Index

Accessors

Constructors

Methods

Properties

Parameters

  • write: Uint8Array

    rendered css, encoded as UTF-8

  • errors: ErrorDescription[]
  • stats: RenderResultStats
  • Optionalmap: SourceMap
  • codeLength: number = -1

    length of the decoded css (code.length), computed when it is not provided

Returns RenderResult

JSON representation: the css is serialized as a string, the bytes are not serialized

Returns Record<string, any>

Internal

length of the rendered css once decoded (result.code.length), without decoding it

Parameters

Returns number

Render errors

map?: SourceMap

Source map

Render stats

write: Uint8Array

Rendered CSS, encoded as UTF-8

shape: RenderResult = ...

An instance is kept alive: the hidden class of the instances would otherwise be collected by a full garbage collection when no instance is alive, and the optimized code that depends on it discarded (deoptimized)