utility to remove positions from a tree
Installations
npm install unist-util-remove-position
Developer
Developer Guide
Module System
ESM
Min. Node Version
Typescript Support
Yes
Node Version
20.0.0
NPM Version
9.7.2
Statistics
12 Stars
103 Commits
2 Forks
9 Watching
1 Branches
11 Contributors
Updated on 22 Jul 2024
Languages
JavaScript (90.59%)
TypeScript (9.41%)
Total Downloads
Cumulative downloads
Total Downloads
1,239,234,720
Last day
-0.9%
941,263
Compared to previous day
Last week
4.2%
5,028,618
Compared to previous week
Last month
10.2%
20,960,457
Compared to previous month
Last year
-13.1%
247,968,130
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
unist-util-remove-position
unist utility to remove positional info from a tree.
Contents
What is this?
This is a small utility that helps you remove the position
field from nodes in
a unist tree.
When should I use this?
Often, positional info is the whole reason, or an important reason, for using
ASTs.
Sometimes, especially when comparing trees, or when inserting one tree into
another, the positional info is at best useless and at worst harmful.
In those cases, you can use this utility to remove position
fields from a
tree.
You might find the utility unist-util-position
useful to instead get clean position info from a tree, or
unist-util-generated
useful to check whether a node is
considered to be generated (not in the original input file).
You might also enjoy
unist-util-stringify-position
when you want
to display positional info to users.
Install
This package is ESM only. In Node.js (version 16+), install with npm:
1npm install unist-util-remove-position
In Deno with esm.sh
:
1import {removePosition} from 'https://esm.sh/unist-util-remove-position@5'
In browsers with esm.sh
:
1<script type="module"> 2 import {removePosition} from 'https://esm.sh/unist-util-remove-position@5?bundle' 3</script>
Use
1import {fromMarkdown} from 'mdast-util-from-markdown' 2import {removePosition} from 'unist-util-remove-position' 3 4const tree = fromMarkdown('Some _emphasis_, **importance**, and `code`.') 5 6removePosition(tree, {force: true}) 7 8console.dir(tree, {depth: null})
Yields:
1{ 2 type: 'root', 3 children: [ 4 { 5 type: 'paragraph', 6 children: [ 7 {type: 'text', value: 'Some '}, 8 {type: 'emphasis', children: [{type: 'text', value: 'emphasis'}]}, 9 {type: 'text', value: ', '}, 10 {type: 'strong', children: [{type: 'text', value: 'importance'}]}, 11 {type: 'text', value: ', and '}, 12 {type: 'inlineCode', value: 'code'}, 13 {type: 'text', value: '.'} 14 ] 15 } 16 ] 17}
API
This package exports the identifier removePosition
.
There is no default export.
removePosition(node[, options])
Remove the position
field from a tree.
Parameters
Returns
Nothing (undefined
).
Options
Configuration (TypeScript type).
Fields
force
(boolean
, default:false
) — whether to usedelete
to removeposition
fields, the default is to set them toundefined
Types
This package is fully typed with TypeScript.
It exports the additional type Options
.
Compatibility
Projects maintained by the unified collective are compatible with maintained versions of Node.js.
When we cut a new major release, we drop support for unmaintained versions of
Node.
This means we try to keep the current release line,
unist-util-remove-position@^5
, compatible with Node.js 16.
Contribute
See contributing.md
in syntax-tree/.github
for
ways to get started.
See support.md
for ways to get help.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.
License
MIT © Titus Wormer
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: license:0
- Info: FSF or OSI recognized license: MIT License: license:0
Reason
security policy file detected
Details
- Info: security policy file detected: github.com/syntax-tree/.github/security.md:1
- Info: Found linked content: github.com/syntax-tree/.github/security.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: github.com/syntax-tree/.github/security.md:1
- Info: Found text in security policy: github.com/syntax-tree/.github/security.md:1
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/bb.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/syntax-tree/unist-util-remove-position/bb.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/syntax-tree/unist-util-remove-position/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/syntax-tree/unist-util-remove-position/main.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/syntax-tree/unist-util-remove-position/main.yml/main?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/main.yml:15
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 third-party GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/bb.yml:1
- Warn: no topLevel permission defined: .github/workflows/main.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
Project has not signed or included provenance with any releases.
Details
- Warn: release artifact 3.0.0 not signed: https://api.github.com/repos/syntax-tree/unist-util-remove-position/releases/28557291
- Warn: release artifact 3.0.0 does not have provenance: https://api.github.com/repos/syntax-tree/unist-util-remove-position/releases/28557291
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Score
3.7
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to unist-util-remove-position
unist-util-stringify-position
unist utility to serialize a node, position, or point as a human readable location
unist-util-position
unist utility to get the position of a node
unist-util-position-from-estree
unist utility to get a position from an estree node
unist-util-generated
unist utility to check if a node is generated