How to use front-async - 3 common examples

To help you get started, we’ve selected a few front-async 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 quentez / talonjs / tests / html_quotations_tests.js View on Github external
return fs.readdir(htmlRepliesPath, (err, files) => {
        if (err)
          return done(err);

        // Iterate on the files we found.
        return async.eachSeries(files, (file, nextFile) => {

          // Read the file.
          return fs.readFile(path.join(htmlRepliesPath, file), "utf-8", (err, html) => {
            if (err)
              return nextFile(err);

            const replyHtml = quotations.extractFromHtml(html).body;
            const replyPlain = utils.htmlToText(replyHtml);

            assert.equal(
              removeWhitespace("Hi. I am fine.\n\nThanks,\nAlex"),
              removeWhitespace(replyPlain));

            return nextFile();
          });
        }, done);
github quentez / talonjs / tests / quotations_tests.js View on Github external
return fs.readdir(standardRepliesPath, function (err, files) {
        if (err)
          return done(err);

        // Iterate on the files we found.
        return async.eachSeries(files, (file, nextFile) => {
          // We're only interested in email files.
          if (file.substr(-4) !== ".eml")
            return nextFile();

          return async.series({

            // Parse the EML file.
            emailText: next => utils.parseEmlText(path.join(standardRepliesPath, file), next),

            // Try and load the reply text for this message.
            replyText: next => utils.tryReadFile(path.join(standardRepliesPath, file.slice(0, -4) + "_reply_text"), next),

            // Compare the results.
            checkText: (next, results) => {
              // Try and extract the reply from the loaded message.
              const extractedText = quotations.extractFromPlain(results.emailText).body;
github quentez / talonjs / tests / quotations_tests.js View on Github external
return async.eachSeries(files, (file, nextFile) => {
          // We're only interested in email files.
          if (file.substr(-4) !== ".eml")
            return nextFile();

          return async.series({

            // Parse the EML file.
            emailText: next => utils.parseEmlText(path.join(standardRepliesPath, file), next),

            // Try and load the reply text for this message.
            replyText: next => utils.tryReadFile(path.join(standardRepliesPath, file.slice(0, -4) + "_reply_text"), next),

            // Compare the results.
            checkText: (next, results) => {
              // Try and extract the reply from the loaded message.
              const extractedText = quotations.extractFromPlain(results.emailText).body;

              // Compare the reply text and the extracted text.
              assert.equal((results.replyText || "Hello").replace(/\r\n/g, "\n").trim(), extractedText);
              return next();
            }

front-async

Higher-order functions and common patterns for asynchronous code

MIT
Latest version published 9 years ago

Package Health Score

60 / 100
Full package analysis

Popular front-async functions