Skip to content

Commit

Permalink
fix style consistency issues
Browse files Browse the repository at this point in the history
  • Loading branch information
derrell committed Oct 14, 2019
1 parent 3265565 commit 179aab1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
21 changes: 9 additions & 12 deletions examples/ini.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const fs = require("fs");
const ini = require("ini");
const fs = require('fs');
const ini = require('ini');
const utils = require('../utils');
const path = require('path');
const Store = require('../');

// Will be called in context of store
function writeFile() {
console.log("writeFile");
console.log('writeFile');
utils.mkdir(path.dirname(this.path));
fs.writeFileSync(this.path, ini.stringify(this.data), { mode: 0o0600 });
}
Expand All @@ -15,13 +15,10 @@ function writeFile() {
function readParseFile() {
let data;

console.log("readParseFile");
try
{
console.log('readParseFile');
try {
data = fs.readFileSync(this.path, "utf-8");
}
catch (e)
{
} catch (e) {
console.log(`readParseFile error; starting with empty data`);
data = {};
}
Expand All @@ -39,9 +36,9 @@ const store = new Store(
readParseFile: readParseFile
});

store.merge("section 1", { a : 'b' });
store.merge("section 1", { c : 'd' });
store.set("section 2", { e : 'f' });
store.merge('section 1', { a : 'b' });
store.merge('section 1', { c : 'd' });
store.set('section 2', { e : 'f' });
console.log(store.data);

//store.unlink();
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ class Store {
this.timeouts = {};

// Allow override of read and write methods
if (typeof options.readParseFile == "function") {
if (typeof options.readParseFile === 'function') {
this.readParseFile = options.readParseFile;
}
if (typeof options.writeFile == "function") {
if (typeof options.writeFile === 'function') {
this.writeFile = options.writeFile;
}
}
Expand Down Expand Up @@ -126,7 +126,7 @@ class Store {

merge(key, val) {
let oldVal = this.get(key);
if (oldVal && typeof oldVal == "object" && ! Array.isArray(oldVal)) {
if (oldVal && typeof oldVal === 'object' && !Array.isArray(oldVal)) {
val = Object.assign(this.get(key), val);
}
return this.set(key, val);
Expand Down Expand Up @@ -373,7 +373,7 @@ class Store {
* data = store.readPraseFile();
* ```
* @name .readParseFile
* @return {undefined}
* @return {Object}
*/

readParseFile() {
Expand Down

0 comments on commit 179aab1

Please sign in to comment.