You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

node-json-db

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-json-db - npm Package Compare versions

Comparing version

to
0.5.1

5

JsonDB.js

@@ -72,2 +72,3 @@ (function () {

create = create || false;
dataPath = JsonUtils.removeTrailingSlash(dataPath);

@@ -130,2 +131,3 @@ function recursiveProcessDataPath(data, index) {

};
/**

@@ -139,2 +141,4 @@ * Pushing data into the database

override = override === undefined ? true : override;
dataPath = JsonUtils.removeTrailingSlash(dataPath);
var dbData = this._getParentData(dataPath, true);

@@ -172,2 +176,3 @@ if (!dbData) {

JsonDB.prototype.delete = function (dataPath) {
dataPath = JsonUtils.removeTrailingSlash(dataPath);
var dbData = this._getParentData(dataPath, true);

@@ -174,0 +179,0 @@ if (!dbData) {

10

lib/utils.js

@@ -50,7 +50,15 @@ (function () {

};
function removeTrailingSlash(dataPath) {
if(dataPath.length > 1 && endsWith(dataPath,"/")) {
return dataPath.substring(0, dataPath.length - 1);
}
return dataPath;
}
exports = module.exports = {
strEndWith: endsWith,
mergeObject: merge,
processArray: processArray
processArray: processArray,
removeTrailingSlash : removeTrailingSlash
}
})();

2

package.json
{
"name": "node-json-db",
"version": "0.5.0",
"version": "0.5.1",
"description": "Database using JSON file as storage for Node.JS",

@@ -5,0 +5,0 @@ "main": "./JsonDB.js",

@@ -50,3 +50,3 @@ [![Build Status](https://secure.travis-ci.org/Belphemur/node-json-db.png?branch=master)](http://travis-ci.org/Belphemur/node-json-db) [![Coverage Status](https://img.shields.io/coveralls/Belphemur/node-json-db.svg)](https://coveralls.io/r/Belphemur/node-json-db?branch=master)

//It also create automatically the hierarchy when pushing new data for a DataPath that doesn't exists
db.push("/test2/my/test/",5);
db.push("/test2/my/test",5);

@@ -53,0 +53,0 @@ //You can also push directly objects

@@ -107,2 +107,17 @@ var expect = require("expect.js");

})
it('should remove trailing Slash when pushing/getting data (/)', function () {
var object = {test: {test: "test"}};
db.push("/testing/", object);
expect(db.getData("/testing")).to.be(object);
})
it('should remove trailing Slash when deleting data (/)', function () {
db.delete("/testing/");
expect(function (args) {
db.getData(args);
}).withArgs("/testing/").to.throwException(function (e) {
expect(e).to.be.a(DataError);
});
})
it('should merge the data at datapath', function () {

@@ -109,0 +124,0 @@ var object = ['test2'];