npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@winner-fed/js-obfuscator

v1.0.0

Published

混淆指定 JS 文件,支持 CLI 与 API

Downloads

23

Readme

@winner/js-obfuscator

混淆指定 JavaScript 文件,支持 CLI 与 API。基于内置的 lib/obfuscator.js(javascript-obfuscator)。

要求:Node.js >= 14

安装

npm install @winner/js-obfuscator

本地开发可在本目录执行:

npm link

CLI

js-obfuscator <文件> [选项]

| 参数 / 选项 | 说明 | | --- | --- | | <文件> | 待混淆的 JS 文件路径 | | -o, --output <路径> | 输出路径;省略则覆盖原文件 | | -h, --help | 显示帮助 |

示例:

# 覆盖原文件
js-obfuscator dist/app.js

# 输出到新文件
js-obfuscator src/config.js -o dist/config.js

# 不安装,直接跑
node bin/cli.js src/config.js -o dist/config.js

API

const {
  obfuscate,
  obfuscateFile,
  DEFAULT_OPTIONS,
  JavaScriptObfuscator
} = require('@winner/js-obfuscator')

obfuscate(sourceCode, options?)

混淆源码字符串,返回混淆后的代码。

const code = obfuscate('var x = 1; console.log(x);')

obfuscateFile(inputPath, options?)

混淆文件并写入磁盘。

| 字段 | 类型 | 默认 | 说明 | | --- | --- | --- | --- | | output | string | 原路径 | 输出路径,省略则覆盖原文件 | | write | boolean | true | 是否写入文件 | | 其余字段 | object | — | 传给混淆引擎,与默认配置合并 |

返回值:{ input, output, code }

// 覆盖原文件
obfuscateFile('dist/app.js')

// 写到新文件
const result = obfuscateFile('src/config.js', {
  output: 'dist/config.js'
})
console.log(result.output)

// 只拿混淆结果,不写盘
const { code } = obfuscateFile('src/a.js', { write: false })

自定义选项

传入的选项会与 DEFAULT_OPTIONS 合并:

obfuscate(sourceCode, {
  compact: true,
  selfDefending: false
})

obfuscateFile('app.js', {
  output: 'app.obf.js',
  controlFlowFlattening: false
})

默认混淆配置

{
  compact: true,
  controlFlowFlattening: true,
  controlFlowFlatteningThreshold: 0.75,
  deadCodeInjection: true,
  deadCodeInjectionThreshold: 0.5,
  numbersToExpressions: true,
  simplify: true,
  selfDefending: true,
  shuffleStringArray: true,
  splitStrings: true,
  stringArrayThreshold: 0.75,
  unicodeEscapeSequence: true
}

完整选项说明见 javascript-obfuscator。

目录结构

obfuscator/
├── bin/cli.js          # CLI 入口
├── index.js            # API 入口
├── lib/obfuscator.js   # 混淆引擎
└── package.json