Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zackthehuman/broccoli-json-transform
Broccoli plugin that allows for JSON files to be modified by using a transform
https://github.com/zackthehuman/broccoli-json-transform
Last synced: 17 days ago
JSON representation
Broccoli plugin that allows for JSON files to be modified by using a transform
- Host: GitHub
- URL: https://github.com/zackthehuman/broccoli-json-transform
- Owner: zackthehuman
- Created: 2017-02-12T02:53:26.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-01-10T06:37:54.000Z (almost 3 years ago)
- Last Synced: 2024-10-03T11:46:18.850Z (about 1 month ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# broccoli-json-transform
Broccoli plugin that allows for JSON files to be modified by using a transform.## Installation
```bash
npm install --save-dev broccoli-json-transform
```## Usage
```js
var JsonTransform = require('broccoli-json-transform');var tranformedJson = new JsonTransform(inputNode, options);
```* **`inputNode`**: A broccoli node
* **`options`**: A hash of options
### Options
* `transform`: The function used to transform the JSON content. Should return
an object.* `space`: Optional. String or number. Used when stringifying the JSON.
### Example
If this is your `example.json`:
```js
{
"foo": "bar"
}
```And this is your build pipeline:
```js
var JsonTransform = require('broccoli-json-transform');function capitalizeKeys(obj) {
var result = {};
var keys = Object.keys(obj);for(var i = 0; i < keys.length; ++i) {
var key = keys[i];
result[key.toUpperCase()] = obj[key];
}return result;
}var tranformedJson = new JsonTransform(inputNode, { transform: capitalizeKeys });
```Then the output `example.json` will look like this:
```js
{
"FOO": "bar"
}
```## Contributing
Clone this repo and run the tests like so:
```
npm install
npm test
```