Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
unist-util-source
Advanced tools
unist utility to get the source code of a node or position.
This is a tiny utility that lets you get the source code of a node or position.
This is super tiny utility useful when you want to display the source code of something in a file.
This package is ESM only. In Node.js (version 16+), install with npm:
npm install unist-util-source
In Deno with esm.sh
:
import {source} from 'https://esm.sh/unist-util-source@5'
In browsers with esm.sh
:
<script type="module">
import {source} from 'https://esm.sh/unist-util-source@5?bundle'
</script>
Say our document example.md
contains:
> + **[Hello](./example)**
> world.
…and our module example.js
looks as follows:
import {fromMarkdown} from 'mdast-util-from-markdown'
import {read} from 'to-vfile'
import {source} from 'unist-util-source'
const file = await read('example.md')
const tree = fromMarkdown(String(file))
const strong = tree.children[0].children[0].children[0].children[0].children[0]
console.log(source(file, strong))
…now running node example.js
yields:
**[Hello](./example)**
This package exports the identifier source
.
There is no default export.
source(file[, value])
Get the source of a node or at a position.
Source of value
in doc
, if available (string
or undefined
).
This package is fully typed with TypeScript. It exports no additional types.
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-source@^5
,
compatible with Node.js 16.
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, organisation, or community you agree to abide by its terms.
FAQs
unist utility to get the source of a value
We found that unist-util-source demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.