【文件属性】:
文件名称:space-monad:选项和结果〜打字稿的Monad
文件大小:72KB
文件格式:ZIP
更新时间:2021-05-02 09:21:25
TypeScript
太空单子
TypeScript的Option和Result单子。
选项
包含
存在
toArray
创建一个选项
选项(x)
从值创建一个选项。 如果该值为null或未定义,它将创建一个None,否则创建Some。
const some = Option ( 33 ) // some === Some(33)
const none = Option ( null ) // none === None
如果您已经知道该值是确定的(不能为空),则可以直接创建Some或None :
const some = Some ( 33 ) // Some(null | undefined) wouldn't compile.
const none = None
Option.all([... optionsOrValues])
创建一个新的Option,以保存传递的数组中包含的所有值的元
【文件预览】:
space-monad-master
----package.json(1KB)
----test()
--------result.ts(4KB)
--------option.ts(11KB)
----.prettierignore(4B)
----LICENSE(1KB)
----src()
--------iterator.ts(410B)
--------result.ts(7KB)
--------option.ts(10KB)
--------index.ts(89B)
----tsconfig.json(279B)
----.gitignore(30B)
----README.md(7KB)
----yarn.lock(152KB)