Package Exports
- option-t
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (option-t) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
OptionType
- This library represents Option type in ECMAScript.
- APIs are inspired by Rust Language's
Option<T>
.
Installation
npm install --save option-t
Usage
var OptionType = require('option-t').OptionType;
// `Some<T>`
var some = new OptionType(1);
console.log(some.isSome); // true
console.log(some.value); // 1
// `None`
var none = new OptionType();
console.log(some.isSome); // false
console.log(some.value); // undefined
JSON Representation
new OptionType(1)
will be
{
"is_some": true,
"value": 1
}