UNPKG

functionalscript

Version:

FunctionalScript is a purely functional subset of JavaScript

19 lines (18 loc) 489 B
import { error, ok, unwrap } from "./module.f.js"; export default { example: () => { const success = ok(42); const failure = error('Something went wrong'); if (unwrap(success) !== 42) { throw 'error'; } const [kind, v] = failure; if (kind !== 'error') { throw 'error'; } // `v` is inferred as `string` here if (v !== 'Something went wrong') { throw 'error'; } } };