You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@terrazzo/parser

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@terrazzo/parser

Parser/validator for the Design Tokens Community Group (DTCG) standard.

0.10.1
latest
Source
npmnpm
Version published
Weekly downloads
11K
-5.14%
Maintainers
1
Weekly downloads
 
Created
Source

⛋ @terrazzo/parser

The JS API is a lower-level API than the CLI that can be used to build Design Token systems. The JS API runs anywhere JavaScript does, including in Node.js, the browser, and serverless functions.

Basic Usage

npm i -D @terrazzo/parser

And here’s a basic example showing config, parse, and build steps:

import { defineConfig, parse, build } from "@terrazzo/parser";

const config = defineConfig(
  {
    // config options
  },
  { cwd: new URL(import.meta.url) }
);

const rawTokens = "(any JSON or YAML)";
const { tokens, sources } = await parse(
  [{ filename: new URL("file:///tokens.json"), src: rawTokens }],
  { config }
);
const buildResult = await build(tokens, { sources, config });

It’s worth noting the JS API is a little more manual work than the CLI:

  • parse() and build() are distinct steps that each do some of the work.
  • defineConfig() needs a cwd so it can resolve files (this can even be a remote URL, so long as it’s a URL())
  • The AST generated from parse() must get passed into build() so the error messages can point to the right lines in the source file.
  • The build() step only returns a final array of outputFilesin memory but doesn’t write them to disk. It’s up to you to write them to disk, upload them somewhere, etc.

Full documentation

Keywords

design tokens

FAQs

Package last updated on 07 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts