simple-json-db
Advanced tools
Comparing version 1.2.2 to 1.2.3
11
index.js
@@ -5,7 +5,8 @@ const fs = require("fs"); | ||
* Default configuration values. | ||
* @type {{asyncWrite: boolean, syncOnWrite: boolean}} | ||
* @type {{asyncWrite: boolean, syncOnWrite: boolean, jsonSpaces: number}} | ||
*/ | ||
const defaultOptions = { | ||
asyncWrite: false, | ||
syncOnWrite: true | ||
syncOnWrite: true, | ||
jsonSpaces: 4 | ||
}; | ||
@@ -33,2 +34,4 @@ | ||
* @param {boolean} [options.syncOnWrite] Makes the storage be written to disk after every modification. Enabled by default. | ||
* @param {boolean} [options.syncOnWrite] Makes the storage be written to disk after every modification. Enabled by default. | ||
* @param {number} [options.jsonSpaces] How many spaces to use for indentation in the output json files. Default = 4 | ||
* @constructor | ||
@@ -146,3 +149,3 @@ */ | ||
if (this.options && this.options.asyncWrite) { | ||
fs.writeFile(this.filePath, JSON.stringify(this.storage, null, 4), (err) => { | ||
fs.writeFile(this.filePath, JSON.stringify(this.storage, null, this.options.jsonSpaces), (err) => { | ||
if (err) throw err; | ||
@@ -152,3 +155,3 @@ }); | ||
try { | ||
fs.writeFileSync(this.filePath, JSON.stringify(this.storage, null, 4)); | ||
fs.writeFileSync(this.filePath, JSON.stringify(this.storage, null, this.options.jsonSpaces)); | ||
} catch (err) { | ||
@@ -155,0 +158,0 @@ if (err.code === 'EACCES') { |
{ | ||
"name": "simple-json-db", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "A simple, no-frills, JSON storage engine for Node.JS", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"engines": { | ||
@@ -7,0 +8,0 @@ "node": ">=6.0" |
@@ -31,2 +31,3 @@ # Simple JSONdb [![npm](https://img.shields.io/npm/v/simple-json-db)](https://www.npmjs.com/package/simple-json-db) [![npm](https://img.shields.io/npm/dw/simple-json-db)](https://www.npmjs.com/package/simple-json-db) [![Minimum NodeJS version](https://img.shields.io/node/v/simple-json-db)](https://www.npmjs.com/package/simple-json-db) [![Dependents (via libraries.io)](https://img.shields.io/librariesio/dependents/npm/simple-json-db)](https://libraries.io/npm/simple-json-db/dependents) [![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/simple-json-db)](https://snyk.io/vuln/search?q=simple-json-db&type=npm) | ||
| syncOnWrite | _Boolean_ | Makes the storage be written to disk after every modification. | _**true**_ | | ||
| jsonSpaces | _Number_ | The number of spaces used for indentation in the output JSON. | _**4**_ | | ||
@@ -33,0 +34,0 @@ ### Set a key |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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
15178
7
293
72
0