API Reference

jspicl

Entry point for transpiling your JavaScript code.

function jspicl(source: string, options?: JspiclOptions): JspiclOutput;

JspiclOptions

type JspiclOptions = {
prettify?: boolean;
customMappers?: Record<string, AstNodeParser>;
};

JspiclOutput

type JspiclOutput = {
code: string;
polyfills: Record<string, string>;
};

AstNode

Represents a node in the syntax tree. All nodes contain at least a type property.

type AstNode = {
type: string;
[key: string]: any;
};

AstNodeParser

Contract for a parser function. The function should be named after the AST node type. Binding a scopeBoundary field on the function will create a new scope for all variables defined inside the hieararchy.

type AstNodeParser = {
(node: Omit<AstNode, "type">, options: AstNodeParserOptions): string;
scopeBoundary?: boolean;
};

AstNodeParserOptions

Includes references to the transpile function and scope.

type AstNodeParserOptions = {
transpile: TranspileFunction;
scope: {
variables: Record<string, any>;
[key: string]: any;
};
};

TranspileFunction

type TranspileFunction = (node: AstNode, options?: TranspileOptions) => string;

TranspileOptions

type TranspileOptions = { arraySeparator?: string };