JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 14767512
  • Score
    100M100P100Q218216F
  • License MIT

Load config with ease.

Package Exports

  • joycon

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (joycon) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

joycon

NPM version NPM downloads CircleCI donate chat

Install

yarn add joycon

Usage

const JoyCon = require('joycon')

const joycon = new JoyCon(['package-lock.json', 'yarn.lock'])

joycon.load()
.then(result => {
  // result is {} when files do not exist
  // otherwise { path, data }
})

By default only .js and .json file are parsed, otherwise raw data will be returned, so you can add custom loader to parse them:

const joycon = new JoyCon(['cargo.toml'])

joycon.addLoader({
  test: /\.toml$/,
  load(filepath) {
    return require('toml').parse(filepath)
  }
})

joycon.load()

DOC

API

constructor(files, [options])

files

Type: string[]

The files to search.

options

cwd

Working directory to search files.

stopDir

Directory where the search will stop. By default it's path.parse(cwd).root.

resolve()

Search files and resolve the path of the file we found.

load()

Search files and resolve { path, data } of the file we found.

addLoader(Loader)

interface Loader {
  test: RegExp
  load(filepath: string): any
}

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

joycon © egoist, Released under the MIT License.
Authored and maintained by egoist with help from contributors (list).

github.com/egoist · GitHub @egoist · Twitter @_egoistlily