properties-file
Advanced tools
Comparing version 3.2.9 to 3.2.10
@@ -1,8 +0,8 @@ | ||
"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");/** The default separator between keys and values. */const DEFAULT_SEPARATOR="=";/** The default character used as comment delimiter. */exports.DEFAULT_SEPARATOR="=";const 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="#";/** | ||
"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="#";/** | ||
* A .properties file editor. | ||
*/class PropertiesEditor extends _properties.Properties{/** | ||
*/var PropertiesEditor=/*#__PURE__*/function(a){/** | ||
* Create `PropertiesEditor` object. | ||
* | ||
* @param content - The content of a `.properties` file. | ||
*/constructor(a){super(a)}/** | ||
*/function b(a){return _classCallCheck(this,b),c.call(this,a)}/** | ||
* Insert a new property in the existing object (by default it will be at the end). | ||
@@ -15,8 +15,8 @@ * | ||
* @returns True if the key was inserted, otherwise false. | ||
*/insert(a,b,c){const 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(a=>(0,_escape.escapeKey)(a,d)).join("\\\n"),i=b.split(/\r?\n/).map(a=>(0,_escape.escapeValue)(a,d)).join("\\\n"),j="".concat((null===c||void 0===c?void 0:c.commentDelimiter)||DEFAULT_COMMENT_DELIMITER," "),k=(null===c||void 0===c?void 0:c.comment)===void 0?"":"".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. | ||
*/_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. | ||
// Allow multiline values. | ||
// Allow multiline comments. | ||
if(void 0===f)return this.lines.push(...l),this.parseLines(),!0;else{// Find the last occurrence of the reference key. | ||
const a=[...this.collection].reverse().find(a=>a.key===f);// Insert the new property when a reference key defined only when found. | ||
if(a){var m,n;const b="after"===g?a.endingLineNumber:null!==(m=null===(n=a.previousProperty)||void 0===n?void 0:n.endingLineNumber)&&void 0!==m?m:0;return this.lines=[...this.lines.slice(0,b),...l,...this.lines.slice(b)],this.parseLines(),!0}return!1}}/** | ||
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. | ||
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. | ||
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}/** | ||
* Insert a new comment in the existing object (by default it will be at the end). | ||
@@ -28,6 +28,6 @@ * | ||
* @returns True if the comment was inserted, otherwise false. | ||
*/insertComment(a,b){const 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. | ||
if(void 0===c)return this.lines.push(...f),this.parseLines(),!0;else{// Find the last occurrence of the reference key. | ||
const a=[...this.collection].reverse().find(a=>a.key===c);// Insert the new comment when a reference key defined only when found. | ||
if(a){var g,h;const b="after"===d?a.endingLineNumber:null!==(g=null===(h=a.previousProperty)||void 0===h?void 0:h.endingLineNumber)&&void 0!==g?g:0;return this.lines=[...this.lines.slice(0,b),...f,...this.lines.slice(b)],this.parseLines(),!0}return!1}}/** | ||
*/},{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. | ||
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. | ||
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. | ||
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}/** | ||
* Delete the last occurrence of a given key from the existing object. | ||
@@ -39,4 +39,4 @@ * | ||
* @returns True if the key was deleted, otherwise false. | ||
*/delete(a){let b=!(1<arguments.length&&arguments[1]!==void 0)||arguments[1];// Find the last occurrence of the key. | ||
const c=[...this.collection].reverse().find(b=>b.key===a);if(c){var d,e;const a=b?null!==(d=null===(e=c.previousProperty)||void 0===e?void 0:e.endingLineNumber)&&void 0!==d?d:0:c.startingLineNumber-1,f=c.endingLineNumber;return this.lines=[...this.lines.slice(0,a),...this.lines.slice(f)],this.parseLines(),!0}return!1}/** | ||
*/},{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. | ||
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}/** | ||
* Restore the original newline characters of a key. | ||
@@ -47,4 +47,4 @@ * | ||
* @returns The key with its original newlines characters restored. | ||
*/getKeyWithNewlines(a){return 0===a.newlinePositions.length?a.key:// eslint-disable-next-line unicorn/no-array-reduce | ||
[...a.key].reduce((b,c,d)=>"".concat(b).concat(a.newlinePositions.includes(d)?"\n":"").concat(c),"")}/** | ||
*/},{key:"getKeyWithNewlines",value:function getKeyWithNewlines(a){return 0===a.newlinePositions.length?a.key:// eslint-disable-next-line unicorn/no-array-reduce | ||
_toConsumableArray(a.key).reduce(function(b,c,d){return"".concat(b).concat(a.newlinePositions.includes(d)?"\n":"").concat(c)},"")}/** | ||
* Restore the original newline characters of a value. | ||
@@ -55,4 +55,4 @@ * | ||
* @returns The value with its original newlines characters restored. | ||
*/getValueWithNewlines(a){return 0===a.newlinePositions.length||a.valuePosition===void 0?a.value:// eslint-disable-next-line unicorn/no-array-reduce | ||
[...a.value].reduce((b,c,d)=>"".concat(b).concat(a.newlinePositions.includes(d+a.valuePosition)?"\n":"").concat(c),"")}/** | ||
*/},{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 | ||
_toConsumableArray(a.value).reduce(function(b,c,d){return"".concat(b).concat(a.newlinePositions.includes(d+a.valuePosition)?"\n":"").concat(c)},"")}/** | ||
* Update the last occurrence of a given key from the existing object. | ||
@@ -64,8 +64,8 @@ * | ||
* @returns True if the key was updated, otherwise false. | ||
*/update(a,b){var c,d,e,f;// Find the last occurrence of the key to update. | ||
const g=[...this.collection].reverse().find(b=>b.key===a);if(!g||!b)return!1;const 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(a=>(0,_escape.escapeKey)(a,h)).join("\\\n"),k=(null!==(d=b.newValue)&&void 0!==d?d:this.getValueWithNewlines(g)).split(/\r?\n/).map(a=>(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. | ||
*/},{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. | ||
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. | ||
// Allow multiline values. | ||
// Allow multiline comments. | ||
// Replace the existing property with the new one. | ||
return this.lines=[...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),...n,...this.lines.slice(g.endingLineNumber)],this.parseLines(),!0}/** | ||
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}/** | ||
* Update a key if it exist, otherwise add it at the end. | ||
@@ -78,2 +78,2 @@ * | ||
* @returns True if the key was updated or inserted, otherwise false. | ||
*/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; | ||
*/},{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; |
@@ -8,3 +8,3 @@ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.escapeValue=exports.escapeKey=void 0;/** | ||
* @return The escaped key. | ||
*/const escapeKey=function(a){let b=!!(1<arguments.length&&arguments[1]!==void 0)&&arguments[1];return escapeContent(a,!0,b)};/** | ||
*/var escapeKey=function(a){var b=!!(1<arguments.length&&arguments[1]!==void 0)&&arguments[1];return escapeContent(a,!0,b)};/** | ||
* Escape property value. | ||
@@ -16,3 +16,3 @@ * | ||
* @return The escaped value. | ||
*/exports.escapeKey=escapeKey;const escapeValue=function(a){let b=!!(1<arguments.length&&arguments[1]!==void 0)&&arguments[1];return escapeContent(a,!1,b)};/** | ||
*/exports.escapeKey=escapeKey;var escapeValue=function(a){var b=!!(1<arguments.length&&arguments[1]!==void 0)&&arguments[1];return escapeContent(a,!1,b)};/** | ||
* Escape the content from either key or value of a property. | ||
@@ -25,5 +25,5 @@ * | ||
* @returns The unescaped content. | ||
*/exports.escapeValue=escapeValue;const escapeContent=(a,b,c)=>{let d="";for(let e=a[0],f=0;f<a.length;f++,e=a[f])switch(e){case" ":{d+=b||0===f?"\\ ":" ";break}// Backslash. | ||
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){const a=e.codePointAt(0);// Can never be `undefined`. | ||
if(32>a||126<a){d+="\\u".concat(a.toString(16).padStart(4,"0"));break}}// Non-escapable characters. | ||
*/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. | ||
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`. | ||
if(32>g||126<g){d+="\\u".concat(g.toString(16).padStart(4,"0"));break}}// Non-escapable characters. | ||
d+=e;break}}return d}; |
@@ -1,2 +0,2 @@ | ||
"use strict";var _properties=require("./properties");Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"Properties",{enumerable:!0,get:function(){return _properties.Properties}}),exports.getProperties=void 0;/** | ||
"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()};/** | ||
* A key-value pair object. | ||
@@ -9,2 +9,2 @@ */ /** | ||
* @returns A key/value object representing the content of a `.properties` file. | ||
*/const getProperties=a=>new _properties.Properties(a).toObject();exports.getProperties=getProperties; | ||
*/exports.getProperties=getProperties; |
@@ -1,2 +0,2 @@ | ||
"use strict";var _=require("..");Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;/** | ||
"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;/** | ||
* Webpack file loader for `.properties` files. | ||
@@ -7,2 +7,2 @@ * | ||
* @returns A Webpack file loader string containing the content of a `.properties` file. | ||
*/const webpackLoader=a=>"module.exports = ".concat(JSON.stringify((0,_.getProperties)(a)),";");var _default=webpackLoader;exports.default=_default; | ||
*/exports.default=_default; |
@@ -1,4 +0,4 @@ | ||
"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"==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)}/** | ||
"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)}/** | ||
* Byte-order mark. | ||
*/const BOM="\uFEFF";exports.BOM="\uFEFF";const BOM_CODE_POINT="\uFEFF".codePointAt(0);/** The default end of line character. */exports.BOM_CODE_POINT=65279;const DEFAULT_END_OF_LINE_CHARACTER="\n";/** | ||
*/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";/** | ||
* Get the first end of line (EOL) character from multiline content. | ||
@@ -9,16 +9,16 @@ * | ||
* @returns The multiline content's first end of line (EOL) character. | ||
*/exports.DEFAULT_END_OF_LINE_CHARACTER="\n";const getFirstEolCharacter=a=>{const b=a.indexOf("\n");return 0>b?void 0:"".concat("\r"===a[b-1]?"\r":"","\n")};/** | ||
*/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")};/** | ||
* A class representing the content of a .properties file. | ||
*/exports.getFirstEolCharacter=getFirstEolCharacter;class Properties{/** | ||
*/exports.getFirstEolCharacter=getFirstEolCharacter;var Properties=/*#__PURE__*/function(){/** | ||
* Create `Properties` object. | ||
* | ||
* @param content - The content of a `.properties` file. | ||
*/constructor(a){var b;_defineProperty(this,"collection",[]),_defineProperty(this,"keyLineNumbers",{});const c="string"==typeof a?a:a.toString();this.hasBom=c.codePointAt(0)===BOM_CODE_POINT,this.eolCharacter=null!==(b=getFirstEolCharacter(c))&&void 0!==b?b:DEFAULT_END_OF_LINE_CHARACTER,this.lines=(this.hasBom?c.slice(1):c).split(/\r?\n/),this.parseLines()}/** | ||
*/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()}/** | ||
* Parse the `.properties` content line by line. | ||
*/parseLines(){this.collection=[],this.keyLineNumbers={};/** Line number while parsing properties file content. */let a,b,c=0;/** The current property object being parsed. */ /** The previous property object that was parsed. */for(const d of this.lines){c++;const e=new _propertyLine.PropertyLine(d,!!a);if(!a){// Check if the line is a new property. | ||
if(e.isComment||e.isBlank)continue;// Skip line if its a comment or blank. | ||
*/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. | ||
if(g.isComment||g.isBlank)continue;// Skip line if its a comment or blank. | ||
// The line is a new property. | ||
if(a=new _property.Property(e,c,b),e.isContinuing)continue;// Continue parsing the next line. | ||
}else if(a.addLine(e),e.isContinuing)continue;// If the line does not continue, add the property to the collection. | ||
this.addToCollection(a),b=a,a=void 0}}/** | ||
if(a=new _property.Property(g,d,b),g.isContinuing)continue;// Continue parsing the next line. | ||
}else if(a.addLine(g),g.isContinuing)continue;// If the line does not continue, add the property to the collection. | ||
this.addToCollection(a),b=a,a=void 0}}catch(a){e.e(a)}finally{e.f()}}/** | ||
* Add a property object into a properties object collection. | ||
@@ -29,10 +29,9 @@ * | ||
* @returns Undefined so that we conveniently overwrite the property object. | ||
*/addToCollection(a){var b;// Add the property to the collection. | ||
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)}/** | ||
*/},{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)}/** | ||
* Get keys that have collisions (more than one occurrence). | ||
*/getKeyCollisions(){const a=[];for(const[b,c]of Object.entries(this.keyLineNumbers))1<c.length&&a.push(new KeyCollisions(b,c));return a}/** | ||
*/},{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}/** | ||
* Get the key/value object representing the properties. | ||
* | ||
* @returns A key/value object representing the properties. | ||
*/toObject(){const a={};return this.collection.forEach(b=>{a[b.key]=b.value}),a}/** | ||
*/},{key:"toObject",value:function toObject(){var a={};return this.collection.forEach(function(b){a[b.key]=b.value}),a}/** | ||
* Format the object in `.properties`. | ||
@@ -43,7 +42,7 @@ * | ||
* @returns The object in `.properties` format. | ||
*/format(a){return"".concat(this.hasBom?BOM:"").concat(this.lines.join(a||this.eolCharacter))}}/** | ||
*/},{key:"format",value:function format(a){return"".concat(this.hasBom?BOM:"").concat(this.lines.join(a||this.eolCharacter))}}]),a}();/** | ||
* Object associating keys with their line numbers. | ||
*/exports.Properties=Properties;/** | ||
* A class representing key within a .properties file that had collisions (more than one occurrence). | ||
*/class KeyCollisions{/** The key with collisions. */ /** The starting line numbers where collisions are found. */ /** | ||
*/var KeyCollisions=/*#__PURE__*/function(){/** The key with collisions. */ /** The starting line numbers where collisions are found. */ /** | ||
* Create a new key collision object. | ||
@@ -53,4 +52,4 @@ * | ||
* @param startingLineNumbers - The starting line numbers where collisions are found. | ||
*/constructor(a,b){this.key=a,this.startingLineNumbers=b}/** | ||
*/function a(b,c){_classCallCheck(this,a),this.key=b,this.startingLineNumbers=c}/** | ||
* Get the number of the line from which the value will be used. | ||
*/getApplicableLineNumber(){return this.startingLineNumbers.slice(-1)[0]}}exports.KeyCollisions=KeyCollisions; | ||
*/return _createClass(a,[{key:"getApplicableLineNumber",value:function getApplicableLineNumber(){return this.startingLineNumbers.slice(-1)[0]}}]),a}();exports.KeyCollisions=KeyCollisions; |
@@ -1,4 +0,4 @@ | ||
"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"==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)}/** | ||
"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)}/** | ||
* Object representing a line from the content of .properties file. | ||
*/class PropertyLine{/** Is the line object a continuation from a previous line? */ /** | ||
*/var PropertyLine=/*#__PURE__*/_createClass(/** Is the line object a continuation from a previous line? */ /** | ||
* Create a new line object. | ||
@@ -8,3 +8,3 @@ * | ||
* @param isMultiline - Is the line spreading on multiple lines? | ||
*/constructor(a,b){if(_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. | ||
const a=this.content.match(/(?<backslashes>\\+)$/);null!==a&&void 0!==a&&a.groups&&(this.isContinuing=!!(a.groups.backslashes.length%2),this.isContinuing&&(this.content=this.content.slice(0,-1)))}}}exports.PropertyLine=PropertyLine; | ||
*/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. | ||
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; |
@@ -1,4 +0,4 @@ | ||
"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"==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)}/** | ||
"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)}/** | ||
* Object representing a property (key/value). | ||
*/class Property{/** 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. */ /** | ||
*/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. */ /** | ||
* Create a new property object. | ||
@@ -8,13 +8,13 @@ * | ||
* @param startingLineNumber - The line number at which the property starts. | ||
*/constructor(a,b,c){/** The content of one or multiple lines when applicable. */ /** The property key (unescaped). */ /** The property key, including its escaped characters. */ /** Is the key empty? */ /** Does the key definition spread across multiple lines? */ /** Starting line numbers of property objects with the same key. */ /** Was the property's key used more than once? */ /** The property value (unescaped). */ /** The property value, including its escaped characters. */ /** Is the value empty? */ /** Positions of the newline characters if any. */_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=a.content,this.startingLineNumber=b,this.endingLineNumber=b,this.previousProperty=c,null===c||void 0===c?void 0:c.setNextProperty(this)}/** | ||
*/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)}/** | ||
* Set the next property object. | ||
* | ||
* @param property - The next property object | ||
*/setNextProperty(a){this.nextProperty=a}/** | ||
*/return _createClass(a,[{key:"setNextProperty",value:function setNextProperty(a){this.nextProperty=a}/** | ||
* Add the a line to a multiline property object. | ||
* | ||
* @param propertyLine - A property line object. | ||
*/addLine(a){0<this.linesContent.length&&(this.newlinePositions.push(this.linesContent.length),this.endingLineNumber++),this.linesContent+=a.content}/** | ||
*/},{key:"addLine",value:function addLine(a){0<this.linesContent.length&&(this.newlinePositions.push(this.linesContent.length),this.endingLineNumber++),this.linesContent+=a.content}/** | ||
* Set the property's key and value. | ||
*/setKeyAndValue(){this.findSeparator(),this.separatorPosition!==void 0&&this.separatorLength!==void 0?(!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))}/** | ||
*/},{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))}/** | ||
* Unescape the content from either key or value of a property. | ||
@@ -29,12 +29,12 @@ * | ||
* This exception is thrown if malformed escaped unicode characters are present. | ||
*/unescapeLine(a,b){try{return(0,_unescape.unescapeContent)(a)}catch(a){throw new Error("".concat(a.message," in property starting at line ").concat(b))}}/** | ||
*/},{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))}}/** | ||
* Find the character separating the key from the value. | ||
*/findSeparator(){// If the separator was already found, skip. | ||
if(!(this.hasNoKey||this.hasNoValue||this.separatorPosition)){for(let c=this.linesContent[0],d=0;d<this.linesContent.length;d++,c=this.linesContent[d]){var a;// If the character is not a separator, check the next one. | ||
if(!/[\t\f :=]/.test(c))continue;// Check if the separator might be escaped. | ||
const e=d?this.linesContent.slice(0,d):"";if(0<e.length){const a=e.match(/(?<backslashes>\\+)$/);if(null!==a&&void 0!==a&&a.groups){const b=!!(a.groups.backslashes.length%2);if(b)// If the separator is escaped, check the next character. | ||
continue}}let f="";this.separatorPosition=d;// Check if the separator starts with a whitespace. | ||
let g=this.linesContent.slice(d);const h=g.match(/^(?<whitespace>\s+)/),i=(null===h||void 0===h||null===(a=h.groups)||void 0===a?void 0:a.whitespace)||"";// If there is a whitespace, move to the next character. | ||
*/},{key:"findSeparator",value:function findSeparator(){// If the separator was already found, skip. | ||
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. | ||
if(/[\t\f :=]/.test(a)){// Check if the separator might be escaped. | ||
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. | ||
continue}}var g="";this.separatorPosition=b;// Check if the separator starts with a whitespace. | ||
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. | ||
// Check if there is an equal or colon character. | ||
if(0<i.length&&(f+=i,g=g.slice(i.length)),/[:=]/.test(g[0])){var b;f+=g[0],g=g.slice(1);// If an equal or colon character was found, try to get trailing whitespace. | ||
const a=g.match(/^(?<whitespace>\s+)/),c=(null===a||void 0===a||null===(b=a.groups)||void 0===b?void 0:b.whitespace)||"";f+=c}this.separatorLength=f.length,this.valuePosition=this.separatorPosition+this.separatorLength,this.separator=this.linesContent.slice(this.separatorPosition,this.separatorPosition+this.separatorLength),d||(this.hasNoKey=!0);break}void 0===this.separatorPosition?this.hasNoValue=!0:0<this.newlinePositions.length&&this.newlinePositions[0]<this.separatorPosition&&(this.hasMultilineKey=!0)}}}exports.Property=Property; | ||
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. | ||
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; |
@@ -10,5 +10,5 @@ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.unescapeContent=void 0;/** | ||
* This exception is thrown if malformed escaped unicode characters are present. | ||
*/const unescapeContent=a=>{let b="";for(let c=a[0],d=0;d<a.length;d++,c=a[d])if("\\"===c){const c=a[d+1];switch(c){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. | ||
const c=a.slice(d+2,d+6);if(!/[\da-f]{4}/i.test(c))// Code point can only be within Unicode's Multilingual Plane (BMP). | ||
throw new Error("malformed escaped unicode characters '\\u".concat(c,"'"));b+=String.fromCodePoint(Number.parseInt(c,16)),d+=5;break}default:b+=c,d++}}else// When there is \, simply add the character. | ||
*/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. | ||
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). | ||
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. | ||
b+=c;return b};exports.unescapeContent=unescapeContent; |
{ | ||
"name": "properties-file", | ||
"version": "3.2.9", | ||
"version": "3.2.10", | ||
"description": ".properties file parser, editor, formatter and Webpack loader.", | ||
@@ -66,10 +66,10 @@ "keywords": [ | ||
"devDependencies": { | ||
"@babel/cli": "^7.22.5", | ||
"@babel/core": "^7.22.5", | ||
"@babel/preset-env": "^7.22.5", | ||
"@babel/cli": "^7.22.6", | ||
"@babel/core": "^7.22.8", | ||
"@babel/preset-env": "^7.22.7", | ||
"@babel/preset-typescript": "^7.22.5", | ||
"@release-it/conventional-changelog": "5.1.1", | ||
"@release-it/conventional-changelog": "7.0.0", | ||
"@types/jest": "29.5.2", | ||
"@typescript-eslint/eslint-plugin": "5.60.1", | ||
"@typescript-eslint/parser": "5.60.1", | ||
"@typescript-eslint/eslint-plugin": "5.61.0", | ||
"@typescript-eslint/parser": "5.61.0", | ||
"babel-preset-minify": "^0.5.2", | ||
@@ -84,12 +84,12 @@ "check-node-version": "^4.2.1", | ||
"eslint-plugin-jest": "27.2.2", | ||
"eslint-plugin-json-files": "2.2.0", | ||
"eslint-plugin-json-files": "3.0.0", | ||
"eslint-plugin-prefer-arrow-functions": "3.1.4", | ||
"eslint-plugin-prettier": "4.2.1", | ||
"eslint-plugin-prettier": "^5.0.0-alpha.2", | ||
"eslint-plugin-tsdoc": "0.2.17", | ||
"eslint-plugin-unicorn": "47.0.0", | ||
"jest": "29.5.0", | ||
"prettier": "2.8.8", | ||
"jest": "29.6.1", | ||
"prettier": "3.0.0", | ||
"prettier-plugin-organize-imports": "3.2.2", | ||
"prettier-plugin-sh": "0.12.8", | ||
"release-it": "15.11.0", | ||
"prettier-plugin-sh": "0.13.0", | ||
"release-it": "16.1.0", | ||
"ts-jest": "29.1.1", | ||
@@ -96,0 +96,0 @@ "ts-node": "10.9.1", |
@@ -7,3 +7,2 @@ # properties-file | ||
![Dependencies](https://img.shields.io/badge/dependencies-0-brightgreen) | ||
[![Known Vulnerabilities](https://snyk.io/test/github/Avansai/properties-file/badge.svg?targetFile=package.json)](https://snyk.io/test/github/Avansai/properties-file?targetFile=package.json) | ||
@@ -10,0 +9,0 @@ `.properties` file parser, editor, formatter and Webpack loader. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
65113
682
4
282