Skip to content

Modules

Joakim edited this page Dec 17, 2021 · 17 revisions

Export

A module's last evaluated expression is implicitly exported. By convention, an object.

sum: (a, b) -> a + b
diff: (a, b) -> a - b

[sum, diff]

Import

import module: 'module.ks'
import [foo]: 'module.ks'
import [foo as alias]: 'module.ks'
import [foo, bar]: 'module.ks'
import _: 'module.ks'  -- for side effects

The import declaration can also import individual items from the global object.

import JSON
import Math
import Promise

Or only specific fields from those.

import [abs, ceil]: Math
Clone this wiki locally