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

simple-json-editor

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-json-editor - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

48

index.js

@@ -181,4 +181,48 @@ // Requires

}
/**
* @description Subtract a value with a subtracting.
* @param {String} key - The key where the array you want the element to pop from is located.
* @param {*} [subtracting=1] - The number you want to substract the value behind the key with-
* @param {*} [ignore=false] - If you want to ignore the point seperator in your key set this to true!
* @returns Returns the difference of the value and the subtracting
*/
substract(key, subtracting, ignore) {
let json = JSON.parse(fs.readFileSync(this.file, {"encoding": "utf-8"}).toString());
if (ignore === true) {
let elem = json[String(key)];
if (typeof elem === Number) {
if (typeof subtracting === Number) {
elem = elem - subtracting;
} else {
elem--;
};
this.set(key, elem, true);
return elem;
} else {
return new Error("TypeError: The path does not lead to an array");
}
} else {
for (var i = 0; i < keys.length; i++) {
var keys = key.split('.');
if (json && json.hasOwnProperty(keys[i])) {
json = json[keys[i]];
} else {
return undefined
}
};
if (typeof json === Number) {
if (typeof subtracting === Number) {
json = json - subtracting;
} else {
json--;
};
this.set(key, json, false);
return json;
} else {
return new Error("TypeError: The path does not lead to an array");
}
}
};
};
module.exports = Editor;
Array().pop
module.exports = Editor;

4

package.json
{
"name": "simple-json-editor",
"version": "0.0.5",
"version": "0.0.6",
"description": "This is a package to easily edit json files",

@@ -21,3 +21,3 @@ "main": "index.js",

"prettier": "^2.8.8",
"simple-json-editor": "^0.0.5"
"simple-json-editor": "^0.0.6"
},

@@ -24,0 +24,0 @@ "funding": {

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