JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 23670
  • Score
    100M100P100Q170858F
  • License MIT

Utility to find nodes before another node

Package Exports

  • unist-util-find-all-before

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (unist-util-find-all-before) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

unist-util-find-all-before Build Status Coverage Status

Unist utility to find nodes before another node.

Installation

npm:

npm install unist-util-find-all-before

Usage

var remark = require('remark');
var findAllBefore = require('unist-util-find-all-before');

var tree = remark().parse('Some _emphasis_, **importance**, and `code`.');
var paragraph = tree.children[0];
var code = paragraph.children[paragraph.children.length - 1];

console.log(findAllBefore(paragraph, code, 'text'));

Yields:

[ { type: 'text', value: ', and ' },
  { type: 'text', value: ', ' },
  { type: 'text', value: 'Some ' } ]

API

findAllBefore(parent, node|index[, test])

Find the first child before index (or node) in parent, that passes test (when given).

Parameters
  • parent (Node) — Context node;
  • node (Node) — Node in parent;
  • index (number, optional) — Position of a node in parent;
  • test (Function, string, or Node, optional) — See unist-util-is.
Returns

Array.<Node> — Child nodes of parent passing test.

License

MIT © Titus Wormer