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

param-pure-default

v1.0.0

Published

精准判断函数参数是用户主动传入,还是使用默认值,解决JS原生无法区分同值默认参数痛点

Readme

param-pure-default

一款轻量 JS 工具库,解决 JavaScript 原生无法区分「同值默认参数」 完美识别:不传参用默认值 / 手动传入和默认值相同的参数

优势

  • 原生 ESM 模块化,适配所有现代前端项目
  • 体积极小,零依赖
  • 使用简洁,无学习成本
  • 支持 Node.js / 浏览器 / Vite / Webpack

安装

npm install param-pure-default

使用示例

import ParamDefaultTrack from 'param-pure-default'

// 新建参数追踪实例
const track = new ParamDefaultTrack()

// 定义函数,绑定默认参数
function showNum(num = track.setDefault(5)) {
  if (track.isDefault()) {
    console.log('当前使用默认值:', num)
  } else {
    console.log('用户手动传入数值:', num)
  }
  // 调用结束重置状态
  track.reset()
}

showNum(10)  // 用户手动传入数值:10
showNum()    // 当前使用默认值:5
showNum(5)   // 用户手动传入数值:5

API 文档

| 方法 | 作用 | | ---- | ---- | | setDefault(value) | 定义函数默认参数,标记默认状态 | | isDefault() | 返回布尔值,判断是否启用默认参数 | | reset() | 重置实例状态,防止多次调用错乱 |

适用场景

  • 函数配置项默认值判断
  • 接口参数可选值校验
  • 工具函数参数优先级判断
  • 表单默认填充逻辑区分

License

MIT © 2026 董翔