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

java-props

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

java-props - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0

48

dist/java-props.js

@@ -19,46 +19,6 @@ "use strict";

const result = Object.create(null);
const lr = new utils_1.LineReader(str);
let line;
while ((line = lr.readLine()) !== undefined) {
let keyLen = 0;
let valueStart = line.length;
let hasSep = false;
let backslash = false;
const lineLen = line.length;
let pos = 0;
for (; pos < lineLen; pos++) {
const c = line[pos];
if ((c === '=' || c === ':') && !backslash) {
valueStart = keyLen + 1;
hasSep = true;
break;
}
else if ((c === ' ' || c === '\t' || c === '\f') && !backslash) {
valueStart = keyLen + 1;
break;
}
if (c === '\\') {
backslash = !backslash;
}
else {
backslash = false;
}
keyLen++;
}
while (valueStart < lineLen) {
const c = line[valueStart];
if (c !== ' ' && c !== '\t' && c !== '\f') {
if (!hasSep && (c === '=' || c === ':')) {
hasSep = true;
}
else {
break;
}
}
valueStart++;
}
const key = utils_1.decodeLine(line.substring(0, keyLen));
const value = utils_1.decodeLine(line.substring(valueStart));
result[key] = value;
}
utils_1.rawParse(str, (res) => {
const key = utils_1.decodeLine(res.line.substring(0, res.sepStart));
result[key] = utils_1.decodeLine(res.line.substring(res.valueStart));
});
return result;

@@ -65,0 +25,0 @@ }

13

dist/utils.d.ts

@@ -0,1 +1,8 @@

export interface ParsedLine {
line: string;
sepStart: number;
valueStart: number;
}
export declare function rawParse(str: string, consumeFn: (res: ParsedLine) => void): void;
export declare function rawParseLine(line: string): ParsedLine;
export declare function decodeLine(line: string): string;

@@ -8,7 +15,7 @@ export declare function encodeLine(line: string, isKey?: boolean): string;

export declare class LineReader {
private readonly str;
private readonly strLen;
private pos;
readonly str: string;
readonly strLen: number;
pos: number;
constructor(str: string);
readLine(): string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LineReader = exports.convertLine = exports.encodeLine = exports.decodeLine = void 0;
exports.LineReader = exports.convertLine = exports.encodeLine = exports.decodeLine = exports.rawParseLine = exports.rawParse = void 0;
const DECODE_PATTERN = /(?:\\u(.{0,4})|\\(.?))/g;

@@ -8,2 +8,51 @@ const UNICODE_PATTERN = /^[0-9a-fA-F]{4}$/;

const ENCODE_KEY_PATTERN = /(?:[\u0000-\u0020!#:=\\\u007F-\uFFFF])/g; // ENCODE_PATTERN with separators + comments
function rawParse(str, consumeFn) {
const lr = new LineReader(str);
let line;
while ((line = lr.readLine()) !== undefined) {
consumeFn(rawParseLine(line));
}
}
exports.rawParse = rawParse;
function rawParseLine(line) {
let keyLen = 0;
let valueStart = line.length;
let hasSep = false;
let backslash = false;
const lineLen = line.length;
let pos = 0;
for (; pos < lineLen; pos++) {
const c = line[pos];
if ((c === '=' || c === ':') && !backslash) {
valueStart = keyLen + 1;
hasSep = true;
break;
}
else if ((c === ' ' || c === '\t' || c === '\f') && !backslash) {
valueStart = keyLen + 1;
break;
}
if (c === '\\') {
backslash = !backslash;
}
else {
backslash = false;
}
keyLen++;
}
while (valueStart < lineLen) {
const c = line[valueStart];
if (c !== ' ' && c !== '\t' && c !== '\f') {
if (!hasSep && (c === '=' || c === ':')) {
hasSep = true;
}
else {
break;
}
}
valueStart++;
}
return { line, sepStart: keyLen, valueStart };
}
exports.rawParseLine = rawParseLine;
function decodeLine(line) {

@@ -10,0 +59,0 @@ return line.replace(DECODE_PATTERN, (_, unicode, char) => {

{
"name": "java-props",
"version": "2.2.0",
"version": "2.3.0",
"description": "Read Java .properties files (using the same specification), without useless additional features.",

@@ -28,3 +28,3 @@ "author": "Nathan Poirier <nathan@poirier.io>",

"lint": "tslint -c ./tslint.json -p ./tsconfig.json",
"format": "prettier -w ./src ./test/**.ts *.md *.json *.js *.yml",
"format": "prettier -w ./src \"./test/**.ts\" \"*.md\" \"*.json\" \"*.js\" \"*.yml\"",
"test": "jest --coverage --verbose",

@@ -38,2 +38,3 @@ "test:watch": "yarn run test -- --watchAll",

"jest": "^24.9.0",
"prettier": "^2.5.1",
"rimraf": "^3.0.2",

@@ -40,0 +41,0 @@ "ts-jest": "^24.3.0",

@@ -45,3 +45,4 @@ # java-props

For detailed API Documentation, see: [https://nathan818fr.github.io/node-java-props/modules.html](https://nathan818fr.github.io/node-java-props/modules.html)
For a detailed API reference, see:
[node-java-props.nathan818.fr](https://node-java-props.nathan818.fr/modules.html)

@@ -56,11 +57,2 @@ ## Building

To generate the documentation, use typedoc:
```sh
npm install -g typedoc
typedoc
```
and copy the result inside this README.
## Testing

@@ -89,8 +81,7 @@

- [Nathan Poirier](https://github.com/nathan818fr) - Initial version
- [Nathan Poirier](https://github.com/nathan818fr) &lt;nathan@poirier.io&gt;
See also the list of [contributors](https://github.com/nathan818fr/node-java-props/contributors) who participated in this project.
## License
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
This project is licensed under the MIT License.
See the [LICENSE](https://github.com/nathan818fr/node-java-props/blob/master/LICENSE) file for details.

Sorry, the diff of this file is not supported yet

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