Socket
Socket
Sign inDemoInstall

java-properties

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

java-properties - npm Package Compare versions

Comparing version 0.2.6 to 0.2.7

38

lib/properties.js

@@ -104,5 +104,30 @@ /*

}, {
key: 'getLast',
value: function getLast(key, defaultValue) {
if (this.objs.hasOwnProperty(key)) {
if (Array.isArray(this.objs[key])) {
var lg = this.objs[key].length;
return this.interpolate(this.objs[key][lg - 1]);
} else {
return typeof this.objs[key] === 'undefined' ? '' : this.interpolate(this.objs[key]);
}
}
return defaultValue;
}
}, {
key: 'getFirst',
value: function getFirst(key, defaultValue) {
if (this.objs.hasOwnProperty(key)) {
if (Array.isArray(this.objs[key])) {
return this.interpolate(this.objs[key][0]);
} else {
return typeof this.objs[key] === 'undefined' ? '' : this.interpolate(this.objs[key]);
}
}
return defaultValue;
}
}, {
key: 'getInt',
value: function getInt(key, defaultIntValue) {
var val = this.get(key);
var val = this.getLast(key);
if (!val) {

@@ -117,3 +142,3 @@ return defaultIntValue;

value: function getFloat(key, defaultFloatValue) {
var val = this.get(key);
var val = this.getLast(key);
if (!val) {

@@ -132,3 +157,3 @@ return defaultFloatValue;

var val = this.get(key);
var val = this.getLast(key);
if (!val) {

@@ -150,8 +175,3 @@ return defaultBooleanValue || false;

return s.replace(/\\\\/g, '\\').replace(/\$\{([A-Za-z0-9\.]*)\}/g, function (match) {
var values = me.get(match.substring(2, match.length - 1));
if (Array.isArray(values)) {
return values[values.length - 1];
} else {
return values;
}
return me.getLast(match.substring(2, match.length - 1));
});

@@ -158,0 +178,0 @@ }

{
"name": "java-properties",
"description": "Reads and interpolates Java .properties files",
"version": "0.2.6",
"version": "0.2.7",
"homepage": "http://github.com/mattdsteele/java-properties",

@@ -6,0 +6,0 @@ "author": {

@@ -79,4 +79,5 @@ # java-properties

* 0.2.6 FIX interpolation when a property is multivalued
* 0.2.7 Get only last value for int and boolean in case of multivalued attribute
## License
Licensed under the MIT license.

@@ -274,3 +274,3 @@ 'use strict';

'Multivalued property in interpolation' : function(test) {
test.expect(4);
test.expect(6);
var myFile = new PropertiesFile('test/fixtures/multivalued.properties');

@@ -280,5 +280,19 @@ test.equal(myFile.get('multi.value').length, 2);

test.equal(myFile.get('multi.value')[1], 'value2');
test.equal(myFile.getLast('multi.value'), 'value2');
test.equal(myFile.getFirst('multi.value'), 'value1');
test.equal('The value is value2', myFile.get('multi.interpolated.value'));
test.done();
},
'Multivalued boolean property' : function(test) {
test.expect(1);
var myFile = new PropertiesFile('test/fixtures/multivalued.properties');
test.equal(myFile.getBoolean('multi.bool.value'), true);
test.done();
},
'Multivalued int property' : function(test) {
test.expect(1);
var myFile = new PropertiesFile('test/fixtures/multivalued.properties');
test.equal(myFile.getInt('multi.int.value'), 1);
test.done();
}
};

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc