Using the NPM Module

Recommended way to use Tokun is via CLI, however, using this as a NPM Module might be useful when you want to do a lot of custom scripts, or use it in the browser. Tokun provides an API for seamless interaction.

Installation

To use Tokun API, install it as a dependency (or devDependencies).

 

Quick start

See below simple way to use Tokun module

import { build, logVerbosityLevels } from 'tokun';

const value = ...;

// Build default to CSS.
const tokens = build({
  data: JSON.parse(value)
});

tokens.forEach(console.log);

// Enable verbose logs programmatically.
build(
  { data: JSON.parse(value) },
  { log: { verbosity: logVerbosityLevels.verbose } }
);

Programmatic build is silent by default. To enable logs, pass runtime logging options (for example { log: { verbosity: logVerbosityLevels.verbose } }).