How to use the fluture.isFuture function in fluture

To help you get started, we’ve selected a few fluture examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github neutrinojs / neutrino / packages / neutrino / src / api.js View on Github external
.chain(() => {
      const result = this.commands[commandName](this.config.toConfig(), this);

      return Future.isFuture(result) ?
        result :
        Future.tryP(() => Promise.resolve().then(() => result));
    })
    // Trigger all post-command events, resolving with the value of the command execution
github fluture-js / fluture-express / index.js View on Github external
const runAction = (name, action, req, res, next) => {
  const ret = action (req, res.locals);

  if (!isFuture (ret)) {
    throw new TypeError (
      `The "${name}" action did not return a Future, instead saw:\n\n  ${ret}`
    );
  }

  fork (next) (val => {
    if (!Response.is (val)) {
      throw new TypeError (`The Future returned by the "${
        name
      }" action did not resolve to a Response, instead saw:\n\n  ${val}`);
    }

    val.cata ({
      Stream: (code, mime, stream) => {
        res.type (mime);
        res.status (code);
github char0n / monad-t / src / FlutureTMonetEither / index.js View on Github external
function FlutureTMonetEither(monad) {
  if (isUndefined(new.target)) {
    if (isFuture(monad)) {
      return FlutureTMonetEither.fromFuture(monad);
    } else if (monad instanceof Identity.fn.init) {
      return FlutureTMonetEither.fromValue(monad.get());
    } else if (monad instanceof Either.fn.init) {
      return FlutureTMonetEither.fromEither(monad);
    }
    throw new Error('FlutureTMonetEither can transform only specific monad types');
  }

  this.run = monad;
  this['@@type'] = this.constructor['@@type'];
}