Socket
Socket
Sign inDemoInstall

unist-util-remove-position

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unist-util-remove-position - npm Package Compare versions

Comparing version 3.0.0 to 4.0.0

index.d.ts

51

index.js

@@ -1,18 +0,41 @@

'use strict'
/**
* @typedef {import('unist').Node} Node
* @typedef {Node & {position: undefined}} NodeWithUndefinedPosition
* @typedef {Omit<Node, 'position'>} NodeWithoutPosition
*/
var visit = require('unist-util-visit')
import {visit} from 'unist-util-visit'
module.exports = removePosition
export const removePosition =
/**
* @type {(
* ((tree: Node, force?: false) => NodeWithUndefinedPosition) &
* ((tree: Node, force: true) => NodeWithoutPosition)
* )}
*/
(
/**
* Utility to remove positions from a tree
*
* @param {Node} node the unist tree
* @param {boolean} [force=false] if `force` is given, uses `delete`, otherwise, sets positions to `undefined`.
* @returns {NodeWithUndefinedPosition}
*/
function (node, force) {
visit(node, remove)
function removePosition(node, force) {
visit(node, force ? hard : soft)
return node
}
// @ts-ignore hush TS, we know what we’re doing.
return node
function hard(node) {
delete node.position
}
function soft(node) {
node.position = undefined
}
/**
* @param {Node} node the unist tree
*/
function remove(node) {
if (force) {
delete node.position
} else {
node.position = undefined
}
}
}
)
{
"name": "unist-util-remove-position",
"version": "3.0.0",
"version": "4.0.0",
"description": "unist utility to remove positions from a tree",

@@ -28,32 +28,36 @@ "license": "MIT",

],
"sideEffects": false,
"type": "module",
"main": "index.js",
"types": "index.d.ts",
"files": [
"index.js",
"types/index.d.ts"
"index.d.ts",
"index.js"
],
"types": "types/index.d.ts",
"dependencies": {
"unist-util-visit": "^2.0.0"
"@types/unist": "^2.0.0",
"unist-util-visit": "^3.0.0"
},
"devDependencies": {
"browserify": "^16.0.0",
"dtslint": "^3.0.0",
"nyc": "^15.0.0",
"@types/tape": "^4.0.0",
"c8": "^7.0.0",
"prettier": "^2.0.0",
"remark": "^12.0.0",
"remark-cli": "^8.0.0",
"remark-preset-wooorm": "^7.0.0",
"remark": "^13.0.0",
"remark-cli": "^9.0.0",
"remark-preset-wooorm": "^8.0.0",
"rimraf": "^3.0.0",
"tape": "^5.0.0",
"tinyify": "^2.0.0",
"unist-builder": "^2.0.0",
"xo": "^0.32.0"
"tsd": "^0.14.0",
"type-coverage": "^2.0.0",
"typescript": "^4.0.0",
"unist-builder": "^3.0.0",
"xo": "^0.38.0"
},
"scripts": {
"format": "remark . -qfo && prettier . --write && xo --fix",
"build-bundle": "browserify . -s unistUtilRemovePosition > unist-util-remove-position.js",
"build-mangle": "browserify . -s unistUtilRemovePosition -p tinyify > unist-util-remove-position.min.js",
"build": "npm run build-bundle && npm run build-mangle",
"test-types": "dtslint types",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test.js",
"test": "npm run format && npm run build && npm run test-coverage && npm run test-types"
"prepack": "npm run build && npm run format",
"build": "rimraf \"*.d.ts\" && tsc && tsd && type-coverage",
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"test-api": "node test.js",
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
"test": "npm run build && npm run format && npm run test-coverage"
},

@@ -70,13 +74,7 @@ "prettier": {

"prettier": true,
"esnext": false,
"ignores": [
"types/"
]
"rules": {
"no-var": "off",
"prefer-arrow-callback": "off"
}
},
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
},
"remarkConfig": {

@@ -86,3 +84,8 @@ "plugins": [

]
},
"typeCoverage": {
"atLeast": 100,
"detail": true,
"strict": true
}
}

@@ -15,2 +15,5 @@ # unist-util-remove-position

This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
Node 12+ is needed to use it and it must be `import`ed instead of `require`d.
[npm][]:

@@ -25,4 +28,4 @@

```js
var remark = require('remark')
var removePosition = require('unist-util-remove-position')
import remark from 'remark'
import {removePosition} from 'unist-util-remove-position'

@@ -60,2 +63,5 @@ var tree = remark().parse('Some _emphasis_, **importance**, and `code`.')

This package exports the following identifiers: `removePosition`.
There is no default export.
### `removePosition(node[, force])`

@@ -86,5 +92,5 @@

[build-badge]: https://img.shields.io/travis/syntax-tree/unist-util-remove-position.svg
[build-badge]: https://github.com/syntax-tree/unist-util-remove-position/workflows/main/badge.svg
[build]: https://travis-ci.org/syntax-tree/unist-util-remove-position
[build]: https://github.com/syntax-tree/unist-util-remove-position/actions

@@ -109,5 +115,5 @@ [coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/unist-util-remove-position.svg

[chat-badge]: https://img.shields.io/badge/chat-spectrum-7b16ff.svg
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
[chat]: https://spectrum.chat/unified/syntax-tree
[chat]: https://github.com/syntax-tree/unist/discussions

@@ -114,0 +120,0 @@ [npm]: https://docs.npmjs.com/cli/install

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc