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

stack-log

v1.0.0

Published

可以打印栈信息的日志

Readme

stack-log

可以打印栈信息的日志函数,移动混合开发必备!!!

简介

断点信息,可以反映函数的调用栈,但是不是所有的场景都适合打断点.console 直接输出的日志,可以反映的简单行数信息,但是部分场景需要结合日志所在函数的调用栈来确定某些调试信息.

偶然间发现,可以用 new Error 记录栈结构,只要能适当处理,去除不必要的栈信息,就可以很好地保持 console 日志的连续性和断点调试时函数调用的明晰性.

这是一个有一点小技巧的工具函数.很简单,很实用!

安装

nodejs 环境

npm i stack-log --save

浏览器环境

下载 lib/stack-log.js 到本地,然后:

<script type="text/javascript" src="path/to/stack-log.js"></script>

使用示例

nodejs 示例

const {log} = require("stack-log")

function funcA (){
  funcB()
}

function funcB(){
  funcC()
}

function funcC(){
  log({k:"v"})
}

funcA()


/* 可能的输出:
{"k":"v"}
    at funcC (/Users/yanfeng/Documents/tmp/stack-test/index.js:12:3)
    at funcB (/Users/yanfeng/Documents/tmp/stack-test/index.js:8:3)
    at funcA (/Users/yanfeng/Documents/tmp/stack-test/index.js:4:3)
    at Object.<anonymous> (/Users/yanfeng/Documents/tmp/stack-test/index.js:15:1)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
*/

浏览器 示例

<script type="text/javascript" src="script/stack-log.js"></script>
<script type="text/javascript">
function funcA (){
  funcB()
}

function funcB(){
  funcC()
}

function funcC(){
  log({k:"v"})
}

funcA()
</script>

可能的输出:

{"k":"v"}
    at funcC (file:///Users/yanfeng/Documents/tmp/index.html:12:3)
    at funcB (file:///Users/yanfeng/Documents/tmp/index.html:8:3)
    at funcA (file:///Users/yanfeng/Documents/tmp/index.html:4:3)
    at file:///Users/yanfeng/Documents/tmp/index.html:15:1