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

scanes

v1.0.1

Published

一个用于检测 JavaScript 代码中 ES5+ 语法特征的命令行工具。

Downloads

6

Readme

scanes

一个用于检测 JavaScript 代码中 ES5+ 语法特征的命令行工具。

工具背景

在前端项目中,我们经常需要确保代码的兼容性,特别是当项目需要支持特定的 JavaScript 版本时。 目前发现较多的第三方npm包的产物存在ES5版本以上的产物,在项目构建时又会被忽略,因此在项目中使用时,需要将最终产物进行扫描,确保最终代码的兼容性。

这个工具可以帮助你:

  • 检测代码中使用的现代 JavaScript 特性
  • 识别可能导致兼容性问题的语法
  • 确保代码符合目标环境的 JavaScript 版本要求

功能特点

  • 支持检测 ES5 到 ES2022 的语法特征
  • 可以指定目标 ES 版本,检测更高版本的语法使用情况
  • 提供详细的代码位置和语法说明
  • 支持输出检测日志到文件

安装

npm install -g scanes

使用方法

基本用法

scanes [目录] [选项]

npx 临时使用:

npx scanes [目录] -e [ES版本]  

命令行选项

  • -v, --version: 显示版本号

  • -h, --help: 显示帮助信息

  • [directory]: 要检测的目录,默认为当前目录 "./"

  • -e, --es <version>: 指定要检测的最低需兼容的 ES 版本(如:ES5、ES2015、ES2016 等),默认为 ES2015。 如果要求兼容到更低的ES5,需指定ES5(也就是ES6及以后的语法会被检测出来)。

  • -o, --output <file>: 指定日志输出文件,默认为当前目录下的 <scanes_logs/es_check_[版本]_[时间戳].log>

示例

  1. 检测当前目录下的所有 JS 文件中的 ES2015+ 特性:
scanes
  1. 检测指定目录下的 ES2017+ 特性:
scanes ./dist -e ES2017
  1. 检测并将结果保存到日志文件:
scanes ./dist -e ES2016 -o scan-result.log

支持的语法特征

工具可以检测以下特征:

ES2015 (ES6)

  • 箭头函数 (() => {})
  • let/const 声明
  • 模板字符串 (string ${expr})
  • 解构赋值 ({a} = obj, [b] = arr)
  • 默认参数 (function foo(a = 1) {})
  • 剩余参数 (function foo(...args) {})
  • 数组展开运算符 ([...arr])
  • 类声明 (class A {})
  • ES 模块导入 (import x from 'module')
  • ES 模块导出 (export default, export {})

ES2016

  • 指数运算符 (2 ** 3)

ES2017

  • async/await
  • 函数参数尾逗号
  • SharedArrayBuffer
  • Atomics

ES2018

  • 异步生成器 (async function* gen() {})
  • 对象展开运算符 ({...obj})
  • 正则表达式后行断言 (?<=pattern)
  • 正则表达式命名捕获组 (?pattern)
  • 正则表达式 Unicode 转义

ES2019

  • 私有类方法 (#method)
  • 私有类属性 (#property)

ES2020

  • 可选链操作符 (obj?.prop)
  • 空值合并操作符 (??)
  • BigInt
  • 可选链函数调用 (func?.())
  • 动态导入 (import())

ES2021

  • 数字分隔符 (1_000_000)

ES2022

  • 类字段 (class A { x = 1 })

每个特征检测都会提供:

  • 特征名称和所属 ES 版本
  • 使用该特征的代码片段
  • 代码在文件中的具体位置(行号)

注意事项

  1. 工具会递归检测指定目录下的所有 .js 文件
  2. 日志文件默认保存在当前执行命令目录下
  3. 文件名默认格式为 es_check_[版本]_[时间戳].log

支持的 ES 版本

  • ES5 (2009)
  • ES2015/ES6 (2015)
  • ES2016
  • ES2017
  • ES2018
  • ES2019
  • ES2020
  • ES2021
  • ES2022