New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

searchconfig

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

searchconfig

Get and Merge Configurations

latest
Source
npmnpm
Version
1.0.0-alpha.1
Version published
Maintainers
1
Created
Source

Get & Merge Config

TypeScript (JavaScript) package to get and merge configuration, made for Node.js and Deno.

A lightweight alternative to cosmiconfig, it is easy to use, fully customizable and predictable, and has clear error types that are simple to handle.

For now it's an alpha release and I'll improve the documentation. But it should be usable and there is auto-generated API doc you can read.

npm install searchconfig

Basic Usage:

import { getConfig } from 'searchconfig'
const stra = defaultConfigGetStrategy('packagename')
;(async () => {
  const config = await getConfig(stra)
})()

With YAML:

import { getConfig, registry } from 'searchconfig'
import * as yaml from 'yaml'

registry.addLoader('yaml', yaml.parse)
const stra = defaultConfigGetStrategy('packagename', {
  hasYaml: true,
})
;(async () => {
  const config = await getConfig(stra)
})()

The stra variable, which represents a default config get strategy, looks like this (the previous one take precedence over the next ones):

[
  {
    filename: [
      'package.json',
      '.packagenamerc',
      '.packagenamerc.json',
      '.packagenamerc.yaml',
      '.packagenamerc.yml',
      '.packagenamerc.js',
      '.packagenamerc.mjs',
      '.packagenamerc.cjs',
      'packagename.config.json',
      'packagename.config.yaml',
      'packagename.config.yml',
      'packagename.config.js',
      'packagename.config.mjs',
      'packagename.config.cjs',
    ],
    loader: [null, 'jsonoryaml'], // only set 'jsonoryaml' for the second item which is '.packagenamerc'
    key: ['packagename'], // only set object key 'jsonoryaml' for the first item which is 'package.json'
  },
]

Keywords

config

FAQs

Package last updated on 08 Feb 2021

Did you know?

Socket

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.

Install

Related posts