New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

edit-json-file

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

edit-json-file - npm Package Compare versions

Comparing version 1.5.0 to 1.6.0

43

lib/index.js

@@ -117,2 +117,45 @@ "use strict";

/**
* append
* Appends a value/object to a specific path.
* If the path is empty it wil create a list.
*
* @name append
* @function
* @param {String} path The object path.
* @param {Anything} value The value.
* @returns {JsonEditor} The `JsonEditor` instance.
*/
}, {
key: "append",
value: function append(path, value) {
var data = this.get(path);
data = data === undefined ? [] : data;
if (!Array.isArray(data)) throw new Error("The data is not an array!");
data.push(value);
this.set(path, data);
return this;
}
/**
* pop
* Pop an array from a specific path.
*
* @name append
* @function
* @param {String} path The object path.
* @returns {JsonEditor} The `JsonEditor` instance.
*/
}, {
key: "pop",
value: function pop(path) {
var data = this.get(path);
if (!Array.isArray(data)) throw new Error('The data is not an array!');
data.pop();
this.set(path, data);
return this;
}
/**
* read

@@ -119,0 +162,0 @@ * Read the JSON file.

2

package.json

@@ -13,3 +13,3 @@ {

"license": "MIT",
"version": "1.5.0",
"version": "1.6.0",
"main": "lib/index.js",

@@ -16,0 +16,0 @@ "scripts": {

@@ -88,2 +88,6 @@ <!-- Please do not edit this file. Edit the `blah` field in the `package.json` instead. If in doubt, open an issue. -->

file.set("is_student", false);
//Create or append to an array
file.append("classes", "fysics");
//You can even append objects
file.append("classes", { class: "Computer Science", where: "KULeuven" });

@@ -96,4 +100,15 @@

// name: { first: 'Johnny', last: 'B.' },
// is_student: false }
// is_student: false,
// classes: [
// 'fysics',
// {
// 'class': 'Computer Science',
// 'where': 'KULeuven'
// }
// ]
// }
//if you want to remove the last element from an array use pop
file.pop("classes")
// Save the data to the disk

@@ -197,2 +212,25 @@ file.save();

### `append(path, value)`
Appends a value/object to a specific path.
If the path is empty it wil create a list.
#### Params
- **String** `path`: The object path.
- **Anything** `value`: The value.
#### Return
- **JsonEditor** The `JsonEditor` instance.
### `append(path)`
pop
Pop an array from a specific path.
#### Params
- **String** `path`: The object path.
#### Return
- **JsonEditor** The `JsonEditor` instance.
### `read(cb)`

@@ -306,4 +344,6 @@ Read the JSON file.

- `@airbnb/nimbus`
- `json-config-ts`
- `@formbird/core`
- `@dolittle/vanir-cli`
- `@williarts/williarts-commons`

@@ -313,6 +353,5 @@ - `menreiki2`

- `@wonderland/cli-plugin-serverless`
- `soft-add-dependencies`
- `next-nodecms`
- `@neutralinojs/neu`
- `@airbnb/nimbus`
- `frdl`
- `gyaon-cli`

@@ -361,5 +400,6 @@ - `@allmywallets/specification`

- `grafpad`
- `kanuki-cli`
- `bucket-cli`
- `kanuki-cli`
- `axereos-hopes`
- `admooh-cli`
- `@aquestsrl/create-app-cli`

@@ -370,3 +410,2 @@ - `intelliter`

- `@wonderland/new`
- `admooh-cli`
- `@openstfoundation/openst-platform`

@@ -378,3 +417,2 @@ - `cucu-generator`

- `typescript-react-native-starter`
- `simple-webpack-starter`
- `project-initializer`

@@ -385,53 +423,81 @@ - `package-to-local`

- `striplet`
- `ontrac`
- `@acanto/october-scripts`
- `dex-cli`
- `@s-ui/changelog`
- `iffe-cli`
- `vcommit-cli`
- `generator-brei-next`
- `kikd`
- `semcom`
- `bhc-cli`
- `iffe-commit`
- `@empirica/meteor-deploy`
- `@acanto/workflow`
- `express-generator-typescript-k8s`
- `@chakra-ui/cli`
- `robinhood-yolo`
- `create-itk-app`
- `malmo`
- `new-express-app`
- `monstro`
- `@marvinkome/create-node-app`
- `@triptyk/nfw-cli`
- `jollof-cli`
- `jollofjs`
- `jollof-cli`
- `bloggify-tools`
- `ootb-express-app`
- `generator-brei-app`
- `@postlight/node-typescript-starter-kit`
- `@anyopsos/cli`
- `mongoose-auto-api.cli`
- `tail-react`
- `@wizwarrior/node.ts`
- `typescript-nest-starter`
- `node-file-rev`
- `create-express-template`
- `baelte-cli`
- `nipinit`
- `@postlight/node-typescript-starter-kit`
- `@anyopsos/cli`
- `@aburkov/scripts`
- `d-bot-script`
- `modern-project-generator`
- `@teamhive/angular-npm-seed`
- `typescript-express-starter`
- `@elastosfoundation/trinity-cli`
- `guser`
- `@frdl/frdl`
- `@frdl/legacy-and-deprecations-fallback`
- `@jianghe/sand-cli`
- `forcemanager-cli`
- `typescript-vue-starter`
- `@grogqli/server`
- `bloggify-tools`
- `node-file-rev`
- `simple-webpack-starter`
- `bo-api-starter`
- `grelease`
- `@rajzik/lumos`
- `@sevta/cli`
- `plop-pack-gatsby-starter`
- `baelte-cli`
- `ontrac`
- `@chakra-ui/codemod`
- `def-struct`
- `@farazahmad759/dricup-crud-express`
- `plop-pack-sanity-starter`
- `@acanto/october-scripts`
- `@acanto/workflow`
- `create-express-template`
- `dricup`
- `@dricup/dricup-cli`
- `dricup-cli`
- `modern-project-generator`
- `@dolittle/webpack`
- `@jianghe/sand-cli`
- `cli-json-edit`
- `@hayes0724/shopify-packer`
- `@teamhive/angular-npm-seed`
- `@elastosfoundation/trinity-cli`
- `generator-brei-app`
- `my-chakra-ui`
- `create-express-typescript-application`
- `@mianfrigo/express-typescript-generator`
- `@s-ui/changelog`
- `dex-cli`
- `@ps-devs/shopify-webpack`
- `@j.u.p.iter/jupiter-scripts`
- `@acanto/laravel-scripts`
- `@rajzik/lumos`
- `create-nuxt-typescript-component`
- `kikd`
- `kape`
- `semcom`
- `@tinyhttp/cli`
- `@bronzw/create-discord-js-bot`
- `@grogqli/server`
- `nipinit`
- `typescript-express-starter`
- `@something.technology/core`
- `@oriflame/lumos`
- `express-generator-typescript`
- `@dolittle/vanir-common`

@@ -438,0 +504,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc