How to use the ferrum.each 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 / test / testFrontmatter.js View on Github external
it(wat, () => {
    const { proc } = procMd(md);
    // Discard position info
    const nodes = flattenTree(proc,
      (node, recurse) => concat([node], recurse(node.children || [])));
    each(nodes, (node) => {
      delete node.position;
    });
    assert.deepStrictEqual(proc.children, yaml.safeLoad(ast));
  });
};
github adobe / helix-pipeline / src / utils / conditional-sections.js View on Github external
function selecttest(context, { request }) {
  const cont = setdefault(context, 'content', { mdast: {} });
  const params = request.params || {};
  const { strain } = params;
  const sections = cont.mdast.children;

  if (!strain || !sections) {
    return;
  }

  const selected = pick(testgroups(sections), strain);
  each(sections, (section) => {
    if (!section.meta || !section.meta.test) {
      return;
    }

    section.meta.hidden = !(section === selected[section.meta.test]);
  });
}
github adobe / helix-pipeline / src / utils / conditional-sections.js View on Github external
function selectstrain(context, { request, logger }) {
  const cont = setdefault(context, 'content', { mdast: {} });
  const params = request.params || {};
  const { strain } = params;
  const sections = cont.mdast.children;

  if (!strain || !sections) {
    return;
  }

  logger.debug(`Filtering sections not intended for strain ${strain}`);
  each(sections, (section) => {
    const meta = setdefault(section, 'meta', {});
    const strainList = type(meta.strain) === Array ? meta.strain : [meta.strain];
    meta.hidden = Boolean(meta.strain && meta.strain !== [] && !strainList.includes(strain));
  });
}
github adobe / helix-pipeline / src / html / get-metadata.js View on Github external
each([yaml, title, intro, image, sectiontype, fallback], (fn) => {
    each(sections, fn);
  });
github adobe / helix-pipeline / src / html / get-metadata.js View on Github external
function getmetadata({ content }, { logger }) {
  const { mdast: { children = [] } } = content;
  let sections = children.filter((node) => node.type === 'section');
  if (!sections.length) {
    sections = [content.mdast];
  }

  logger.debug(`Parsing Markdown Metadata from ${sections.length} sections`);

  each([yaml, title, intro, image, sectiontype, fallback], (fn) => {
    each(sections, fn);
  });

  const img = sections.filter((section) => section.image)[0];
  const titl = sections.filter((section) => section.title)[0];

  content.meta = sections[0].meta;
  content.title = titl ? titl.title : '';
  content.intro = sections[0].intro;
  content.image = img ? img.image : undefined;
}

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