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 🙏

© 2024 – Pkg Stats / Ryan Hefner

write-debug-varible

v1.0.8

Published

In vscode debug mode, save variables of any type to the JSON file

Downloads

21

Readme

背景:

最近在负责一个爬虫项目,在爬完一页数据保存前 debug查看数组中的数据,有时需要再优化,有时发现数据结构需要再处理一下。 难道改完代码再爬一遍?如果能保存当前这个数组到一个JSON文件中,下次直接require这个JSON,岂不是完美? 最初的解决方案是 在调试控制台使用JSON.stringfy(dataList),将结果复制到js文件中,并把它赋值给一个变量,在执行JSON.parse(varible)却报错了。 很显然,JSON.stringfy()函数并不是完美的解决方案。 Tips:如果您还不知道vscode编辑器如何debug JavaScript代码,请先使用搜索引擎搜索vscode debug JavaScript。 众所周知,在debug 断点时 调试控制台是可以执行代码的,也可以输入程序运行中的变量来看到它的值。 Alt text

描述:

在debug断点时,可以将任何类型的变量,输出到指定路径的JSON文件中

Web服务中引入:

Tips:下面两行代码推荐放在入口文件(app.js 或 index.js)或是声明global变量的文件中。

const { saveVarible } = require('write-debug-varible'); global.saveVarible = saveVarible;

单JS文件中引入:

const { saveVarible } = require('write-debug-varible');

如何调用:

saveVarible("./file.json", varible);   // 该行无论是放到代码里 还是 debug断点的时候使用调试控制台执行都可以 即可在当前项目中看到生成的JSON文件