Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
properties-sync
Advanced tools
propertiesSync - Synchronous parsing and manipulating .properties files
const properties = require('propertiesSync');
let props = properties.readPropertiesSync('config.properties');
let aB = props.a.b;
let c = props.c;
let props2 = properties.readPropertiesSync('config2.properties');
properties.mergeProperties(props, props2);
This module provides two functions:
Read .properties files using Node.js' synchronous filesystem interface. Since the files are read synchronously, an application's configuration will be available immediately.
Merge two objects, allowing configuration objects to be combined.
module.readPropertiesSync(path): Object
Read a file identified by path, producing an object.
A properties file consists, roughly, of lines, each consisting of a key and a value. The result of reading a file is an object mapping keys to values. If the key is made up of segments joined by periods, the key is broken into sub-keys, i.e. namespaces, each mapping to a sub-object.
For example, the properties file:
a.b.c = 1
a.b.d = 0
a.e = 2
is read into the object structure:
{
a: {
b: {
c: "1",
d: "0",
},
e: "2",
}
}
If the file does not exist, undefined is returned.
If the file contains conflicting structure, an error is thrown. An example of such conflicts:
a.b.c = 1
a.b = 2
In this example, a.b is both an object and the value "2".
module.mergeProperties(target, source,...)
Recursively merge the source objects onto the target object. A target object must be specified and will be modified, and one or more source objects.
For example, given the two properties files:
a.b.c = 1
a.b.d = 2
x.y.z = "potato"
r = "elbow"
the result of merging the two objects will be:
{
a: {
b: {
c: "1",
d: "2",
},
},
x: {
z: "potato",
},
r: "elbow",
}
A properties file consists of logical lines. Each logical line is made of:
A comment, beginning with '#' and continuing until the end of the line. The comment character can be escaped by a backslash ("#") to include it in a key or value.
A key/value pair consisting of a key ending at the first ':' or '=' character, followed by a value. Keys are broken at periods ('.'), to create namespaces.
Multiple physical lines can be combined into a single logical line by escaping the terminating newline with a backslash ('').
Alternative project: node-properties.
The .properties file format. (This module does not completely implement that format.)
.properties at Wikipedia.
FAQs
Simple, synchronous .properties file reader
The npm package properties-sync receives a total of 0 weekly downloads. As such, properties-sync popularity was classified as not popular.
We found that properties-sync demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.