How to use the ferrum.type 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 / set-surrogate-key.js View on Github external
function key(context, { logger }) {
  const cont = setdefault(context, 'content', {});
  const res = setdefault(context, 'response', {});
  const headers = setdefault(res, 'headers', {});

  // somebody already set a surrogate key
  if (headers['Surrogate-Key'] || !(type(cont.sources) === Array)) {
    logger.debug('Keeping existing Surrogate-Key header');
    return;
  }

  logger.debug('Setting Surrogate-Key header');
  headers['Surrogate-Key'] = join(' ')(map(cont.sources, computeSurrogateKey));
}
github adobe / helix-pipeline / src / html / parse-frontmatter.js View on Github external
} else if (src.match(re(`\\n${hspace}*\\n`)) && fst.idx > 0) {
      return warn(null,
        'Found ambigous frontmatter fence: Block contains empty line! '
          + 'Make sure your mid-document YAML blocks contain no empty lines '
          + 'and your horizontal rules have an empty line before AND after them.');
    }

    const txt = str.slice(fst.offEnd, !last ? undefined : last.offStart);
    let data;
    try {
      data = yaml.safeLoad(txt);
    } catch (e) {
      return warn(e, `Exception ocurred while parsing yaml: ${e}`);
    }

    if (type(data) !== Object) {
      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,
    };
  });
github adobe / helix-pipeline / src / utils / conditional-sections.js View on Github external
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 / parse-frontmatter.js View on Github external
+ 'Make sure your mid-document YAML blocks contain no empty lines '
          + 'and your horizontal rules have an empty line before AND after them.');
    }

    const txt = str.slice(fst.offEnd, !last ? undefined : last.offStart);
    let data;
    try {
      data = yaml.safeLoad(txt);
    } catch (e) {
      return warn(e, `Exception ocurred while parsing yaml: ${e}`);
    }

    if (type(data) !== Object) {
      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,
    };
  });

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