Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alan-agius4/speedy-json-extends
Extend a JSON file with one or many existing files
https://github.com/alan-agius4/speedy-json-extends
extend extendable extends json json-files node nodejs utility
Last synced: 4 days ago
JSON representation
Extend a JSON file with one or many existing files
- Host: GitHub
- URL: https://github.com/alan-agius4/speedy-json-extends
- Owner: alan-agius4
- Created: 2017-04-01T14:50:04.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-07-28T13:31:41.000Z (3 months ago)
- Last Synced: 2024-10-05T07:41:06.978Z (about 1 month ago)
- Topics: extend, extendable, extends, json, json-files, node, nodejs, utility
- Language: TypeScript
- Size: 30.3 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# @speedy/json-extends
[![CircleCI](https://circleci.com/gh/alan-agius4/speedy-json-extends.svg?style=shield)](https://circleci.com/gh/alan-agius4/speedy-json-extends)
[![npm version](https://img.shields.io/npm/v/@speedy/json-extends.svg)](https://www.npmjs.com/package/@speedy/json-extends)
[![Dependency Status](https://img.shields.io/david/alan-agius4/speedy-json-extends.svg?style=flat-square)](https://david-dm.org/alan-agius4/speedy-json-extends)
[![devDependency Status](https://img.shields.io/david/dev/alan-agius4/speedy-json-extends.svg?style=flat-square)](https://david-dm.org/alan-agius4/speedy-json-extends?type=dev)Extend a JSON file with one or many existing files.
### Installation
```core
npm install @speedy/json-extends --save
```### Usage
#### json.read(filePath, [namedExtends]) ⇒ `Promise`
Retrieve a JSON file. Supports `extends` with one or many existing JSON files.Extends supports also Named Extends paths, as shown in the example.
| Param | Type | Required | Description |
|--------------|---------------------------|----------|------------------------------------------|
| filePath | `string` | true | path to a JSON file. |
| namedExtends | `{[id: string]: string }` | false | A key value pair of named extends paths |TypeScript
```ts
import { json } from "@speedy/json-extends";const named = {
"@speedy/commit-msg-hook:latest": "./node_modules/config/config.json"
};json.read("local-config.json", named)
.then(content => {
// json content
});
```JSON file
```json
{
"extends": [
"@speedy/commit-msg-hook:latest",
"./local/config.json"
],
"rules": {
"no-dash": true
}
}
```#### json.readSync(filePath, [namedExtends]) ⇒ `T`
Synchronous version of `json.read()`.TypeScript
```ts
import { json } from "@speedy/json-extends";const named = {
"@speedy/commit-msg-hook:latest": "./node_modules/config/config.json"
};const content = json.readSync("local-config.json", named);
```