Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Changelog
v2.1.2
flat
to v6 and inline (38cebbb)Readme
Read/Write RC configs couldn't be easier!
Install dependencies:
# ✨ Auto-detect
npx nypm install rc9
# npm
npm install rc9
# yarn
yarn add rc9
# pnpm
pnpm install rc9
# bun
bun install rc9
Import utils:
ESM (Node.js, Bun)
import {
defaults,
parse,
parseFile,
read,
readUser,
serialize,
write,
writeUser,
update,
updateUser,
} from "rc9";
CommonJS (Legacy Node.js)
const {
defaults,
parse,
parseFile,
read,
readUser,
serialize,
write,
writeUser,
update,
updateUser,
} = require("rc9");
.conf
:
db.username=username
db.password=multi word password
db.enabled=true
Update config:
update({ 'db.enabled': false }) // or update(..., { name: '.conf' })
Push to an array:
update({ 'modules[]': 'test' })
Read/Write config:
const config = read() // or read('.conf')
// config = {
// db: {
// username: 'username',
// password: 'multi word password',
// enabled: true
// }
// }
config.enabled = false
write(config) // or write(config, '.conf')
User Config:
It is common to keep config in user home directory (MacOS: /Users/{name}
, Linux: /home/{name}
, Windows: C:\users\{name}
)
you can use readUser
/writeuser
/updateUser
shortcuts to quickly do this:
writeUser({ token: 123 }, '.zoorc') // Will be saved in {home}/.zoorc
const conf = readUser('.zoorc') // { token: 123 }
RC uses flat to automatically flat/unflat when writing and reading rcfile.
It means that you can use .
for keys to define objects. Some examples:
hello.world = true
<=> { hello: { world: true }
test.0 = A
<=> tags: [ 'A' ]
Note: If you use keys that can override like x=
and x.y=
, you can disable this feature by passing flat: true
option.
Tip: You can use keys ending with []
to push to an array like test[]=A
RC uses destr to convert values into native javascript values.
So reading count=123
results { count: 123 }
(instead of { count: "123" }
) if you want to preserve strings as is, can use count="123"
.
const defaults: RCOptions;
function parse(contents: string, options?: RCOptions): RC
function parseFile(path: string, options?: RCOptions): RC
function read(options?: RCOptions | string): RC;
function readUser(options?: RCOptions | string): RC;
function serialize(config: RC): string;
function write(config: RC, options?: RCOptions | string): void;
function writeUser(config: RC, options?: RCOptions | string): void;
function update(config: RC, options?: RCOptions | string): RC;
function updateUser(config: RC, options?: RCOptions | string): RC;
Types:
type RC = Record<string, any>;
interface RCOptions {
name?: string;
dir?: string;
flat?: boolean;
}
Defaults:
{
name: '.conf',
dir: process.cwd(),
flat: false
}
Be the first one to guess 🐇
FAQs
Read/Write config couldn't be easier!
The npm package rc9 receives a total of 793,942 weekly downloads. As such, rc9 popularity was classified as popular.
We found that rc9 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.