How to use the ferrum.pipe 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 / html / parse-frontmatter.js View on Github external
},
      };

      const cnt = block.end - block.start + 1;
      mdast.children.splice(block.start + off, cnt, dat);
      off += -cnt + 1; // cnt removed, 1 inserted
    } else {
      const { warning, source, start } = block;
      const fst = mdast.children[start + off];

      // This also needs to account for settext headings
      // hence the usage of end here, instead of using start
      const { line } = fst.position.end;

      // Source file pretty printing with line numbers
      const sourceref = pipe(
        source.split('\n'),
        zipLeast2(range(line, Infinity)),
        map(([l, no]) => `    ${no} | ${l} `),
        join('\n'),
      );

      const err = new FrontmatterParsingError(`${warning}\n${sourceref}`);
      if (!production()) {
        logger.warn(err);
      }
      logger.debug(err);
    }
  }
};
github adobe / jsonschema2md / lib / readmeBuilder.js View on Github external
return (schemas) => {
    if (readme) {
      console.log('building readme');
      const toplevel = flist(pipe(
        schemas,
        filter(schema => !schema[s.parent]), // remove schemas with a parent
        mapSort(schema => gentitle(schema[s.titles], schema[keyword`type`])),
        map(schema => listItem(paragraph([
          link(`./${schema[s.slug]}.md`, gendescription(schema), [text(gentitle(schema[s.titles], schema[keyword`type`]))]),
          text(' – '),
          inlineCode(schema[keyword`$id`] || '-'),
        ]))),
      ), Array);

      const bytype = type => flist(pipe(
        schemas,
        filter(schema => schema[keyword`type`] === type), // remove schemas without matching type
        filter(schema => !!schema[s.parent]), // keep only schemas with a parent
        mapSort(schema => gentitle(schema[s.titles], schema[keyword`type`])),
        map(schema => listItem(paragraph([
github adobe / jsonschema2md / lib / readmeBuilder.js View on Github external
      const bytype = type => flist(pipe(
        schemas,
        filter(schema => schema[keyword`type`] === type), // remove schemas without matching type
        filter(schema => !!schema[s.parent]), // keep only schemas with a parent
        mapSort(schema => gentitle(schema[s.titles], schema[keyword`type`])),
        map(schema => listItem(paragraph([
          link(`./${schema[s.slug]}.md`, gendescription(schema), [text(gentitle(schema[s.titles], schema[keyword`type`]))]),
          text(' – '),
          inlineCode(`${schema[s.id]}#${schema[s.pointer]}`),
        ]))),
      ), Array);
github adobe / helix-pipeline / src / html / parse-frontmatter.js View on Github external
return warn(null,
        '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);

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