Ω: the Omega function
Ω
is an experiment in replacing try
/catch
boilerplate with an [err, result]
array, inspired by error return values in Go.
Installation
# npm npm i --save omega-fn # yarn yarn add omega-fn
Usage
const Ω = const err result = await
Rationale
This is annoying:
let result try result = await catch err // ... // use result
This is nicer:
let err result = await if err // ... // use result
What's it doing?
Not much:
moduleexports = async { const channels = undefined undefined try channels1 = await fn catch err channels0 = err finally return channels }
Why Ω?
Ω
represents finality, and this function is conceptually similar to afinally
block- it's keyboard-friendly (at least on a Mac:
option
+z
) - since the goal is hiding as much annoying syntax as possible, I wanted something that was only a single character
- unclaimed single-char non-alpha keyboard-friendly valid JS identifiers are in very short supply (thanks a lot,
$
and_
)
If you're weirded out by it, you can always call it something else:
const omega = require('omega-fn')
const channels = require('omega-fn')
const potato = require('omega-fn')