Gathering detailed insights and metrics for properties-reader
Gathering detailed insights and metrics for properties-reader
Gathering detailed insights and metrics for properties-reader
Gathering detailed insights and metrics for properties-reader
@types/properties-reader
TypeScript definitions for properties-reader
grunt-properties-reader
Grunt plugin that reads java properties files.
@resource-sentry/reader-properties
Resource Sentry Properties Reader.
@smithy/chunked-blob-reader
[![NPM version](https://img.shields.io/npm/v/@smithy/chunked-blob-reader/latest.svg)](https://www.npmjs.com/package/@smithy/chunked-blob-reader) [![NPM downloads](https://img.shields.io/npm/dm/@smithy/chunked-blob-reader.svg)](https://www.npmjs.com/packag
npm install properties-reader
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
77 Stars
111 Commits
33 Forks
5 Watching
11 Branches
6 Contributors
Updated on 04 Sept 2024
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
3.1%
152,956
Compared to previous day
Last week
2.3%
799,377
Compared to previous week
Last month
13%
3,315,913
Compared to previous month
Last year
52.8%
28,975,769
Compared to previous year
1
3
An ini file compatible properties reader for Node.JS
The easiest installation is through NPM:
npm install properties-reader
Read properties from a file:
var propertiesReader = require('properties-reader');
var properties = propertiesReader('/path/to/properties.file');
The properties are then accessible either by fully qualified name, or if the property names are in dot-delimited notation, they can be access as an object:
// fully qualified name
var property = properties.get('some.property.name');
// by object path
var property = properties.path().some.property.name;
To read more than one file, chain calls to the .append()
method:
properties.append('/another.file').append('/yet/another.file');
To read properties from a string, use the .read()
method:
properties.read('some.property = Value \n another.property = Another Value');
To set a single property into the properties object, use .set()
:
properties.set('property.name', 'Property Value');
When reading a .ini
file, sections are created by having a line that contains just a section name in square
brackets. The section name is then prefixed to all property names that follow it until another section name is found
to replace the current section.
# contents of properties file
[main]
some.thing = foo
[blah]
some.thing = bar
// reading these back from the properties reader
properties.get('main.some.thing') == 'foo';
properties.get('blah.some.thing') == 'bar';
// looping through the properties reader
properties.each((key, value) => {
// called for each item in the reader,
// first with key=main.some.thing, value=foo
// next with key=blah.some.thing, value=bar
});
// get all properties at once
expect(properties.getAllProperties()).toEqual({
'main.some.thing': 'foo',
'blah.some.thing': 'bar',
})
Checking for the current number of properties that have been read into the reader:
var propertiesCount = properties.length;
The length is calculated on request, so if accessing this in a loop an efficiency would be achieved by caching the value.
When duplicate names are found in the properties, the first one read will be replaced with the later one.
To get the complete set of properties, either loop through them with the .each((key, value) => {})
iterator or
use the convenience method getAllProperties
to return the complete set of flattened properties.
Once a file has been read and changes made, saving those changes to another file is as simple as running:
1// async/await ES6 2const propertiesReader = require('properties-reader'); 3const props = propertiesReader(filePath, {writer: { saveSections: true }}); 4await props.save(filePath); 5 6// ES5 callback styles 7props.save(filePath, function then(err, data) { ... }); 8 9// ES5 promise style 10props.save(filePath).then(onSaved, onSaveError);
To output the properties without any section headings, set the saveSections
option to false
Properties will automatically be converted to their regular data types when they represent true/false or numeric
values. To get the original value without any parsing / type coercion applied, use properties.getRaw('path.to.prop')
.
From version 2.0.0
the default behaviour relating to multiple [section]
blocks with the same name has changed
so combine the items of each same-named section into the one section. This is only visible when saving the items
(via reader.save()
).
To restore the previous behaviour which would allow duplicate [...]
blocks to be created, supply an appender
configuration with the property allowDuplicateSections
set to true
.
1const propertiesReader = require('properties-reader'); 2const props = propertiesReader(filePath, 'utf-8', { allowDuplicateSections: true });
If you find bugs or want to change functionality, feel free to fork and pull request.
The latest stable version of the package.
Stable Version
1
9.8/10
Summary
Properties-Reader before v2.2.0 vulnerable to prototype pollution
Affected Versions
< 2.2.0
Patched Versions
2.2.0
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
8 existing vulnerabilities detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/17 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More