How to use the iferr.tiferr function in iferr

To help you get started, we’ve selected a few iferr 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 hexojs / hexo-fs / test / index.js View on Github external
it('emptyDir() - callback', callback => {
    const target = join(tmpDir, 'test');

    const checkExistsMap = {
      [join('.hidden', 'a.txt')]: true,
      [join('.hidden', 'b.js')]: true,
      [join('.hidden', 'c', 'd')]: true,
      'e.txt': false,
      'f.js': false,
      '.g': true,
      [join('folder', 'h.txt')]: false,
      [join('folder', 'i.js')]: false,
      [join('folder', '.j')]: true
    };

    createDummyFolder(target, tiferr(callback, () => {
      fs.emptyDir(target, tiferr(callback, files => {
        files.should.have.members([
          'e.txt',
          'f.js',
          join('folder', 'h.txt'),
          join('folder', 'i.js')
        ]);

        return Promise.map(Object.keys(checkExistsMap), path => {
          return fs.exists(join(target, path)).should.become(checkExistsMap[path]);
        }).asCallback(tiferr(callback, () => {
          fs.rmdir(target, callback);
        }));
      }));
    }));
  });
github hexojs / hexo-fs / test / index.js View on Github external
it('mkdirs() - callback', callback => {
    const target = join(tmpDir, 'a', 'b', 'c');

    fs.mkdirs(target, tiferr(callback, () => {
      fs.exists(target, exist => {
        exist.should.be.true;
        fs.rmdir(join(tmpDir, 'a'), callback);
      });
    }));
  });
github hexojs / hexo-fs / test / index.js View on Github external
it('ensurePath() - callback', callback => {
    const target = join(tmpDir, 'test');
    const filenames = ['foo.txt', 'foo-1.txt', 'foo-2.md', 'bar.txt'];

    Promise.map(filenames, path => fs.writeFile(join(target, path))).asCallback(tiferr(callback, () => {
      fs.ensurePath(join(target, 'foo.txt'), tiferr(callback, path => {
        path.should.eql(join(target, 'foo-2.txt'));
        fs.rmdir(target, callback);
      }));
    }));
  });
github hexojs / hexo-fs / test / index.js View on Github external
Promise.map(filenames, path => fs.writeFile(join(target, path))).asCallback(tiferr(callback, () => {
      fs.ensurePath(join(target, 'foo.txt'), tiferr(callback, path => {
        path.should.eql(join(target, 'foo-2.txt'));
        fs.rmdir(target, callback);
      }));
    }));
  });
github hexojs / hexo-fs / test / index.js View on Github external
fs.copyDir(src, dest, tiferr(callback, files => {
        files.should.have.members(finenames);
        fs.rmdir(src, tiferr(callback, () => {
          Promise.map(finenames, path => fs.readFile(join(dest, path))).asCallback(tiferr(callback, result => {
            result.should.eql(['e', 'f', 'h', 'i']);
            fs.rmdir(dest, callback);
          }));
        }));
      }));
    }));
github hexojs / hexo-fs / test / index.js View on Github external
createDummyFolder(target, tiferr(callback, () => {
      fs.listDir(target, tiferr(callback, paths => {
        paths.should.have.members(filenames);
        fs.rmdir(target, callback);
      }));
    }));
  });
github hexojs / hexo-fs / test / index.js View on Github external
createDummyFolder(src, tiferr(callback, () => {
      fs.copyDir(src, dest, tiferr(callback, files => {
        files.should.have.members(finenames);
        fs.rmdir(src, tiferr(callback, () => {
          Promise.map(finenames, path => fs.readFile(join(dest, path))).asCallback(tiferr(callback, result => {
            result.should.eql(['e', 'f', 'h', 'i']);
            fs.rmdir(dest, callback);
          }));
        }));
      }));
    }));
  });
github hexojs / hexo-fs / test / index.js View on Github external
fs.writeFile(src, body, tiferr(callback, () => {
      fs.copyFile(src, dest, tiferr(callback, () => {
        fs.readFile(dest, tiferr(callback, content => {
          content.should.eql(body);

          Promise.all([
            fs.unlink(src),
            fs.rmdir(join(tmpDir, 'a'))
          ]).asCallback(callback);
        }));
      }));
    }));
  });
github hexojs / hexo-fs / test / index.js View on Github external
createDummyFolder(target, tiferr(callback, () => {
      fs.emptyDir(target, tiferr(callback, files => {
        files.should.have.members([
          'e.txt',
          'f.js',
          join('folder', 'h.txt'),
          join('folder', 'i.js')
        ]);

        return Promise.map(Object.keys(checkExistsMap), path => {
          return fs.exists(join(target, path)).should.become(checkExistsMap[path]);
        }).asCallback(tiferr(callback, () => {
          fs.rmdir(target, callback);
        }));
      }));
    }));
  });
github hexojs / hexo-fs / test / index.js View on Github external
fs.writeFile(target, body, tiferr(callback, () => {
      fs.appendFile(target, body2, tiferr(callback, () => {
        fs.readFile(target, tiferr(callback, content => {
          content.should.eql(body + body2);
          fs.rmdir(join(tmpDir, 'a'), callback);
        }));
      }));
    }));
  });

iferr

Higher-order functions for easier error handling

MIT
Latest version published 6 years ago

Package Health Score

65 / 100
Full package analysis

Popular iferr functions