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

omni-config

v1.0.0

Published

config system to use everywhere

Readme

ConfigPool

读写配置文件的类

安装

npm i config-pool -S

使用

创建新的配置文件

const ConfigPool = require('config-pool')

// 创建eslint配置的配置文件池
const eslintConfig = new ConfigPool({
js: ['.eslintrc.js'],
json: ['.eslintrc', '.eslintrc.json'],
yaml: ['.eslintrc.yaml', '.eslintrc.yml']
})

// 需要写入的文件信息
  const eslintObj = {
    rules: {
      quotes: 2
    }
  }


// 输出.eslintrc.js文件名和内容
const {filename, content} = eslintConfig.transform(eslintObj)

即可得到一个配置文件名和内容

console.log(filename)
// 输出.eslintrc.js

console.log(content)
/**
*  module.export = {
*    rules:{
*      quotes: 2
*    }
*  }
**/

对已存在的配置文件进行改写:

假如目录已有配置文件 babel.config.js ,文件所在路径为config_path/下

配置文件内容为

module.exports = {
  presets: ['env']
}

现在新输入一个对象,想合并到babel.config.js上

const updateBabelObj = {
  presets: ["latest-minimal"]
}

可以通过以下操作实现

const ConfigPool = require('../lib/ConfigPool')
const fs = require('fs')
const path = require('path')

const filename = 'babel.config.js'
const context = path.join(__dirname, 'config_path')
const content = fs.readFileSync(path.join(context,filename),'utf-8')

//创建文件映射
let fileData = {}
fileData[filename] = content

// babel配置文件实例化
const babelConfig = new ConfigPool({
  js: ['babel.config.js'],
  json: ['.babelrc']
})

// 想要写入babel配置文件的信息
const updateBabelObj = {
  presets: ["latest-minimal"]
}

const res = babelConfig.transform(updateBabelObj,context,fileData)

console.log('filename:',res.filename)
console.log('\ncontent:')
console.log(res.content)

如果你想改写掉babel.config.js,只需要使用fs.writeFile覆盖原文件即可。