How to use the ferrum.enumerate function in ferrum

To help you get started, we’ve selected a few ferrum 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 adobe / helix-pipeline / src / pipeline.js View on Github external
const execFns = async (fns) => {
      for (const [idx, f] of enumerate(fns)) {
        const ident = `#${String(idx).padStart(2, '0')}/${f.alias}`;

        // skip if error and no error handler (or no error and error handler)
        if ((!context.error) === (!!f.errorHandler)) {
          logger.silly(`skip ${ident}`, {
            function: f.alias,
          });
          // eslint-disable-next-line no-continue
          continue;
        }

        try {
          await execTaps(enumerate(this._taps), f.title, idx);
        } catch (e) {
          if (!context.error) {
            context.error = e;
          }
        }
        if (context.error && !f.errorHandler) {
          // eslint-disable-next-line no-continue
          continue;
        }
        try {
          logger.silly(`exec ${ident}`, {
            function: f.alias,
          });
          await f(context, this._action);
        } catch (e) {
          logger.error(`Exception during ${ident}:\n${e.stack}`);
github adobe / helix-pipeline / src / pipeline.js View on Github external
const execFns = async (fns) => {
      for (const [idx, f] of enumerate(fns)) {
        const ident = `#${String(idx).padStart(2, '0')}/${f.alias}`;

        // skip if error and no error handler (or no error and error handler)
        if ((!context.error) === (!!f.errorHandler)) {
          logger.silly(`skip ${ident}`, {
            function: f.alias,
          });
          // eslint-disable-next-line no-continue
          continue;
        }

        try {
          await execTaps(enumerate(this._taps), f.title, idx);
        } catch (e) {
          if (!context.error) {
            context.error = e;
github adobe / helix-pipeline / src / html / parse-frontmatter.js View on Github external
'Found ambigous frontmatter block: Block contains valid yaml, but '
          + `it's data type is ${type(data)} instead of Object.`
          + 'Make sure your yaml blocks contain only key-value pairs at the root level!');
    }

    return {
      type: 'frontmatter',
      payload: data,
      start: fst.idx,
      end: last.idx,
    };
  });

  // Preprocessing
  return pipe(
    enumerate(mdast.children),
    // Find any potential frontmatter starts/ends in the mdast
    /* eslint-disable-next-line no-unused-vars */
    filter(([idx, nod]) => isPotential(nod)),
    // Filter out dom nodes based on their actual text content;
    // this filters out HRs made from other characters or setext
    // headings with more than three dashes...
    //
    // And: Perform some more sophisticated feature extraction on the nodes
    map(([idx, nod]) => {
      const mat = nodeStr(idx).match(re(`(?<=^|\\n)---${hspace}*\\n?$`));
      if (!mat) {
        return null;
      }
      // Offset of the actual separator line (this may deviate from the)
      const offStart = mat.index + start(idx);
      const offEnd = offStart + size(mat[0]);

ferrum

Features from the rust language in javascript: Provides Traits/Type classes & an advanced library for working with sequences/iterators in js.

Apache-2.0
Latest version published 2 years ago

Package Health Score

62 / 100
Full package analysis