JSPM

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

Utility to get the source of a value

Package Exports

  • unist-util-source

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-source) 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-source Build Status Coverage Status

Unist utility to get the source of a Node or Location.

Installation

npm:

npm install unist-util-source

Usage

var remark = require('remark');
var source = require('./');

remark()
  .use(function () {
    return transformer;
    function transformer(tree, file) {
      var list = tree.children[0].children[0];
      console.log(source(list, file));
    }
  })
  .process('> + **[Hello](./example)**\n> world.');

Yields:

+ **[Hello](./example)**
world.

API

source(value, doc)

Parameters
  • value (Node or Location) — Value to get.
  • doc (VFile or string) — Document in which value exists.
Returns

string? — Source of value in file, if available.

License

MIT © Titus Wormer