Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

properties

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

properties - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

8

lib/escape.js

@@ -12,2 +12,5 @@ "use strict";

module.exports = function (c, code, meta, options){
//Encode characters to their unicode representation to be compatible with
//ISO 8859-1 (latin1)
//code 61: =

@@ -43,4 +46,7 @@ //code 58: :

//ASCII extended and multibyte characters
//Printable 8-bit character
if (code < 256) return c;
//Latin1 multibyte character
return options.unicode ? unicode (code) : c;
};

10

lib/parse.js
"use strict";
var PropertiesError = require ("./error");
//The data doesn't need to be buffered because .properties files typically

@@ -257,4 +255,4 @@ //have a size less than a block (default is 16KB)

//The section doesn't end with ], it's a key
control.error = new PropertiesError ("The section line \"" +
section + "\" must end with \"]\"");
control.error = new Error ("The section line \"" + section +
"\" must end with \"]\"");
return;

@@ -277,4 +275,4 @@ }

//The section doesn't end with ], it's a key
control.error = new PropertiesError ("The section line \"" + section +
"\" must end with \"]\"");
control.error = new Error ("The section line \"" + section + "\" must end" +
"with \"]\"");
return;

@@ -281,0 +279,0 @@ }

@@ -6,3 +6,2 @@ "use strict";

var parse = require ("./parse");
var PropertiesError = require ("./error");

@@ -54,4 +53,4 @@ var INCLUDE_KEY = "include";

if (!holder){
return cb (new PropertiesError ("The section \"" + section +
"\" does not exist"));
return cb (new Error ("The section \"" + section + "\" does not " +
"exist"));
}

@@ -69,4 +68,4 @@

if (v === undefined){
return cb (new PropertiesError ("The property \"" + key +
"\" does not exist"));
return cb (new Error ("The property \"" + key + "\" does not " +
"exist"));
}

@@ -87,3 +86,3 @@ }

if (stack.length !== 0){
return cb (new PropertiesError ("Malformed variable: " + str));
return cb (new Error ("Malformed variable: " + str));
}

@@ -154,4 +153,4 @@

if (currentSection !== null){
return abort (new PropertiesError ("Cannot include files from inside " +
"a section: " + currentSection));
return abort (new Error ("Cannot include files from inside a " +
"section: " + currentSection));
}

@@ -396,4 +395,4 @@

if (comment.length > 1 || code < 33 || code > 126){
throw new PropertiesError ("The comment token must be a single " +
"printable ASCII character");
throw new Error ("The comment token must be a single printable ASCII " +
"character");
}

@@ -410,4 +409,4 @@ c[comment] = true;

if (separator.length > 1 || code < 33 || code > 126){
throw new PropertiesError ("The separator token must be a single " +
"printable ASCII character");
throw new Error ("The separator token must be a single printable ASCII " +
"character");
}

@@ -419,4 +418,4 @@ s[separator] = true;

if (options.path){
if (!cb) throw new PropertiesError ("A callback must be passed if the " +
"data is a path");
if (!cb) throw new Error ("A callback must be passed if the data is a " +
"path");
if (options.include){

@@ -423,0 +422,0 @@ read (data, options, cb);

{
"name": "properties",
"version": "1.1.1",
"version": "1.1.2",
"description": ".properties parser/stringifier",

@@ -16,4 +16,7 @@ "keywords": ["properties", "ini", "parser", "stringifier", "config"],

},
"scripts": {
"test": "node test/parse && node test/stringify"
},
"license": "MIT",
"main": "lib"
}
properties
==========
_Node.js project_
#### .properties parser/stringifier ####
Version: 1.1.1
[![NPM version](https://badge.fury.io/js/properties.png)](http://badge.fury.io/js/properties "Fury Version Badge")
[![Build Status](https://secure.travis-ci.org/gagle/node-properties.png)](http://travis-ci.org/gagle/node-properties "Travis CI Badge")
[Specification](http://docs.oracle.com/javase/7/docs/api/java/util/Properties.html#load%28java.io.Reader%29)
[![NPM installation](https://nodei.co/npm/properties.png?mini=true)](https://nodei.co/npm/properties "NodeICO Badge")
[.properties specification](http://docs.oracle.com/javase/7/docs/api/java/util/Properties.html#load%28java.io.Reader%29)
This module implements the Java .properties specification and adds additional features like [ini](#ini) sections, variables (key referencing), namespaces, importing files and much more.
#### Installation ####
```
npm install properties
```
#### Documentation ####

@@ -219,3 +214,3 @@

When the `include` option is enabled, the `include` key allows you import files. If the path is a directory it tries to load the file `index.properties`. The paths are relative from the __current__ file.
When the `include` option is enabled, the `include` key allows you import files. If the path is a directory it tries to load the file `index.properties`. The paths are relative from the __current__ .properties file.

@@ -229,6 +224,16 @@ The imported files are merged with the current file, they can replace old data.

# Loads a/dir/index.properties
# Load a/dir/index.properties
include a/dir
```
Note: You can include files using a simple key-value string:
```javascript
properties.parse ("include my/file", function (error, data){
...
})
```
In this case the files are __always__ relative to `.`. You cannot use `__dirname` like this: `"include " + __dirname + "/my/file"`.
---

@@ -364,9 +369,11 @@

Files can be linked and imported with the `include` key. If this option is used the callback is mandatory. See the [include](#include) section for further details.
- __reviver__ - _Boolean_
Each property or section can be removed or modified from the final object. It's similar to the reviver of the JSON.parse function.
- __reviver__ - _Function_
Each property or section can be removed or modified from the final object. It's similar to the reviver of the `JSON.parse()` function.
The reviver it's exactly the same as the replacer from [stringify()](#stringify). The same function can be reused.
The callback gets 3 parameters: key, value and section.
A property has a key and a value and can belong to a section. If it's a global property the section is set to null. If __undefined__ is returned the property will be removed from the final object, otherwise the returned value will be used as the property value.
The callback gets 3 parameters: key, value and section.
A property has a key and a value and can belong to a section. If it's a global property the section is set to null. If __undefined__ is returned the property will be removed from the final object, otherwise the returned value will be used as the property value.
If the key and the value are set to null then it's a section line. If it returns a falsy value it won't be added to the final object, the entire section -including all the properties- will be discarded. If it returns a truthy value the section is parsed.

@@ -402,2 +409,41 @@

The reviver is called just after the value is casted to the proper data type. This means that the `value` parameter can be null, true, false or any data type.
This module doesn't parse arrays but you can actually parse comma-separated values using a reviver:
```javascript
var options = {
sections: true,
reviver: function (key, value, section){
//Do not split section lines
if (this.isSection) return this.assert ();
//Split all the string values by a comma
if (typeof value === "string"){
var values = value.split (",");
return values.length === 1 ? value : values;
}
//Do not split the rest of the lines
return this.assert ();
}
};
/*
[sec,tion]
key1 a,b,c
key2 true
*/
console.log (properties.parse ("[sec,tion]\n key1 a,b,c\n key2 true", options));
/*
{
"sec,tion": {
key1: ["a", "b", "c" ],
key2: true
}
}
*/
```
Look at the [reviver](https://github.com/gagle/node-properties/blob/master/examples/reviver/reviver.js) example for further details.

@@ -453,9 +499,11 @@

If you are in a platform that can handle utf8 strings, e.g. Node.js, you don't need to use this option.
- __replacer__ - _Function_
Each property or section can be removed or modified from the final string. It's similar to the replacer of the JSON.stringify function.
- __replacer__ - _Function_
Each property or section can be removed or modified from the final string. It's similar to the replacer of the `JSON.stringify()` function.
The replacer it's exatcly the same as the reviver from [parse()](#parse). The same function can be reused.
The callback gets three parameters: key, value and section.
A property has a key and a value and can belong to a section. If it's a global property the section is set to null. If __undefined__ is returned the property won't be stringified, otherwise the returned value will be used as the property value.
The callback gets three parameters: key, value and section.
A property has a key and a value and can belong to a section. If it's a global property the section is set to null. If __undefined__ is returned the property won't be stringified, otherwise the returned value will be used as the property value.
If the key and the value are set to null then it's a section line. If it returns a falsy value it won't be added to the final string, the entire section -including all the properties- will be discarded. If it returns a truthy value the section is stringified.

@@ -462,0 +510,0 @@

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