diff options
Diffstat (limited to 'tools/eslint/node_modules/unist-util-remove-position/index.js')
-rw-r--r-- | tools/eslint/node_modules/unist-util-remove-position/index.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tools/eslint/node_modules/unist-util-remove-position/index.js b/tools/eslint/node_modules/unist-util-remove-position/index.js new file mode 100644 index 0000000000..1e1cb81ec2 --- /dev/null +++ b/tools/eslint/node_modules/unist-util-remove-position/index.js @@ -0,0 +1,42 @@ +/** + * @author Titus Wormer + * @copyright 2016 Titus Wormer + * @license MIT + * @module unist:util:remove-position + * @fileoverview Remove `position`s from a unist tree. + */ + +'use strict'; + +/* eslint-env commonjs */ + +/* Dependencies. */ +var visit = require('unist-util-visit'); + +/* Expose. */ +module.exports = removePosition; + +/** + * Remove `position`s from `tree`. + * + * @param {Node} tree - Node. + * @return {Node} - Node without `position`s. + */ +function removePosition(node, force) { + visit(node, force ? hard : soft); + return node; +} + +/** + * Delete `position`. + */ +function hard(node) { + delete node.position; +} + +/** + * Remove `position` softly. + */ +function soft(node) { + node.position = undefined; +} |