properties-to-object
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "properties-to-object", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Parse property file structures into object structures", | ||
@@ -15,3 +15,4 @@ "main": "index.js", | ||
{ | ||
"name": "Florian Hertrampf" | ||
"name": "Florian Hertrampf", | ||
"email": "florian.hertrampf@uni-jena.de" | ||
} | ||
@@ -24,2 +25,8 @@ ], | ||
"license": "MIT", | ||
"keywords": [ | ||
"cloud", | ||
"config", | ||
"spring", | ||
"properties" | ||
], | ||
"devDependencies": { | ||
@@ -26,0 +33,0 @@ "mocha": "^5.2.0" |
# Parse Properties to Objects | ||
[![Build Status](https://travis-ci.com/winner-potential/properties-to-object.svg?branch=master)](https://travis-ci.com/winner-potential/properties-to-object) | ||
Simple parser to handle property file based key names and parse them into objects. The key name separations with points is transferred into an object structure. | ||
@@ -4,0 +6,0 @@ |
42
test.js
const parser = require("./index.js"); | ||
const assert = require("assert"); | ||
describe("Basic Mocha String Test", function() { | ||
it("should return number of charachters in a string", function() { | ||
describe("Parser", function() { | ||
it("should parse simple config", function() { | ||
var config = parser({ | ||
@@ -18,2 +18,40 @@ "some.property": "value", | ||
}); | ||
it("should parse array config", function() { | ||
var config = parser({ | ||
"some[0]": "value", | ||
"some[1]": "123", | ||
"some[2]": "xyz", | ||
"some[3]": "..." | ||
}); | ||
assert.ok(config); | ||
assert.ok(config.some); | ||
assert.ok(config.some.length); | ||
assert.equal(4, config.some.length); | ||
assert.equal("value", config.some[0]); | ||
assert.equal("123", config.some[1]); | ||
assert.equal("xyz", config.some[2]); | ||
assert.equal("...", config.some[3]); | ||
}); | ||
it("should parse complex config", function() { | ||
var config = parser({ | ||
"some.more": "Hello", | ||
"some.other[0].value": "value", | ||
"some.other[1].value": "123", | ||
"some.other[2].value": "xyz", | ||
"some.other[3].value": "..." | ||
}); | ||
assert.ok(config); | ||
assert.ok(config.some.more); | ||
assert.ok(config.some.other); | ||
assert.ok(config.some.other.length); | ||
assert.equal(4, config.some.other.length); | ||
assert.equal("value", config.some.other[0].value); | ||
assert.equal("123", config.some.other[1].value); | ||
assert.equal("xyz", config.some.other[2].value); | ||
assert.equal("...", config.some.other[3].value); | ||
}); | ||
}); |
6483
6
103
43