How to use the fluture.node 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 b-gran / object-editor-react / .neutrinorc.js View on Github external
neutrino.register('publish', () => {
        const isNextRelease = neutrino.options.args.next
        const packageJson = neutrino.options.packageJson
        const mainFile = path.resolve(path.join(neutrino.options.output, packageJson.main))
        const readme = path.join(__dirname, 'README.md')

        return Future.node(done => fs.access(mainFile, done))
          .mapRej(() => {
            console.log()
            console.error('No main file in output directory. Please run npm build')
          })

          // Create package.json for publishing
          .chain(() => {
            const trimPackageJson = R.omit([ 'devDependencies', 'scripts' ])()(packageJson)
            return Future.encase3(JSON.stringify, trimPackageJson, null, ' ')
          })
          .chain(packageJsonString => {
            const publishablePackageJsonPath = path.resolve(path.join(neutrino.options.output, 'package.json'))
            return Future
              .node(done => fs.writeFile(publishablePackageJsonPath, packageJsonString, done))
          })
github arrterian / nix-env-selector / src / actions.ts View on Github external
export const getNixConfigList = (dirPath: string) =>
  node(done => {
    readdir(dirPath, done);
  }).map(files => files.filter(fileName => /.*\.nix/i.test(fileName)));
github jongold / unblockerer / index.js View on Github external
user_id =>
    Future.node(done => client.post('blocks/destroy', { user_id }, done)).mapRej(
      err => new Error(`error on ${user_id} ${err.message}`),
    );
github arrterian / nix-env-selector / src / actions.ts View on Github external
.chain(totalEnvCount =>
          totalEnvCount > 0
            ? node(done =>
              vscode.commands
                .executeCommand(Command.SELECT_ENV_DIALOG)
                .then(_ => done(null, true), err => done(err))
            )
              .map(some)
            : of(none)
        );
github haskellcamargo / js-to-advpl / src / cli.js View on Github external
const readFile = file => Future.node(fs.readFile(file, 'utf-8', _))
github fluture-js / momi / examples / bootstrap / bootstrappers.js View on Github external
exports.httpServerBootstrapper = App.do(function*(next) {
  log('Connecting HTTP server');
  const state = yield Middleware.get;
  const mergeState = next => Middleware.modify(req => merge(state, {req})).chain(K(next));
  const app = B(mergeState, require('./app'));
  const connections = new Set;
  const server = App.mount(app, 3000);
  server.on('connection', connection => {
    connection.once('close', _ => connections.delete(connection));
    connections.add(connection);
  });
  log('Connected HTTP server');
  const res = yield next;
  log('Disconnecting HTTP server');
  yield Middleware.lift(Future.node(done => {
    connections.forEach(connection => connection.destroy());
    server.close(done);
  }));
  log('Disconnected HTTP server');
  return res;
});
github fluture-js / momi / examples / bootstrap / app.js View on Github external
.use(App.do(function*(next) {
  const mysqlPool = yield getService('mysqlPool');
  const connection = yield Middleware.lift(Future.node(done => mysqlPool.getConnection(done)));
  yield putService('connection', connection);
  const res = yield next;
  connection.release();
  return res;
}))