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

@qubit-ltd/config

v1.2.6

Published

A JavaScript library providing a global configuration object for Apps.

Readme

@qubit-ltd/config

npm package License English Document CircleCI Coverage Status

@qubit-ltd/config 是一个为应用程序提供全局配置对象的JavaScript库。

安装

使用npm:

npm install @qubit-ltd/config

使用yarn:

yarn add @qubit-ltd/config

使用方法

import config from '@qubit-ltd/config';

// 设置配置
config.set('app.name', 'My App');
config.set('app.version', '1.0.0');
config.set('database.host', 'localhost');
config.set('database.port', 3306);

// 获取配置
const appName = config.get('app.name');         // 'My App'
const dbConfig = config.get('database');        // { host: 'localhost', port: 3306 }
const apiKey = config.get('api.key', 'default'); // 如果api.key不存在,返回'default'

// 检查配置是否存在
const hasAppName = config.has('app.name');      // true
const hasApiKey = config.has('api.key');        // false

// 删除配置
config.remove('app.name');
const appNameAfterRemove = config.has('app.name'); // false

// 合并配置
config.merge({
  app: {
    name: 'New App Name',
    theme: 'dark'
  }
});

// 合并环境变量
// 例如:使用Node.js的环境变量
config.mergeEnv(process.env);
// 或者在Vite项目中使用
// config.mergeEnv(import.meta.env, 'VITE_');

// 清空所有配置
config.clear();

API

config.has(keyPath)

检查指定路径的配置是否存在。

  • keyPath: 字符串,配置的路径,支持点号和数组索引,如'app.name''database.users[0].name'
  • 返回:布尔值,表示配置是否存在。

config.get(keyPath, defaultValue)

获取指定路径的配置值。

  • keyPath: 字符串,配置的路径,支持点号和数组索引。
  • defaultValue: 可选,如果配置不存在时返回的默认值。
  • 返回:配置值,如果不存在且未提供默认值则返回undefined

config.set(keyPath, value)

设置指定路径的配置值。

  • keyPath: 字符串,配置的路径,支持点号和数组索引。
  • value: 要设置的值。

config.remove(keyPath)

删除指定路径的配置。

  • keyPath: 字符串,配置的路径,支持点号和数组索引。

config.clear()

清空所有配置。

config.merge(cfg)

合并配置对象。

  • cfg: 对象,要合并的配置对象。

config.mergeEnv(env, removePrefix)

合并环境变量。

  • env: 对象,包含环境变量的对象,通常是process.envimport.meta.env
  • removePrefix: 可选,字符串,要从环境变量名中移除的前缀。

贡献

如果您发现任何问题或有改进建议,请随时在GitHub仓库开issue或提交pull request。

许可证

@qubit-ltd/config在Apache 2.0许可证下分发。 有关更多详细信息,请参见LICENSE文件。