
Security News
/Research
Popular node-ipc npm Package Infected with Credential Stealer
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.
@0bdx/semi-parser
Advanced tools
A collection of tools for roughly (but quickly) parsing CSS, HTML and JavaScript
A collection of tools for roughly (but quickly) parsing CSS, HTML and JavaScript.
∅ Version: 0.0.6
∅ NPM: https://www.npmjs.com/package/@0bdx/semi-parser
∅ Repo: https://github.com/0bdx/semi-parser
∅ Homepage: https://0bdx.com/semi-parser
@TODO add an overview
npm i @0bdx/semi-parser
Require an LTS Node version (v14.0.0+).
@TODO add the redactJs() description
import { equal } from 'assert';
import { redactJs } from '@0bdx/semi-parser';
// In this JavaScript source code, we'd like to replace the identifier
// `foo` with `ok`, without changing the comment, or the string 'foo',
const source = `let foo = 'foo'; console.log(foo); // displays "foo"`;
console.log(`source:\n ${source}`);
// Define a simple regular expression which finds "foo" multiple times.
// The `g` flag makes exec() search repeatedly - tinyurl.com/mr2puud2
const rx = /foo/g;
// "foo" appears four times in `source`, ending at 7, 14, 32 and 51.
const endPositions = [];
while (rx.exec(source)) endPositions.push(rx.lastIndex);
equal(endPositions.join(), '7,14,32,51');
// Fill the string with dashes, and replace the comment with spaces.
const result = redactJs(source); // no 2nd argument, so default options
equal(result, "let foo = '---'; console.log(foo); ");
// "foo" only appears twice in `result`, ending at positions 7 and 32.
// Fill an array with the parts of `source` which do not contain "foo".
let parts = [], from = 0;
while (rx.exec(result)) {
const endPos = rx.lastIndex;
parts.push(source.slice(from, endPos - 3)); // 'foo' length is 3
from = endPos;
}
parts.push(source.slice(from)); // the part after the final "foo"
// Join the parts into a string, with 'ok' placed between each part.
const replaced = parts.join('ok');
equal(replaced, `let ok = 'foo'; console.log(ok); // displays "foo"`);
console.log(`replaced:\n ${replaced}`);
You can find the redactJs() example in the
src/redact-js/ directory, and run it using:
npm run example-1
git --version # should be 'git version 2.20.1' or greaternode --version # should be 'v14.0.0' or greatertsc --version # should be 'Version 4.9.4' or greatertsserver to highlight errors in src/ JavaScript filestsc is needed to generate the semi-parser.d.ts type declarationcode --version # should be '1.74.3' or greaterjeremyljackson.vs-docblock
extension.dnamsons.kimbie-dark-plus
theme.Clone the repository, and cd into it.
git clone git@github.com:0bdx/semi-parser.git && cd semi-parser
Install Rollup, the only dependency.
npm i
Rollup 3.10.1 adds 2 packages, 2.5 MB, 29 items.
Open semi-parser in VS Code.
code .
Run all tests on the in-development source code:
npm test
Run each example, one by one:
npm run example:1
npm run example:2
Or run all the examples:
npm run examples
Build semi-parser.js and semi-parser.d.ts:
npm run build:production
npm run build:typings
Run all tests on the built semi-parser.js file:
npm run preflight:test
Check that semi-parser.js uses all types correctly:
npm run preflight:types
Or run all the build and preflight steps in one line, eg before committing:
npm run build && npm run preflight
Display what will be published:
npm publish --dry-run
Publish to npmjs.com/package/@0bdx/semi-parser:
npm publish
FAQs
A collection of tools for roughly (but quickly) parsing CSS, HTML and JavaScript
We found that @0bdx/semi-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.

Security News
TeamPCP and BreachForums are promoting a Shai-Hulud supply chain attack contest with a $1,000 prize for the biggest package compromise.

Security News
Packagist urges PHP projects to update Composer after a GitHub token format change exposed some GitHub Actions tokens in CI logs.