properties-file 3.2.9 → 3.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/lib/editor/index.js +21 -21
- package/lib/escape/index.js +5 -5
- package/lib/index.js +2 -2
- package/lib/loader/webpack.js +2 -2
- package/lib/properties.js +17 -18
- package/lib/property-line.js +4 -4
- package/lib/property.js +15 -15
- package/lib/unescape/index.js +3 -3
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/properties-file)
|
|
5
5
|

|
|
6
6
|

|
|
7
|
-
[](https://snyk.io/test/github/Avansai/properties-file?targetFile=package.json)
|
|
8
7
|
|
|
9
8
|
`.properties` file parser, editor, formatter and Webpack loader.
|
|
10
9
|
|
package/lib/editor/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PropertiesEditor=exports.DEFAULT_SEPARATOR=exports.DEFAULT_COMMENT_DELIMITER=void 0;var _escape=require("../escape"),_properties=require("../properties")
|
|
1
|
+
"use strict";function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.PropertiesEditor=exports.DEFAULT_SEPARATOR=exports.DEFAULT_COMMENT_DELIMITER=void 0;var _escape=require("../escape"),_properties=require("../properties");function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_unsupportedIterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _iterableToArray(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a))return _arrayLikeToArray(a)}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}function _inherits(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),Object.defineProperty(a,"prototype",{writable:!1}),b&&_setPrototypeOf(a,b)}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _possibleConstructorReturn(a,b){if(b&&("object"===_typeof(b)||"function"==typeof b))return b;if(void 0!==b)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(a)}function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}function _getPrototypeOf(a){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(a){return a.__proto__||Object.getPrototypeOf(a)},_getPrototypeOf(a)}/** The default separator between keys and values. */var DEFAULT_SEPARATOR="=";/** The default character used as comment delimiter. */exports.DEFAULT_SEPARATOR="=";var DEFAULT_COMMENT_DELIMITER="#";/** Characters that can be used as key-value pair separators. */ /** Characters that can be used as comment delimiters. */ /** Options on the `Properties.insert` method. */ /** Options on the `Properties.insertComment` method. */ /** Options on the `Properties.update` method. */ /** Options on the `Properties.upsert` method. */exports.DEFAULT_COMMENT_DELIMITER="#";/**
|
|
2
2
|
* A .properties file editor.
|
|
3
|
-
*/
|
|
3
|
+
*/var PropertiesEditor=/*#__PURE__*/function(a){/**
|
|
4
4
|
* Create `PropertiesEditor` object.
|
|
5
5
|
*
|
|
6
6
|
* @param content - The content of a `.properties` file.
|
|
7
|
-
*/
|
|
7
|
+
*/function b(a){return _classCallCheck(this,b),c.call(this,a)}/**
|
|
8
8
|
* Insert a new property in the existing object (by default it will be at the end).
|
|
9
9
|
*
|
|
10
10
|
* @param key - A property key (unescaped).
|
|
@@ -12,56 +12,56 @@
|
|
|
12
12
|
* @param options - Additional options.
|
|
13
13
|
*
|
|
14
14
|
* @returns True if the key was inserted, otherwise false.
|
|
15
|
-
*/insert(a,b,c){
|
|
15
|
+
*/_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"insert",value:function insert(a,b,c){var d=(null===c||void 0===c?void 0:c.escapeUnicode)||!1,e=null!==c&&void 0!==c&&c.separator?" "===c.separator?" ":" ".concat(c.separator," "):" ".concat(DEFAULT_SEPARATOR," ").replace(" "," "),f=null===c||void 0===c?void 0:c.referenceKey,g=(null===c||void 0===c?void 0:c.position)||"after",h=a.split(/\r?\n/).map(function(a){return(0,_escape.escapeKey)(a,d)}).join("\\\n"),i=b.split(/\r?\n/).map(function(a){return(0,_escape.escapeValue)(a,d)}).join("\\\n"),j="".concat((null===c||void 0===c?void 0:c.commentDelimiter)||DEFAULT_COMMENT_DELIMITER," "),k=void 0===(null===c||void 0===c?void 0:c.comment)?"":"".concat("".concat(j).concat(c.comment).split(/\r?\n/).join("\n".concat(j)),"\n"),l="".concat(k).concat(h).concat(e).concat(i).split(/\n/);// Allow multiline keys.
|
|
16
16
|
// Allow multiline values.
|
|
17
17
|
// Allow multiline comments.
|
|
18
|
-
if(void 0===f)return
|
|
19
|
-
|
|
20
|
-
if(
|
|
18
|
+
if(void 0===f){var m;return(m=this.lines).push.apply(m,_toConsumableArray(l)),this.parseLines(),!0}// Find the last occurrence of the reference key.
|
|
19
|
+
var n=_toConsumableArray(this.collection).reverse().find(function(a){return a.key===f});// Insert the new property when a reference key defined only when found.
|
|
20
|
+
if(n){var o,p,q="after"===g?n.endingLineNumber:null!==(o=null===(p=n.previousProperty)||void 0===p?void 0:p.endingLineNumber)&&void 0!==o?o:0;return this.lines=[].concat(_toConsumableArray(this.lines.slice(0,q)),_toConsumableArray(l),_toConsumableArray(this.lines.slice(q))),this.parseLines(),!0}return!1}/**
|
|
21
21
|
* Insert a new comment in the existing object (by default it will be at the end).
|
|
22
22
|
*
|
|
23
23
|
* @param comment - The comment to add.
|
|
24
24
|
* @param options - Additional options.
|
|
25
25
|
*
|
|
26
26
|
* @returns True if the comment was inserted, otherwise false.
|
|
27
|
-
*/insertComment(a,b){
|
|
28
|
-
if(void 0===c)return
|
|
29
|
-
|
|
30
|
-
if(
|
|
27
|
+
*/},{key:"insertComment",value:function insertComment(a,b){var c=null===b||void 0===b?void 0:b.referenceKey,d=(null===b||void 0===b?void 0:b.position)||"after",e="".concat((null===b||void 0===b?void 0:b.commentDelimiter)||DEFAULT_COMMENT_DELIMITER," "),f="".concat(e).concat(a).replace(/\r?\n/g,"\n".concat(e)).split(/\n/);// Allow multiline comments.
|
|
28
|
+
if(void 0===c){var g;return(g=this.lines).push.apply(g,_toConsumableArray(f)),this.parseLines(),!0}// Find the last occurrence of the reference key.
|
|
29
|
+
var h=_toConsumableArray(this.collection).reverse().find(function(a){return a.key===c});// Insert the new comment when a reference key defined only when found.
|
|
30
|
+
if(h){var i,j,k="after"===d?h.endingLineNumber:null!==(i=null===(j=h.previousProperty)||void 0===j?void 0:j.endingLineNumber)&&void 0!==i?i:0;return this.lines=[].concat(_toConsumableArray(this.lines.slice(0,k)),_toConsumableArray(f),_toConsumableArray(this.lines.slice(k))),this.parseLines(),!0}return!1}/**
|
|
31
31
|
* Delete the last occurrence of a given key from the existing object.
|
|
32
32
|
*
|
|
33
33
|
* @param key - The name of the key to delete.
|
|
34
34
|
* @param deleteCommentsAndWhiteSpace - By default, comments and white-space characters before the key will be deleted.
|
|
35
35
|
*
|
|
36
36
|
* @returns True if the key was deleted, otherwise false.
|
|
37
|
-
*/delete(a){
|
|
38
|
-
|
|
37
|
+
*/},{key:"delete",value:function _delete(a){var b=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],c=_toConsumableArray(this.collection).reverse().find(function(b){return b.key===a});// Find the last occurrence of the key.
|
|
38
|
+
if(c){var d,e,f=b?null!==(d=null===(e=c.previousProperty)||void 0===e?void 0:e.endingLineNumber)&&void 0!==d?d:0:c.startingLineNumber-1,g=c.endingLineNumber;return this.lines=[].concat(_toConsumableArray(this.lines.slice(0,f)),_toConsumableArray(this.lines.slice(g))),this.parseLines(),!0}return!1}/**
|
|
39
39
|
* Restore the original newline characters of a key.
|
|
40
40
|
*
|
|
41
41
|
* @param property - A property object.
|
|
42
42
|
*
|
|
43
43
|
* @returns The key with its original newlines characters restored.
|
|
44
|
-
*/getKeyWithNewlines(a){return 0===a.newlinePositions.length?a.key:// eslint-disable-next-line unicorn/no-array-reduce
|
|
45
|
-
|
|
44
|
+
*/},{key:"getKeyWithNewlines",value:function getKeyWithNewlines(a){return 0===a.newlinePositions.length?a.key:// eslint-disable-next-line unicorn/no-array-reduce
|
|
45
|
+
_toConsumableArray(a.key).reduce(function(b,c,d){return"".concat(b).concat(a.newlinePositions.includes(d)?"\n":"").concat(c)},"")}/**
|
|
46
46
|
* Restore the original newline characters of a value.
|
|
47
47
|
*
|
|
48
48
|
* @param property - A property object.
|
|
49
49
|
*
|
|
50
50
|
* @returns The value with its original newlines characters restored.
|
|
51
|
-
*/getValueWithNewlines(a){return 0===a.newlinePositions.length||a.valuePosition
|
|
52
|
-
|
|
51
|
+
*/},{key:"getValueWithNewlines",value:function getValueWithNewlines(a){return 0===a.newlinePositions.length||void 0===a.valuePosition?a.value:// eslint-disable-next-line unicorn/no-array-reduce
|
|
52
|
+
_toConsumableArray(a.value).reduce(function(b,c,d){return"".concat(b).concat(a.newlinePositions.includes(d+a.valuePosition)?"\n":"").concat(c)},"")}/**
|
|
53
53
|
* Update the last occurrence of a given key from the existing object.
|
|
54
54
|
*
|
|
55
55
|
* @param key - The name of the key to update.
|
|
56
56
|
* @param options - Additional options.
|
|
57
57
|
*
|
|
58
58
|
* @returns True if the key was updated, otherwise false.
|
|
59
|
-
*/update(a,b){var c,d,e,f;// Find the last occurrence of the key to update.
|
|
60
|
-
|
|
59
|
+
*/},{key:"update",value:function update(a,b){var c,d,e,f,g=_toConsumableArray(this.collection).reverse().find(function(b){return b.key===a});// Find the last occurrence of the key to update.
|
|
60
|
+
if(!g||!b)return!1;var h=b.escapeUnicode||!1,i=b.separator?" "===b.separator?" ":" ".concat(b.separator," "):g.separator||" ".concat(DEFAULT_SEPARATOR," ").replace(" "," "),j=(null!==(c=b.newKey)&&void 0!==c?c:this.getKeyWithNewlines(g)).split(/\r?\n/).map(function(a){return(0,_escape.escapeKey)(a,h)}).join("\\\n"),k=(null!==(d=b.newValue)&&void 0!==d?d:this.getValueWithNewlines(g)).split(/\r?\n/).map(function(a){return(0,_escape.escapeValue)(a,h)}).join("\\\n"),l="".concat(b.commentDelimiter||DEFAULT_COMMENT_DELIMITER," "),m=void 0===b.newComment?"":"".concat("".concat(l).concat(b.newComment).split(/\r?\n/).join("\n".concat(l)),"\n"),n="".concat(m).concat(j).concat(i).concat(k).split(/\n/);// Allow multiline keys.
|
|
61
61
|
// Allow multiline values.
|
|
62
62
|
// Allow multiline comments.
|
|
63
63
|
// Replace the existing property with the new one.
|
|
64
|
-
return this.lines=[
|
|
64
|
+
return this.lines=[].concat(_toConsumableArray(this.lines.slice(0,void 0===b.newComment?g.startingLineNumber-1:null!==(e=null===(f=g.previousProperty)||void 0===f?void 0:f.endingLineNumber)&&void 0!==e?e:0)),_toConsumableArray(n),_toConsumableArray(this.lines.slice(g.endingLineNumber))),this.parseLines(),!0}/**
|
|
65
65
|
* Update a key if it exist, otherwise add it at the end.
|
|
66
66
|
*
|
|
67
67
|
* @param key - A property key (unescaped).
|
|
@@ -69,4 +69,4 @@ return this.lines=[...this.lines.slice(0,void 0===b.newComment?g.startingLineNum
|
|
|
69
69
|
* @param options - Additional options.
|
|
70
70
|
*
|
|
71
71
|
* @returns True if the key was updated or inserted, otherwise false.
|
|
72
|
-
*/upsert(a,b,c){return this.keyLineNumbers[a]?this.update(a,{newValue:b,newComment:null===c||void 0===c?void 0:c.comment,commentDelimiter:null===c||void 0===c?void 0:c.commentDelimiter,separator:null===c||void 0===c?void 0:c.separator,escapeUnicode:null===c||void 0===c?void 0:c.escapeUnicode}):this.insert(a,b,c)}}exports.PropertiesEditor=PropertiesEditor;
|
|
72
|
+
*/},{key:"upsert",value:function upsert(a,b,c){return this.keyLineNumbers[a]?this.update(a,{newValue:b,newComment:null===c||void 0===c?void 0:c.comment,commentDelimiter:null===c||void 0===c?void 0:c.commentDelimiter,separator:null===c||void 0===c?void 0:c.separator,escapeUnicode:null===c||void 0===c?void 0:c.escapeUnicode}):this.insert(a,b,c)}}]),b}(_properties.Properties);exports.PropertiesEditor=PropertiesEditor;
|
package/lib/escape/index.js
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
* @param escapeUnicode - Escape unicode characters into ISO-8859-1 compatible encoding?
|
|
6
6
|
*
|
|
7
7
|
* @return The escaped key.
|
|
8
|
-
*/
|
|
8
|
+
*/var escapeKey=function(a){var b=!!(1<arguments.length&&arguments[1]!==void 0)&&arguments[1];return escapeContent(a,!0,b)};/**
|
|
9
9
|
* Escape property value.
|
|
10
10
|
*
|
|
11
11
|
* @param unescapedValue - Property value to be escaped.
|
|
12
12
|
* @param escapeUnicode - Escape unicode characters into ISO-8859-1 compatible encoding?
|
|
13
13
|
*
|
|
14
14
|
* @return The escaped value.
|
|
15
|
-
*/exports.escapeKey=escapeKey;
|
|
15
|
+
*/exports.escapeKey=escapeKey;var escapeValue=function(a){var b=!!(1<arguments.length&&arguments[1]!==void 0)&&arguments[1];return escapeContent(a,!1,b)};/**
|
|
16
16
|
* Escape the content from either key or value of a property.
|
|
17
17
|
*
|
|
18
18
|
* @param unescapedContent - The content to escape.
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* @param escapeUnicode - Escape unicode characters into ISO-8859-1 compatible encoding?
|
|
21
21
|
*
|
|
22
22
|
* @returns The unescaped content.
|
|
23
|
-
*/exports.escapeValue=escapeValue;
|
|
24
|
-
case"\\":{d+="\\\\";break}case"\f":{d+="\\f";break}case"\n":{d+="\\n";break}case"\r":{d+="\\r";break}case"\t":{d+="\\t";break}case"=":case":":case"#":case"!":{d+="\\".concat(e);break}default:{if(c){
|
|
25
|
-
if(32>
|
|
23
|
+
*/exports.escapeValue=escapeValue;var escapeContent=function(a,b,c){for(var d="",e=a[0],f=0;f<a.length;f++,e=a[f])switch(e){case" ":{d+=b||0===f?"\\ ":" ";break}// Backslash.
|
|
24
|
+
case"\\":{d+="\\\\";break}case"\f":{d+="\\f";break}case"\n":{d+="\\n";break}case"\r":{d+="\\r";break}case"\t":{d+="\\t";break}case"=":case":":case"#":case"!":{d+="\\".concat(e);break}default:{if(c){var g=e.codePointAt(0);// Can never be `undefined`.
|
|
25
|
+
if(32>g||126<g){d+="\\u".concat(g.toString(16).padStart(4,"0"));break}}// Non-escapable characters.
|
|
26
26
|
d+=e;break}}return d};
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"Properties",{enumerable:!0,get:function get(){return _properties.Properties}}),exports.getProperties=void 0;var _properties=require("./properties"),getProperties=function(a){return new _properties.Properties(a).toObject()};/**
|
|
2
2
|
* A key-value pair object.
|
|
3
3
|
*/ /**
|
|
4
4
|
* Converts the content of a `.properties` file to a key-value pair object.
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* @param content - The content of a `.properties` file.
|
|
7
7
|
*
|
|
8
8
|
* @returns A key/value object representing the content of a `.properties` file.
|
|
9
|
-
*/
|
|
9
|
+
*/exports.getProperties=getProperties;
|
package/lib/loader/webpack.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _=require(".."),webpackLoader=function(a){return"module.exports = ".concat(JSON.stringify((0,_.getProperties)(a)),";")},_default=webpackLoader;/**
|
|
2
2
|
* Webpack file loader for `.properties` files.
|
|
3
3
|
*
|
|
4
4
|
* @param content - the content of a `.properties` file.
|
|
5
5
|
*
|
|
6
6
|
* @returns A Webpack file loader string containing the content of a `.properties` file.
|
|
7
|
-
*/
|
|
7
|
+
*/exports.default=_default;
|
package/lib/properties.js
CHANGED
|
@@ -1,52 +1,51 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getFirstEolCharacter=exports.Properties=exports.KeyCollisions=exports.DEFAULT_END_OF_LINE_CHARACTER=exports.BOM_CODE_POINT=exports.BOM=void 0;var _property=require("./property"),_propertyLine=require("./property-line");function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getFirstEolCharacter=exports.Properties=exports.KeyCollisions=exports.DEFAULT_END_OF_LINE_CHARACTER=exports.BOM_CODE_POINT=exports.BOM=void 0;var _property=require("./property"),_propertyLine=require("./property-line");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(a,b){var c=null==a?null:"undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(null!=c){var d,e,f,g,h=[],i=!0,j=!1;try{if(f=(c=c.call(a)).next,0===b){if(Object(c)!==c)return;i=!1}else for(;!(i=(d=f.call(c)).done)&&(h.push(d.value),h.length!==b);i=!0);}catch(a){j=!0,e=a}finally{try{if(!i&&null!=c.return&&(g=c.return(),Object(g)!==g))return}finally{if(j)throw e}}return h}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c.return||c.return()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}/**
|
|
2
2
|
* Byte-order mark.
|
|
3
|
-
*/
|
|
3
|
+
*/var BOM="\uFEFF";exports.BOM="\uFEFF";var BOM_CODE_POINT="\uFEFF".codePointAt(0);/** The default end of line character. */exports.BOM_CODE_POINT=65279;var DEFAULT_END_OF_LINE_CHARACTER="\n";/**
|
|
4
4
|
* Get the first end of line (EOL) character from multiline content.
|
|
5
5
|
*
|
|
6
6
|
* @param content - The content of a `.properties` file.
|
|
7
7
|
*
|
|
8
8
|
* @returns The multiline content's first end of line (EOL) character.
|
|
9
|
-
*/exports.DEFAULT_END_OF_LINE_CHARACTER="\n";
|
|
9
|
+
*/exports.DEFAULT_END_OF_LINE_CHARACTER="\n";var getFirstEolCharacter=function(a){var b=a.indexOf("\n");return 0>b?void 0:"".concat("\r"===a[b-1]?"\r":"","\n")};/**
|
|
10
10
|
* A class representing the content of a .properties file.
|
|
11
|
-
*/exports.getFirstEolCharacter=getFirstEolCharacter;
|
|
11
|
+
*/exports.getFirstEolCharacter=getFirstEolCharacter;var Properties=/*#__PURE__*/function(){/**
|
|
12
12
|
* Create `Properties` object.
|
|
13
13
|
*
|
|
14
14
|
* @param content - The content of a `.properties` file.
|
|
15
|
-
*/
|
|
15
|
+
*/function a(b){var c;_classCallCheck(this,a),_defineProperty(this,"collection",[]),_defineProperty(this,"keyLineNumbers",{});var d="string"==typeof b?b:b.toString();this.hasBom=d.codePointAt(0)===BOM_CODE_POINT,this.eolCharacter=null!==(c=getFirstEolCharacter(d))&&void 0!==c?c:DEFAULT_END_OF_LINE_CHARACTER,this.lines=(this.hasBom?d.slice(1):d).split(/\r?\n/),this.parseLines()}/**
|
|
16
16
|
* Parse the `.properties` content line by line.
|
|
17
|
-
*/parseLines(){this.collection=[],this.keyLineNumbers={};/** Line number while parsing properties file content. */
|
|
18
|
-
if(
|
|
17
|
+
*/return _createClass(a,[{key:"parseLines",value:function parseLines(){this.collection=[],this.keyLineNumbers={};/** Line number while parsing properties file content. */var a,b,c,d=0,e=_createForOfIteratorHelper(this.lines);/** The current property object being parsed. */ /** The previous property object that was parsed. */try{for(e.s();!(c=e.n()).done;){var f=c.value;d++;var g=new _propertyLine.PropertyLine(f,!!a);if(!a){// Check if the line is a new property.
|
|
18
|
+
if(g.isComment||g.isBlank)continue;// Skip line if its a comment or blank.
|
|
19
19
|
// The line is a new property.
|
|
20
|
-
if(a=new _property.Property(
|
|
21
|
-
}else if(a.addLine(
|
|
22
|
-
this.addToCollection(a),b=a,a=void 0}}/**
|
|
20
|
+
if(a=new _property.Property(g,d,b),g.isContinuing)continue;// Continue parsing the next line.
|
|
21
|
+
}else if(a.addLine(g),g.isContinuing)continue;// If the line does not continue, add the property to the collection.
|
|
22
|
+
this.addToCollection(a),b=a,a=void 0}}catch(a){e.e(a)}finally{e.f()}}/**
|
|
23
23
|
* Add a property object into a properties object collection.
|
|
24
24
|
*
|
|
25
25
|
* @param property - A property object, or undefined.
|
|
26
26
|
*
|
|
27
27
|
* @returns Undefined so that we conveniently overwrite the property object.
|
|
28
|
-
*/addToCollection(a){var b
|
|
29
|
-
a.setKeyAndValue(),null!==(b=this.keyLineNumbers[a.key])&&void 0!==b&&b.length?(this.keyLineNumbers[a.key].push(a.startingLineNumber),a.hasKeyCollisions=!0,a.keyCollisionLines=this.keyLineNumbers[a.key],this.collection=this.collection.filter(b=>b.key!==a.key)):this.keyLineNumbers[a.key]=[a.startingLineNumber],this.collection.push(a)}/**
|
|
28
|
+
*/},{key:"addToCollection",value:function addToCollection(a){var b;a.setKeyAndValue(),null!==(b=this.keyLineNumbers[a.key])&&void 0!==b&&b.length?(this.keyLineNumbers[a.key].push(a.startingLineNumber),a.hasKeyCollisions=!0,a.keyCollisionLines=this.keyLineNumbers[a.key],this.collection=this.collection.filter(function(b){return b.key!==a.key})):this.keyLineNumbers[a.key]=[a.startingLineNumber],this.collection.push(a)}/**
|
|
30
29
|
* Get keys that have collisions (more than one occurrence).
|
|
31
|
-
*/getKeyCollisions(){
|
|
30
|
+
*/},{key:"getKeyCollisions",value:function getKeyCollisions(){for(var a=[],b=0,c=Object.entries(this.keyLineNumbers);b<c.length;b++){var d=_slicedToArray(c[b],2),e=d[0],f=d[1];1<f.length&&a.push(new KeyCollisions(e,f))}return a}/**
|
|
32
31
|
* Get the key/value object representing the properties.
|
|
33
32
|
*
|
|
34
33
|
* @returns A key/value object representing the properties.
|
|
35
|
-
*/toObject(){
|
|
34
|
+
*/},{key:"toObject",value:function toObject(){var a={};return this.collection.forEach(function(b){a[b.key]=b.value}),a}/**
|
|
36
35
|
* Format the object in `.properties`.
|
|
37
36
|
*
|
|
38
37
|
* @param endOfLineCharacter - The character used for end of lines.
|
|
39
38
|
*
|
|
40
39
|
* @returns The object in `.properties` format.
|
|
41
|
-
*/format(a){return"".concat(this.hasBom?BOM:"").concat(this.lines.join(a||this.eolCharacter))}}
|
|
40
|
+
*/},{key:"format",value:function format(a){return"".concat(this.hasBom?BOM:"").concat(this.lines.join(a||this.eolCharacter))}}]),a}();/**
|
|
42
41
|
* Object associating keys with their line numbers.
|
|
43
42
|
*/exports.Properties=Properties;/**
|
|
44
43
|
* A class representing key within a .properties file that had collisions (more than one occurrence).
|
|
45
|
-
*/
|
|
44
|
+
*/var KeyCollisions=/*#__PURE__*/function(){/** The key with collisions. */ /** The starting line numbers where collisions are found. */ /**
|
|
46
45
|
* Create a new key collision object.
|
|
47
46
|
*
|
|
48
47
|
* @param key - The key with collisions.
|
|
49
48
|
* @param startingLineNumbers - The starting line numbers where collisions are found.
|
|
50
|
-
*/
|
|
49
|
+
*/function a(b,c){_classCallCheck(this,a),this.key=b,this.startingLineNumbers=c}/**
|
|
51
50
|
* Get the number of the line from which the value will be used.
|
|
52
|
-
*/getApplicableLineNumber(){return this.startingLineNumbers.slice(-1)[0]}}exports.KeyCollisions=KeyCollisions;
|
|
51
|
+
*/return _createClass(a,[{key:"getApplicableLineNumber",value:function getApplicableLineNumber(){return this.startingLineNumbers.slice(-1)[0]}}]),a}();exports.KeyCollisions=KeyCollisions;
|
package/lib/property-line.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PropertyLine=void 0;function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PropertyLine=void 0;function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _wrapRegExp(){function a(b,c,e){var f=new RegExp(b,c);return d.set(f,e||d.get(b)),_setPrototypeOf(f,a.prototype)}function b(a,b){var c=d.get(b);return Object.keys(c).reduce(function(b,d){var e=c[d];if("number"==typeof e)b[d]=a[e];else{for(var f=0;void 0===a[e[f]]&&f+1<e.length;)f++;b[d]=a[e[f]]}return b},Object.create(null))}_wrapRegExp=function(b,c){return new a(b,void 0,c)};var c=RegExp.prototype,d=new WeakMap;return _inherits(a,RegExp),a.prototype.exec=function(a){var d=c.exec.call(this,a);if(d){d.groups=b(d,this);var e=d.indices;e&&(e.groups=b(e,this))}return d},a.prototype[Symbol.replace]=function(a,e){if("string"==typeof e){var f=d.get(this);return c[Symbol.replace].call(this,a,e.replace(/\$<([^>]+)>/g,function(a,b){var c=f[b];return"$"+(Array.isArray(c)?c.join("$"):c)}))}if("function"==typeof e){var g=this;return c[Symbol.replace].call(this,a,function(){var a=arguments;return"object"!=_typeof(a[a.length-1])&&(a=[].slice.call(a)).push(b(a,g)),e.apply(this,a)})}return c[Symbol.replace].call(this,a,e)},_wrapRegExp.apply(this,arguments)}function _inherits(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),Object.defineProperty(a,"prototype",{writable:!1}),b&&_setPrototypeOf(a,b)}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}/**
|
|
2
2
|
* Object representing a line from the content of .properties file.
|
|
3
|
-
*/
|
|
3
|
+
*/var PropertyLine=/*#__PURE__*/_createClass(/** Is the line object a continuation from a previous line? */ /**
|
|
4
4
|
* Create a new line object.
|
|
5
5
|
*
|
|
6
6
|
* @param line - The raw content of a line.
|
|
7
7
|
* @param isMultiline - Is the line spreading on multiple lines?
|
|
8
|
-
*/
|
|
9
|
-
|
|
8
|
+
*/function c(a,b){if(_classCallCheck(this,c),_defineProperty(this,"isContinuing",!1),_defineProperty(this,"isBlank",!1),_defineProperty(this,"isComment",!1),this.content=a.trimStart(),this.isMultiline=b,0===this.content.length)this.isBlank=!0;else if(this.isMultiline||(this.isComment=!!/^[!#]/.test(this.content)),!this.isComment){// Otherwise, check if the line is continuing on the next line.
|
|
9
|
+
var d=this.content.match(/*#__PURE__*/_wrapRegExp(/(\\+)$/,{backslashes:1}));null!==d&&void 0!==d&&d.groups&&(this.isContinuing=!!(d.groups.backslashes.length%2),this.isContinuing&&(this.content=this.content.slice(0,-1)))}});exports.PropertyLine=PropertyLine;
|
package/lib/property.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
"use strict";var _unescape=require("./unescape");Object.defineProperty(exports,"__esModule",{value:!0}),exports.Property=void 0;function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"
|
|
1
|
+
"use strict";var _unescape=require("./unescape");Object.defineProperty(exports,"__esModule",{value:!0}),exports.Property=void 0;function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _wrapRegExp(){function a(b,c,e){var f=new RegExp(b,c);return d.set(f,e||d.get(b)),_setPrototypeOf(f,a.prototype)}function b(a,b){var c=d.get(b);return Object.keys(c).reduce(function(b,d){var e=c[d];if("number"==typeof e)b[d]=a[e];else{for(var f=0;void 0===a[e[f]]&&f+1<e.length;)f++;b[d]=a[e[f]]}return b},Object.create(null))}_wrapRegExp=function(b,c){return new a(b,void 0,c)};var c=RegExp.prototype,d=new WeakMap;return _inherits(a,RegExp),a.prototype.exec=function(a){var d=c.exec.call(this,a);if(d){d.groups=b(d,this);var e=d.indices;e&&(e.groups=b(e,this))}return d},a.prototype[Symbol.replace]=function(a,e){if("string"==typeof e){var f=d.get(this);return c[Symbol.replace].call(this,a,e.replace(/\$<([^>]+)>/g,function(a,b){var c=f[b];return"$"+(Array.isArray(c)?c.join("$"):c)}))}if("function"==typeof e){var g=this;return c[Symbol.replace].call(this,a,function(){var a=arguments;return"object"!=_typeof(a[a.length-1])&&(a=[].slice.call(a)).push(b(a,g)),e.apply(this,a)})}return c[Symbol.replace].call(this,a,e)},_wrapRegExp.apply(this,arguments)}function _inherits(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),Object.defineProperty(a,"prototype",{writable:!1}),b&&_setPrototypeOf(a,b)}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}/**
|
|
2
2
|
* Object representing a property (key/value).
|
|
3
|
-
*/
|
|
3
|
+
*/var Property=/*#__PURE__*/function(){/** The line number at which the property starts. */ /** The line number at which the property ends. */ /** The previous property object if it exists. */ /** The next property object if it exists. */ /**
|
|
4
4
|
* Create a new property object.
|
|
5
5
|
*
|
|
6
6
|
* @param propertyLine - A property line object.
|
|
7
7
|
* @param startingLineNumber - The line number at which the property starts.
|
|
8
|
-
*/
|
|
8
|
+
*/function a(b,c,d){_classCallCheck(this,a),_defineProperty(this,"key",""),_defineProperty(this,"escapedKey",""),_defineProperty(this,"hasNoKey",!1),_defineProperty(this,"hasMultilineKey",!1),_defineProperty(this,"keyCollisionLines",[]),_defineProperty(this,"hasKeyCollisions",!1),_defineProperty(this,"value",""),_defineProperty(this,"escapedValue",""),_defineProperty(this,"hasNoValue",!1),_defineProperty(this,"newlinePositions",[]),this.linesContent=b.content,this.startingLineNumber=c,this.endingLineNumber=c,this.previousProperty=d,null===d||void 0===d?void 0:d.setNextProperty(this)}/**
|
|
9
9
|
* Set the next property object.
|
|
10
10
|
*
|
|
11
11
|
* @param property - The next property object
|
|
12
|
-
*/setNextProperty(a){this.nextProperty=a}/**
|
|
12
|
+
*/return _createClass(a,[{key:"setNextProperty",value:function setNextProperty(a){this.nextProperty=a}/**
|
|
13
13
|
* Add the a line to a multiline property object.
|
|
14
14
|
*
|
|
15
15
|
* @param propertyLine - A property line object.
|
|
16
|
-
*/addLine(a){0<this.linesContent.length&&(this.newlinePositions.push(this.linesContent.length),this.endingLineNumber++),this.linesContent+=a.content}/**
|
|
16
|
+
*/},{key:"addLine",value:function addLine(a){0<this.linesContent.length&&(this.newlinePositions.push(this.linesContent.length),this.endingLineNumber++),this.linesContent+=a.content}/**
|
|
17
17
|
* Set the property's key and value.
|
|
18
|
-
*/setKeyAndValue(){this.findSeparator(),this.separatorPosition
|
|
18
|
+
*/},{key:"setKeyAndValue",value:function setKeyAndValue(){this.findSeparator(),void 0!==this.separatorPosition&&void 0!==this.separatorLength?(!this.hasNoKey&&(this.escapedKey=this.linesContent.slice(0,this.separatorPosition),this.key=this.unescapeLine(this.escapedKey,this.startingLineNumber)),!this.hasNoValue&&(this.escapedValue=this.linesContent.slice(this.separatorPosition+this.separatorLength),this.value=this.unescapeLine(this.escapedValue,this.startingLineNumber))):this.hasNoValue&&(this.escapedKey=this.linesContent,this.key=this.unescapeLine(this.escapedKey,this.startingLineNumber))}/**
|
|
19
19
|
* Unescape the content from either key or value of a property.
|
|
20
20
|
*
|
|
21
21
|
* @param escapedContent - The content to unescape.
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
*
|
|
26
26
|
* @throws {@link Error}
|
|
27
27
|
* This exception is thrown if malformed escaped unicode characters are present.
|
|
28
|
-
*/unescapeLine(a,b){try{return(0,_unescape.unescapeContent)(a)}catch(a){throw new Error("".concat(a.message," in property starting at line ").concat(b))}}/**
|
|
28
|
+
*/},{key:"unescapeLine",value:function unescapeLine(a,b){try{return(0,_unescape.unescapeContent)(a)}catch(a){throw new Error("".concat(a.message," in property starting at line ").concat(b))}}/**
|
|
29
29
|
* Find the character separating the key from the value.
|
|
30
|
-
*/findSeparator(){// If the separator was already found, skip.
|
|
31
|
-
if(!(this.hasNoKey||this.hasNoValue||this.separatorPosition)){for(
|
|
32
|
-
if(
|
|
33
|
-
|
|
34
|
-
continue}}
|
|
35
|
-
|
|
30
|
+
*/},{key:"findSeparator",value:function findSeparator(){// If the separator was already found, skip.
|
|
31
|
+
if(!(this.hasNoKey||this.hasNoValue||this.separatorPosition)){for(var a=this.linesContent[0],b=0;b<this.linesContent.length;b++,a=this.linesContent[b]){var c;// If the character is not a separator, check the next one.
|
|
32
|
+
if(/[\t\f :=]/.test(a)){// Check if the separator might be escaped.
|
|
33
|
+
var d=b?this.linesContent.slice(0,b):"";if(0<d.length){var e=d.match(/*#__PURE__*/_wrapRegExp(/(\\+)$/,{backslashes:1}));if(null!==e&&void 0!==e&&e.groups){var f=!!(e.groups.backslashes.length%2);if(f)// If the separator is escaped, check the next character.
|
|
34
|
+
continue}}var g="";this.separatorPosition=b;// Check if the separator starts with a whitespace.
|
|
35
|
+
var h=this.linesContent.slice(b),i=h.match(/*#__PURE__*/_wrapRegExp(/^(\s+)/,{whitespace:1})),j=(null===i||void 0===i||null===(c=i.groups)||void 0===c?void 0:c.whitespace)||"";// If there is a whitespace, move to the next character.
|
|
36
36
|
// Check if there is an equal or colon character.
|
|
37
|
-
if(0<
|
|
38
|
-
|
|
37
|
+
if(0<j.length&&(g+=j,h=h.slice(j.length)),/[:=]/.test(h[0])){var k;g+=h[0],h=h.slice(1);// If an equal or colon character was found, try to get trailing whitespace.
|
|
38
|
+
var l=h.match(/*#__PURE__*/_wrapRegExp(/^(\s+)/,{whitespace:1})),m=(null===l||void 0===l||null===(k=l.groups)||void 0===k?void 0:k.whitespace)||"";g+=m}this.separatorLength=g.length,this.valuePosition=this.separatorPosition+this.separatorLength,this.separator=this.linesContent.slice(this.separatorPosition,this.separatorPosition+this.separatorLength),b||(this.hasNoKey=!0);break}}void 0===this.separatorPosition?this.hasNoValue=!0:0<this.newlinePositions.length&&this.newlinePositions[0]<this.separatorPosition&&(this.hasMultilineKey=!0)}}}]),a}();exports.Property=Property;
|
package/lib/unescape/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @throws {@link Error}
|
|
9
9
|
* This exception is thrown if malformed escaped unicode characters are present.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
throw new Error("malformed escaped unicode characters '\\u".concat(
|
|
10
|
+
*/var unescapeContent=function(a){for(var b="",c=a[0],d=0;d<a.length;d++,c=a[d])if("\\"===c){var e=a[d+1];switch(e){case"f":{b+="\f",d++;break}case"n":{b+="\n",d++;break}case"r":{b+="\r",d++;break}case"t":{b+="\t",d++;break}case"u":{// Unicode character.
|
|
11
|
+
var f=a.slice(d+2,d+6);if(!/[\da-f]{4}/i.test(f))// Code point can only be within Unicode's Multilingual Plane (BMP).
|
|
12
|
+
throw new Error("malformed escaped unicode characters '\\u".concat(f,"'"));b+=String.fromCodePoint(Number.parseInt(f,16)),d+=5;break}default:b+=e,d++}}else// When there is \, simply add the character.
|
|
13
13
|
b+=c;return b};exports.unescapeContent=unescapeContent;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "properties-file",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.10",
|
|
4
4
|
"description": ".properties file parser, editor, formatter and Webpack loader.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
".properties",
|
|
@@ -63,14 +63,14 @@
|
|
|
63
63
|
"test": "jest --coverage"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@babel/cli": "^7.22.
|
|
67
|
-
"@babel/core": "^7.22.
|
|
68
|
-
"@babel/preset-env": "^7.22.
|
|
66
|
+
"@babel/cli": "^7.22.6",
|
|
67
|
+
"@babel/core": "^7.22.8",
|
|
68
|
+
"@babel/preset-env": "^7.22.7",
|
|
69
69
|
"@babel/preset-typescript": "^7.22.5",
|
|
70
|
-
"@release-it/conventional-changelog": "
|
|
70
|
+
"@release-it/conventional-changelog": "7.0.0",
|
|
71
71
|
"@types/jest": "29.5.2",
|
|
72
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
73
|
-
"@typescript-eslint/parser": "5.
|
|
72
|
+
"@typescript-eslint/eslint-plugin": "5.61.0",
|
|
73
|
+
"@typescript-eslint/parser": "5.61.0",
|
|
74
74
|
"babel-preset-minify": "^0.5.2",
|
|
75
75
|
"check-node-version": "^4.2.1",
|
|
76
76
|
"dotenv-cli": "7.2.1",
|
|
@@ -80,16 +80,16 @@
|
|
|
80
80
|
"eslint-import-resolver-typescript": "3.5.5",
|
|
81
81
|
"eslint-plugin-import": "2.27.5",
|
|
82
82
|
"eslint-plugin-jest": "27.2.2",
|
|
83
|
-
"eslint-plugin-json-files": "
|
|
83
|
+
"eslint-plugin-json-files": "3.0.0",
|
|
84
84
|
"eslint-plugin-prefer-arrow-functions": "3.1.4",
|
|
85
|
-
"eslint-plugin-prettier": "
|
|
85
|
+
"eslint-plugin-prettier": "^5.0.0-alpha.2",
|
|
86
86
|
"eslint-plugin-tsdoc": "0.2.17",
|
|
87
87
|
"eslint-plugin-unicorn": "47.0.0",
|
|
88
|
-
"jest": "29.
|
|
89
|
-
"prettier": "
|
|
88
|
+
"jest": "29.6.1",
|
|
89
|
+
"prettier": "3.0.0",
|
|
90
90
|
"prettier-plugin-organize-imports": "3.2.2",
|
|
91
|
-
"prettier-plugin-sh": "0.
|
|
92
|
-
"release-it": "
|
|
91
|
+
"prettier-plugin-sh": "0.13.0",
|
|
92
|
+
"release-it": "16.1.0",
|
|
93
93
|
"ts-jest": "29.1.1",
|
|
94
94
|
"ts-node": "10.9.1",
|
|
95
95
|
"typescript": "5.1.6"
|