Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
token-replacer
Advanced tools
A library to replace lines and blocks within text (or files) designated by token comments. Useful for removing example code from a template.
A library to replace lines and blocks within text (or files) designated by token comments (e.g. // @template:car next-line
). Useful for removing example code from a template.
Install using NPM:
$ npm i token-replacer
Replace tokens within a string
import { replaceTokens } from 'token-replacer
const text = `
// @template:car next-line
const car = {}
// @template:house block-start
const house = {
sqFt: 1000,
bedrooms: 3,
}
// @template:house block-end
`
const replacedText = replaceTokens(text, {
car: true,
house: false,
})
console.log(replacedText)
Since car
is set to true, it will be preserved (the token comments will be removed), but house
is false, so it will be removed. The resulting replacedText
will be:
// @template:car next-line
const car = {}
Replace tokens in files (in-place) within a directory (recursive)
import { replaceTokensInFiles } from 'token-replacer
replaceTokensInFiles('./code', {
car: true,
house: false,
})
Replace the line directly after the next-line
comment:
// @template:car next-line
Replace the lines in between a block-start
and block-end
comment:
// @template:house block-start
const house = {
sqFt: 1000,
bedrooms: 3,
}
// @template:house block-end
FAQs
A library to replace lines and blocks within text (or files) designated by token comments. Useful for removing example code from a template.
The npm package token-replacer receives a total of 2 weekly downloads. As such, token-replacer popularity was classified as not popular.
We found that token-replacer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.