Compare commits

..

No commits in common. "48df37e502146b4a46225c3193a1c88b7c42cb5d" and "a18a759db4332a834ee5cfff113958ad006779a3" have entirely different histories.

3 changed files with 21 additions and 12 deletions

View file

@ -19,8 +19,5 @@ result.bind(() => Err(new Error(-Infinity)))
.bind(Ok) .bind(Ok)
result.isErr() // true result.isErr() // true
// crimes!
None == None() // true
``` ```

View file

@ -81,12 +81,13 @@ function isSome() {
* @returns {this is None} * @returns {this is None}
*/ */
function isNone() { function isNone() {
return this === None return this === none
} }
/** /**
* @template T * @template T
* @param {?T} value * @param {?T} value
* @variation 2
* @returns {Some<T>} * @returns {Some<T>}
*/ */
export const Some = value => ({ export const Some = value => ({
@ -100,13 +101,21 @@ export const Some = value => ({
fold fold
}) })
export const None = () => None /**
None.isSome = isSome * @returns {None}
None.isNone = isNone */
None.chain = constant export const None = () => none
None.map = constant
None.alt = alt /** @type {None} */
None.fold = fold export const none = ({
isSome,
isNone,
chain: constant,
map: constant,
alt,
fold
})
/** /**
* @template T * @template T

View file

@ -1,2 +1,5 @@
export * from './algebra/index.js' import { Result } from './algebra/result.js'
const a = Result.of(2).chain(x => Result.zero())
console.log(a)