Socket
Socket
Sign inDemoInstall

properties-parser

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.1 to 0.2.1

24

index.js

@@ -231,4 +231,6 @@ var fs = require("fs");

this.get = function(key) { return obj[key]; }
this.get = function(key) { return obj[key]; };
this.set = function(key, val, comment) {
if(val == null) { this.unset(key); return; }
obj[key] = val;

@@ -247,6 +249,6 @@

if(range.type == "literal") {
if(range.type === "literal") {
range.text = key + "=" + val;
if(range.comment != null) { range.text = range.comment + "\n" + range.text; }
} else if(range.type == "key-value") {
} else if(range.type === "key-value") {
range.children[2].type = "literal";

@@ -258,3 +260,13 @@ range.children[2].text = val;

}
}
};
this.unset = function(key) {
var range = keyRange[key];
var index = ranges.indexOf(range);
if (index > -1) {
ranges.splice(index, 1);
}
delete keyRange[key];
delete obj[key];
};
this.valueOf = this.toString = function() {

@@ -288,3 +300,3 @@ var buffer = [], stack = [].concat(ranges);

return buffer.join("");
},
};
this.save = function(newPath, callback) {

@@ -300,3 +312,3 @@ if(typeof newPath === 'function') {

fs.writeFile(newPath, this.toString(), callback || function() {});
}
};
}

@@ -303,0 +315,0 @@ function createEditor(path, callback) {

{ "name": "properties-parser"
, "version": "0.1.1"
, "version": "0.2.1"
, "description": "A parser for .properties files written in javascript"

@@ -4,0 +4,0 @@ , "keywords": [ "parser", ".properties", "properties", "java", "file parser", "actionscript" ]

@@ -50,9 +50,9 @@ var fs = require("fs");

assert.equal(fs.readFileSync("./test-cases.properties"), editor2.toString());
editor2.set("lala", "prop1")
editor2.set("lala", "prop1");
assert.ok(editor2.toString().indexOf("lala=prop1") > -1);
editor2.set("lala", "prop2", "A comment\nmulti-line1")
editor2.set("lala", "prop2", "A comment\nmulti-line1");
assert.ok(editor2.toString().indexOf("# A comment\n# multi-line1\nlala=prop2") > -1);
editor2.set("lala", "prop3", "A comment\nmulti-line2")
editor2.set("lala", "prop3", "A comment\nmulti-line2");
assert.ok(editor2.toString().indexOf("# A comment\n# multi-line2\nlala=prop3") > -1);
editor2.set("lala", "prop4")
editor2.set("lala", "prop4");
assert.ok(editor2.toString().indexOf("# A comment\n# multi-line2\nlala=prop4") > -1);

@@ -68,3 +68,24 @@ editor2.set("lala", "prop5", null); // Delete's comment

var editor3 = prop.createEditor();
editor3.set("stay", "ok");
editor3.unset("key");
editor3.unset("key", null);
editor3.unset("key", undefined);
assert.equal(editor3.toString().trim(), "stay=ok");
editor3.set("key", "val");
editor3.unset("key");
assert.equal(editor3.toString().trim(), "stay=ok");
editor3.set("key", "val");
editor3.set("key", null);
assert.equal(editor3.toString().trim(), "stay=ok");
editor3.set("key", "val");
editor3.set("key", undefined);
assert.equal(editor3.toString().trim(), "stay=ok");
// java ReadProperties test-cases.properties
// javac ReadProperties.java

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc