module folktale/conversions

Allows converting between the different data structures provided by Folktale and JavaScript.

Documentation

Allows converting between the different data structures provided by Folktale and JavaScript.

Properties

Converting from Futures

futureToPromise(aFuture)

Converts a Future into a Promise.

Experimental

Converting from Maybe

maybeToResult(aMaybe, failureValue)

Converts a Maybe to an Result. Nothings map to Errors, Justs map to Oks.

maybeToValidation(aMaybe, failureValue)

Converts a Maybe to a Validation. Nothings map to Failures, Justs map to Successes.

Converting from Promises

promiseToFuture(aPromise)

Converts a Promise to a folktale Future.

Experimental
promisedToTask(aPromiseFn)

Converts a Promise-yielding function to a Task-yielding function.

Experimental

Converting from Result

resultToMaybe(aResult)

Converts an Result structure to a Maybe structure. Errors map to Nothings, Oks map to Justs.

resultToValidation(aResult)

Converts an Result to a Validation. Errors map to Failures, Oks map to Successes.

Converting from Validation

validationToMaybe(aValidation)

Converts a Validation to a Maybe. Failures map to Nothings, Successes map to Justs.

validationToResult(aValidation)

Converts a Validation to an Result. Failures map to Errors, Successes map to Oks.

Converting from function with Node-style callback

nodebackToTask(fn)

Converts a function with a Node-style callback to a Task.

Experimental

Converting from nullables

nullableToMaybe(a)

Converts a nullable value to a maybe. null and undefined map to Nothing, any other value maps to Justs.

nullableToResult(a, givenFallback)

Converts a nullable value to a Result. null and undefined map to Errors, any other value maps to Oks.

nullableToValidation(a, fallbackValue)

Converts a nullable value to a Validation. null and undefined map to Failures, any other type maps to Successes.

Source Code

Defined in source/conversions/index.js at line 14, column 0
{
  resultToValidation: require('./result-to-validation'),
  resultToMaybe: require('./result-to-maybe'),
  validationToResult: require('./validation-to-result'),
  validationToMaybe: require('./validation-to-maybe'),
  maybeToValidation: require('./maybe-to-validation'),
  maybeToResult: require('./maybe-to-result'),
  nullableToValidation: require('./nullable-to-validation'),
  nullableToResult: require('./nullable-to-result'),
  nullableToMaybe: require('./nullable-to-maybe'),
  nodebackToTask: require('./nodeback-to-task'),
  futureToPromise: require('./future-to-promise'),
  promiseToFuture: require('./promise-to-future'),
  promisedToTask: require('./promised-to-task')
}
Stability
stable
Licence
MIT
Module
folktale/conversions
Authors
Copyright
(c) 2013-2017 Quildreen Motta, and CONTRIBUTORS
Authors
  • Quildreen Motta
Maintainers
  • Quildreen Motta <queen@robotlolita.me> (http://robotlolita.me/)