json-file-plus
Advanced tools
Comparing version
@@ -0,1 +1,11 @@ | ||
[4.0.0](https://github.com/ljharb/json-file-plus/releases/tag/v4.0.0) / 2025-02-13 | ||
================== | ||
[Breaking] complete overhaul; use ESM and modern syntax | ||
[New] add types | ||
[Fix] ensure non-object data is not persisted | ||
[meta] add `sideEffects` flag | ||
[meta] exclude more files | ||
[meta] add `npmignore` | ||
[actions] split out node 10-20, and 20+ | ||
[3.3.2](https://github.com/ljharb/json-file-plus/releases/tag/v3.3.2) / 2025-02-06 | ||
@@ -2,0 +12,0 @@ ================== |
{ | ||
"name": "json-file-plus", | ||
"version": "3.3.2", | ||
"version": "4.0.0", | ||
"author": { | ||
@@ -19,14 +19,20 @@ "name": "Jordan Harband", | ||
], | ||
"description": "Read from and write to a JSON file, minimizing diffs and preserving formatting.", | ||
"license": "MIT", | ||
"main": "index.js", | ||
"main": "index.mjs", | ||
"exports": { | ||
".": "./index.mjs", | ||
"./package.json": "./package.json" | ||
}, | ||
"sideEffects": false, | ||
"scripts": { | ||
"prepack": "npmignore --auto --commentLines=autogenerated", | ||
"prepublishOnly": "safe-publish-latest", | ||
"prepublish": "not-in-publish || npm run prepublishOnly", | ||
"prelint": "evalmd README.md", | ||
"lint": "eslint --ext=js,mjs .", | ||
"postlint": "tsc && attw -P .", | ||
"pretest": "npm run lint", | ||
"test": "npm run tests-only", | ||
"tests-only": "nyc tape 'test/**/*.js'", | ||
"posttest": "npx npm@\">= 10.2\" audit --production", | ||
"prelint": "evalmd README.md", | ||
"lint": "eslint --ext=js,mjs ." | ||
"tests-only": "nyc tape 'test/**/*.mjs'", | ||
"posttest": "npx npm@\">= 10.2\" audit --production" | ||
}, | ||
@@ -43,26 +49,37 @@ "repository": { | ||
"write", | ||
"promise", | ||
"promiseback" | ||
"promise" | ||
], | ||
"dependencies": { | ||
"is": "^3.3.0", | ||
"node.extend": "^2.0.3", | ||
"object.assign": "^4.1.7", | ||
"promiseback": "^2.0.3", | ||
"safer-buffer": "^2.1.2" | ||
"node.extend": "^2.0.3" | ||
}, | ||
"devDependencies": { | ||
"@arethetypeswrong/cli": "^0.17.3", | ||
"@ljharb/eslint-config": "^21.1.1", | ||
"@ljharb/tsconfig": "^0.2.3", | ||
"@types/tape": "^5.8.1", | ||
"es-value-fixtures": "^1.7.1", | ||
"eslint": "=8.8.0", | ||
"evalmd": "^0.0.19", | ||
"for-each": "^0.3.4", | ||
"hasown": "^2.0.2", | ||
"npmignore": "^0.3.1", | ||
"nyc": "^10.3.2", | ||
"object-keys": "^1.1.1", | ||
"safe-publish-latest": "^2.0.0", | ||
"tape": "^5.9.0" | ||
"tape": "^5.9.0", | ||
"typescript": "next" | ||
}, | ||
"engines": { | ||
"node": ">= 0.4" | ||
"node": "^16.20.2 || ^18.20.6 || ^20.18.3 || ^22.14.0 || >= 23.8" | ||
}, | ||
"publishConfig": { | ||
"ignore": [ | ||
".attw.json", | ||
".editorconfig", | ||
".eslintrc", | ||
".nycrc", | ||
".github/workflows", | ||
"appveyor.yml", | ||
"test", | ||
"tsconfig.json" | ||
] | ||
} | ||
} |
@@ -16,11 +16,7 @@ # json-file-plus <sup>[![Version Badge][npm-version-svg]][npm-url]</sup> | ||
```js | ||
var jsonFile = require('json-file-plus'); | ||
var path = require('path'); // in node-core | ||
var filename = path.join(process.cwd(), 'package.json'); | ||
var callback = function (err, result) { /* your code here */ }; | ||
const jsonFile = require('json-file-plus'); | ||
const path = require('path'); | ||
const filename = path.join(process.cwd(), 'package.json'); | ||
/* Note: jsonFile also returns a Promise, if you prefer that to a Node-style callback ("errorback"). */ | ||
jsonFile(filename, function (err, file) { | ||
if (err) { return doSomethingWithError(err); } | ||
jsonFile(filename).then((file) => { | ||
file.data; // Direct access to the data from the file | ||
@@ -30,5 +26,3 @@ file.format; // extracted formatting data. change at will. | ||
file.get('version'); // get top-level keys. returns a Promise | ||
file.get('version', callback); // get top-level keys. calls the errorback | ||
file.get(); // get entire data. returns a Promise | ||
file.get(callback); // get entire data. calls the errorback | ||
@@ -41,8 +35,7 @@ /* pass any plain object into "set" to merge in a deep copy */ | ||
bar: { | ||
baz: true | ||
} | ||
baz: true, | ||
}, | ||
}); | ||
file.remove('description'); // remove a specific key-value pair. returns a Promise | ||
file.remove('description', callback); // remove a specific key-value pair. calls the errorback | ||
@@ -52,6 +45,4 @@ /* change the filename if desired */ | ||
/* Save the file, preserving formatting. */ | ||
/* Errorback will be passed to fs.writeFile */ | ||
/* Returns a Promise. */ | ||
file.save(callback).then(function () { | ||
/* Save the file, preserving formatting. returns a Promise. */ | ||
file.save().then(function () { | ||
console.log('success!'); | ||
@@ -58,0 +49,0 @@ }).catch(function (err) { |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
1
-80%18154
-39.8%13
44.44%7
-50%101
-76.07%69
-11.54%- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed