Builtins Overview

Built-in APIs and feature flags in Tish.

Secure by default

Tish runs in secure mode with no I/O features enabled by default. Only core builtins (console, Math, JSON, parsing, etc.) are available.

Feature flags

To enable network, filesystem, or process APIs:

  • Run: The tish binary must be built with features, e.g. cargo run -p tishlang --features http -- run main.tish. The tish run command does not accept feature flags.
  • Build: Pass --feature (singular, repeatable) when building: tish build main.tish -o app --feature http --feature fs --feature process
FlagEnables
httpfetch, fetchAll, serve; Promise; setTimeout, setInterval, clearTimeout, clearInterval
fsreadFile, writeFile, fileExists, readDir, mkdir
processprocess.exit, process.cwd, process.argv, process.env
regexRegExp, String.match, String.replace with regex
fullAll features above

In zectre.yaml, configure features under build.features for platform deploys.

Builtin categories

CategoryFeatureAPIs
ConsoleAlwaysconsole.log, console.info, console.debug, console.warn, console.error
MathAlwaysMath.abs, Math.sqrt, Math.min, Math.max, Math.floor, Math.ceil, Math.round, Math.random, Math.pow, Math.sin, Math.cos, Math.tan, Math.log, Math.exp, Math.sign, Math.trunc, etc.
JSON & URIAlwaysJSON.parse, JSON.stringify, encodeURI, decodeURI
ParsingAlwaysparseInt, parseFloat, isFinite, isNaN
ObjectsAlwaysObject.keys, Object.values, Object.entries, Object.assign, Object.fromEntries
NumbersAlwaystoFixed
ArraysAlwaysArray.isArray, push, pop, map, filter, reduce, etc.
StringsAlwaysindexOf, includes, slice, split, replace, etc.
HTTPhttpfetch, fetchAll, serve (fetch / fetchAll return Promise; response body is a ReadableStream; text / json return Promise); Promise; setTimeout, setInterval, clearTimeout, clearInterval
File systemfsreadFile, writeFile, fileExists, readDir, mkdir
Processprocessprocess.exit, process.cwd, process.argv, process.env
RegExpregexRegExp, String.match, String.replace with regex

Improve this documentation