properties-file 5.0.3 → 5.0.5

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 CHANGED
@@ -3,7 +3,7 @@
3
3
  [![License](https://img.shields.io/npm/l/make-coverage-badge.svg?color=brightgreen)](https://opensource.org/licenses/MIT)
4
4
  [![Download Stats](https://img.shields.io/npm/dw/properties-file.svg?color=brightgreen)](https://www.npmjs.com/package/properties-file)
5
5
  ![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen.svg)
6
- ![Package Size](https://img.shields.io/badge/min%2Bgzip-1014%20B-brightgreen)
6
+ ![Package Size](https://img.shields.io/badge/min%2Bgzip-970%20B-brightgreen)
7
7
  ![Dependencies](https://img.shields.io/badge/dependencies-0-brightgreen)
8
8
 
9
9
  `.properties` file parser, editor, formatter and bundler integrations.
@@ -28,8 +28,8 @@ npm install properties-file
28
28
  - `PropertiesEditor` enables insertion, edition, and removal of entries while preserving formatting.
29
29
  - `escapeKey` and `escapeValue` convert any content to `.properties` compatible format.
30
30
  - Bundler integrations for Webpack, Rollup/Vite, esbuild, and Bun to import `.properties` files directly. See [BUNDLER.md](./docs/BUNDLER.md).
31
- - **Tiny with 0 dependencies** — `getProperties` is only 1014 B min+gzip.
32
- - **Runs everywhere** — compiled to ES5, works in any browser and on Node.js all the way back to v0.10 (2013). [Verified via Docker](./tests/node-compat/).
31
+ - **Tiny with 0 dependencies** — `getProperties` is only 970 B min+gzip.
32
+ - **Runs everywhere** — compiled to ES5, works in any browser and on Node.js all the way back to v0.4.0 (2011, the first stable release with ES5 support). [Verified via Docker](./tests/node-compat/).
33
33
  - **100% test coverage** based on the output from a Java implementation.
34
34
  - Active maintenance (many popular `.properties` packages have been inactive for years). See our [detailed comparison](./docs/COMPARISON.md) with other packages.
35
35
 
@@ -0,0 +1,32 @@
1
+ /** Tab character code. */
2
+ export declare const CH_TAB = 9;
3
+ /** Line feed character code. */
4
+ export declare const CH_LF = 10;
5
+ /** Form feed character code. */
6
+ export declare const CH_FF = 12;
7
+ /** Carriage return character code. */
8
+ export declare const CH_CR = 13;
9
+ /** Space character code. */
10
+ export declare const CH_SPACE = 32;
11
+ /** Exclamation mark character code (comment delimiter). */
12
+ export declare const CH_BANG = 33;
13
+ /** Hash character code (comment delimiter). */
14
+ export declare const CH_HASH = 35;
15
+ /** Colon character code (separator). */
16
+ export declare const CH_COLON = 58;
17
+ /** Equals character code (separator). */
18
+ export declare const CH_EQUALS = 61;
19
+ /** Backslash character code (escape / continuation). */
20
+ export declare const CH_BACKSLASH = 92;
21
+ /** Lowercase 'f' character code (formfeed escape). */
22
+ export declare const CH_LOWER_F = 102;
23
+ /** Lowercase 'n' character code (newline escape). */
24
+ export declare const CH_LOWER_N = 110;
25
+ /** Lowercase 'r' character code (carriage return escape). */
26
+ export declare const CH_LOWER_R = 114;
27
+ /** Lowercase 't' character code (tab escape). */
28
+ export declare const CH_LOWER_T = 116;
29
+ /** Lowercase 'u' character code (unicode escape). */
30
+ export declare const CH_LOWER_U = 117;
31
+ /** Byte Order Mark character code. */
32
+ export declare const CH_BOM = 65279;
@@ -0,0 +1 @@
1
+ "use strict";function _export(_,C){for(var e in C)Object.defineProperty(_,e,{enumerable:!0,get:Object.getOwnPropertyDescriptor(C,e).get})}Object.defineProperty(exports,"__esModule",{value:!0}),_export(exports,{get CH_BACKSLASH(){return CH_BACKSLASH},get CH_BANG(){return CH_BANG},get CH_BOM(){return CH_BOM},get CH_COLON(){return CH_COLON},get CH_CR(){return CH_CR},get CH_EQUALS(){return CH_EQUALS},get CH_FF(){return CH_FF},get CH_HASH(){return CH_HASH},get CH_LF(){return CH_LF},get CH_LOWER_F(){return CH_LOWER_F},get CH_LOWER_N(){return CH_LOWER_N},get CH_LOWER_R(){return CH_LOWER_R},get CH_LOWER_T(){return CH_LOWER_T},get CH_LOWER_U(){return CH_LOWER_U},get CH_SPACE(){return CH_SPACE},get CH_TAB(){return CH_TAB}});var CH_TAB=9,CH_LF=10,CH_FF=12,CH_CR=13,CH_SPACE=32,CH_BANG=33,CH_HASH=35,CH_COLON=58,CH_EQUALS=61,CH_BACKSLASH=92,CH_LOWER_F=102,CH_LOWER_N=110,CH_LOWER_R=114,CH_LOWER_T=116,CH_LOWER_U=117,CH_BOM=65279;
@@ -104,21 +104,21 @@ export type DeleteOptions = {
104
104
  */
105
105
  export declare class PropertiesEditor extends Properties {
106
106
  /**
107
- * Find the index of the first property node with the given key.
107
+ * Find the first property node with the given key.
108
108
  *
109
109
  * @param key - The unescaped key to search for.
110
110
  *
111
- * @returns The index in `this.nodes`, or `-1` if not found.
111
+ * @returns The matching node and its index in `this.nodes`, or `undefined`.
112
112
  */
113
- private findFirstPropertyIndex;
113
+ private findFirstProperty;
114
114
  /**
115
- * Find the index of the last property node with the given key.
115
+ * Find the last property node with the given key.
116
116
  *
117
117
  * @param key - The unescaped key to search for.
118
118
  *
119
- * @returns The index in `this.nodes`, or `-1` if not found.
119
+ * @returns The matching node and its index in `this.nodes`, or `undefined`.
120
120
  */
121
- private findLastPropertyIndex;
121
+ private findLastProperty;
122
122
  /**
123
123
  * Insert a new property.
124
124
  *
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"PropertiesEditor",{enumerable:!0,get:function(){return PropertiesEditor}});var _index=require("../escape/index.js"),_properties=require("../parser/properties.js");function _instanceof(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):e instanceof r}function _array_like_to_array(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function _array_without_holes(e){if(Array.isArray(e))return _array_like_to_array(e)}function _assert_this_initialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _call_super(e,r,t){return r=_get_prototype_of(r),_possible_constructor_return(e,_is_native_reflect_construct()?Reflect.construct(r,t||[],_get_prototype_of(e).constructor):r.apply(e,t))}function _class_call_check(e,r){if(!_instanceof(e,r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _create_class(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),e}function _get_prototype_of(e){return _get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},_get_prototype_of(e)}function _inherits(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),r&&_set_prototype_of(e,r)}function _iterable_to_array(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _non_iterable_spread(){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 _possible_constructor_return(e,r){return!r||"object"!==_type_of(r)&&"function"!=typeof r?_assert_this_initialized(e):r}function _set_prototype_of(e,r){return _set_prototype_of=Object.setPrototypeOf||function(e,r){return e.__proto__=r,e},_set_prototype_of(e,r)}function _to_consumable_array(e){return _array_without_holes(e)||_iterable_to_array(e)||_unsupported_iterable_to_array(e)||_non_iterable_spread()}function _type_of(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function _unsupported_iterable_to_array(e,r){if(e){if("string"==typeof e)return _array_like_to_array(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(t):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_array_like_to_array(e,r):void 0}}function _is_native_reflect_construct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_is_native_reflect_construct=function(){return!!e})()}var DEFAULT_SEPARATOR="=",DEFAULT_COMMENT_DELIMITER="#",REGEX_NEWLINE=/\r\n|\r|\n/,buildPropertyNode=function(e,r,t,n){var o,i=!0===t.escapeUnicode,a=(0,_index.escapeKey)(e,i),s=(0,_index.escapeValue)(r,i),l=" "===t.separator?void 0:null!==(o=t.separator)&&void 0!==o?o:DEFAULT_SEPARATOR,c=l?" ":"",u=l?"".concat(" ").concat(l).concat(c):" ",p="".concat(a).concat(u).concat(s).split(REGEX_NEWLINE);return{type:"property",rawLines:p,leadingWhitespace:"",key:e,escapedKey:a,separatorLeading:" ",separatorChar:l,separatorTrailing:c,value:r,escapedValue:s,startingLineNumber:n,endingLineNumber:n+p.length-1}},buildCommentNodes=function(e,r,t){return e.split(REGEX_NEWLINE).map(function(e,n){return""===e?{type:"blank",rawLine:"",lineNumber:t+n}:{type:"comment",rawLine:"".concat(r," ").concat(e),leadingWhitespace:"",delimiter:r,body:" ".concat(e),lineNumber:t+n}})},recalculateLineNumbers=function(e){var r=1,t=!0,n=!1,o=void 0;try{for(var i,a=e[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var s=i.value;if("property"===s.type){var l=s.rawLines.length;s.startingLineNumber=r,s.endingLineNumber=r+l-1,r+=l}else s.lineNumber=r,r++}}catch(e){n=!0,o=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw o}}},PropertiesEditor=function(){function e(){return _class_call_check(this,e),_call_super(this,e,arguments)}return _inherits(e,_properties.Properties),_create_class(e,[{key:"findFirstPropertyIndex",value:function(e){for(var r=0;r<this.nodes.length;r++){var t=this.nodes[r];if("property"===t.type&&t.key===e)return r}return-1}},{key:"findLastPropertyIndex",value:function(e){for(var r=this.nodes.length-1;r>=0;r--){var t=this.nodes[r];if("property"===t.type&&t.key===e)return r}return-1}},{key:"insert",value:function(e,r,t){var n,o,i=[];if(void 0!==(null==t?void 0:t.comment)){var a,s=null!==(o=t.commentDelimiter)&&void 0!==o?o:DEFAULT_COMMENT_DELIMITER;(a=i).push.apply(a,_to_consumable_array(buildCommentNodes(t.comment,s,0)))}if(i.push(buildPropertyNode(e,r,{escapeUnicode:null==t?void 0:t.escapeUnicode,separator:null==t?void 0:t.separator},0)),null==t?void 0:t.referenceKey){var l=this.findLastPropertyIndex(t.referenceKey);if(-1!==l){var c,u="before"===t.position?l:l+1;return(c=this.nodes).splice.apply(c,[u,0].concat(_to_consumable_array(i))),void recalculateLineNumbers(this.nodes)}}(n=this.nodes).push.apply(n,_to_consumable_array(i)),recalculateLineNumbers(this.nodes)}},{key:"insertComment",value:function(e,r){var t,n,o=null!==(n=null==r?void 0:r.commentDelimiter)&&void 0!==n?n:DEFAULT_COMMENT_DELIMITER,i=buildCommentNodes(e,o,0);if(null==r?void 0:r.referenceKey){var a=this.findLastPropertyIndex(r.referenceKey);if(-1!==a){var s,l="before"===r.position?a:a+1;return(s=this.nodes).splice.apply(s,[l,0].concat(_to_consumable_array(i))),void recalculateLineNumbers(this.nodes)}}(t=this.nodes).push.apply(t,_to_consumable_array(i)),recalculateLineNumbers(this.nodes)}},{key:"insertBlankLine",value:function(e){var r={type:"blank",rawLine:"",lineNumber:0};if(null==e?void 0:e.referenceKey){var t=this.findLastPropertyIndex(e.referenceKey);if(-1!==t){var n="before"===e.position?t:t+1;return this.nodes.splice(n,0,r),void recalculateLineNumbers(this.nodes)}}this.nodes.push(r),recalculateLineNumbers(this.nodes)}},{key:"update",value:function(e,r){var t,n,o,i=this.findLastPropertyIndex(e);if(-1===i)return!1;var a=this.nodes[i],s=null!==(t=r.newKey)&&void 0!==t?t:a.key,l=null!==(n=r.newValue)&&void 0!==n?n:a.value,c=!0===r.escapeUnicode,u=c?(0,_index.escapeKey)(s,!0):void 0!==r.newKey?(0,_index.escapeKey)(s):a.escapedKey,p=c?(0,_index.escapeValue)(l,!0):void 0!==r.newValue?(0,_index.escapeValue)(l):a.escapedValue,_=r.separator?" "===r.separator?void 0:r.separator:a.separatorChar,d=r.separator?" ":a.separatorLeading,y=r.separator?_?" ":"":a.separatorTrailing,f=_?"".concat(d).concat(_).concat(y):d,m="".concat(u).concat(f).concat(p).split(REGEX_NEWLINE),h={type:"property",rawLines:m,leadingWhitespace:a.leadingWhitespace,key:s,escapedKey:u,separatorLeading:d,separatorChar:_,separatorTrailing:y,value:l,escapedValue:p,startingLineNumber:a.startingLineNumber,endingLineNumber:a.startingLineNumber+m.length-1};if(void 0!==r.newComment){for(var v,b=i,L=i-1;L>=0&&"property"!==this.nodes[L].type;L--)b=L;var E=null!==(o=r.commentDelimiter)&&void 0!==o?o:DEFAULT_COMMENT_DELIMITER,g=buildCommentNodes(r.newComment,E,0);(v=this.nodes).splice.apply(v,[b,i-b+1].concat(_to_consumable_array(g),[h]))}else this.nodes[i]=h;return recalculateLineNumbers(this.nodes),!0}},{key:"upsert",value:function(e,r,t){-1!==this.findLastPropertyIndex(e)?this.update(e,{newValue:r,escapeUnicode:null==t?void 0:t.escapeUnicode,separator:null==t?void 0:t.separator,newComment:null==t?void 0:t.comment,commentDelimiter:null==t?void 0:t.commentDelimiter}):this.insert(e,r,t)}},{key:"delete",value:function(e,r){var t="first"===(null==r?void 0:r.occurrence)?this.findFirstPropertyIndex(e):this.findLastPropertyIndex(e);if(-1!==t){var n=this.nodes[t];if(!1!==(null==r?void 0:r.deleteLeadingNodes)){for(var o=t,i=t-1;i>=0&&"property"!==this.nodes[i].type;i--)o=i;this.nodes.splice(o,t-o+1)}else this.nodes.splice(t,1);return recalculateLineNumbers(this.nodes),n}}},{key:"deleteAll",value:function(e){for(var r=[],t=this.nodes.length-1;t>=0;t--){var n=this.nodes[t];"property"===n.type&&n.key===e&&(this.nodes.splice(t,1),r.push(n))}return r.length>0&&recalculateLineNumbers(this.nodes),r.reverse()}}]),e}();
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"PropertiesEditor",{enumerable:!0,get:function(){return PropertiesEditor}});var _index=require("../escape/index.js"),_properties=require("../parser/properties.js");function _instanceof(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):e instanceof r}function _array_like_to_array(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function _array_without_holes(e){if(Array.isArray(e))return _array_like_to_array(e)}function _assert_this_initialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _call_super(e,r,t){return r=_get_prototype_of(r),_possible_constructor_return(e,_is_native_reflect_construct()?Reflect.construct(r,t||[],_get_prototype_of(e).constructor):r.apply(e,t))}function _class_call_check(e,r){if(!_instanceof(e,r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _create_class(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),e}function _get_prototype_of(e){return _get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},_get_prototype_of(e)}function _inherits(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),r&&_set_prototype_of(e,r)}function _iterable_to_array(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _non_iterable_spread(){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 _possible_constructor_return(e,r){return!r||"object"!==_type_of(r)&&"function"!=typeof r?_assert_this_initialized(e):r}function _set_prototype_of(e,r){return _set_prototype_of=Object.setPrototypeOf||function(e,r){return e.__proto__=r,e},_set_prototype_of(e,r)}function _to_consumable_array(e){return _array_without_holes(e)||_iterable_to_array(e)||_unsupported_iterable_to_array(e)||_non_iterable_spread()}function _type_of(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function _unsupported_iterable_to_array(e,r){if(e){if("string"==typeof e)return _array_like_to_array(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(t):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_array_like_to_array(e,r):void 0}}function _is_native_reflect_construct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_is_native_reflect_construct=function(){return!!e})()}var DEFAULT_SEPARATOR="=",DEFAULT_COMMENT_DELIMITER="#",REGEX_NEWLINE=/\r\n|\r|\n/,buildPropertyNode=function(e,r,t,n){var o,i=!0===t.escapeUnicode,a=(0,_index.escapeKey)(e,i),s=(0,_index.escapeValue)(r,i),l=" "===t.separator?void 0:null!==(o=t.separator)&&void 0!==o?o:DEFAULT_SEPARATOR,c=l?" ":"",u=l?"".concat(" ").concat(l).concat(c):" ",p="".concat(a).concat(u).concat(s).split(REGEX_NEWLINE);return{type:"property",rawLines:p,leadingWhitespace:"",key:e,escapedKey:a,separatorLeading:" ",separatorChar:l,separatorTrailing:c,value:r,escapedValue:s,startingLineNumber:n,endingLineNumber:n+p.length-1}},buildCommentNodes=function(e,r,t){return e.split(REGEX_NEWLINE).map(function(e,n){return""===e?{type:"blank",rawLine:"",lineNumber:t+n}:{type:"comment",rawLine:"".concat(r," ").concat(e),leadingWhitespace:"",delimiter:r,body:" ".concat(e),lineNumber:t+n}})},recalculateLineNumbers=function(e){for(var r=1,t=0;t<e.length;t++){var n=e[t];if("property"===n.type){var o=n.rawLines.length;e[t]={type:"property",rawLines:n.rawLines,leadingWhitespace:n.leadingWhitespace,key:n.key,escapedKey:n.escapedKey,separatorLeading:n.separatorLeading,separatorChar:n.separatorChar,separatorTrailing:n.separatorTrailing,value:n.value,escapedValue:n.escapedValue,startingLineNumber:r,endingLineNumber:r+o-1},r+=o}else"comment"===n.type?(e[t]={type:"comment",rawLine:n.rawLine,leadingWhitespace:n.leadingWhitespace,delimiter:n.delimiter,body:n.body,lineNumber:r},r++):(e[t]={type:"blank",rawLine:n.rawLine,lineNumber:r},r++)}},PropertiesEditor=function(){function e(){return _class_call_check(this,e),_call_super(this,e,arguments)}return _inherits(e,_properties.Properties),_create_class(e,[{key:"findFirstProperty",value:function(e){for(var r=0;r<this.nodes.length;r++){var t=this.nodes[r];if("property"===t.type&&t.key===e)return{index:r,node:t}}}},{key:"findLastProperty",value:function(e){for(var r=this.nodes.length-1;r>=0;r--){var t=this.nodes[r];if("property"===t.type&&t.key===e)return{index:r,node:t}}}},{key:"insert",value:function(e,r,t){var n,o,i=[];if(void 0!==(null==t?void 0:t.comment)){var a,s=null!==(o=t.commentDelimiter)&&void 0!==o?o:DEFAULT_COMMENT_DELIMITER;(a=i).push.apply(a,_to_consumable_array(buildCommentNodes(t.comment,s,0)))}if(i.push(buildPropertyNode(e,r,{escapeUnicode:null==t?void 0:t.escapeUnicode,separator:null==t?void 0:t.separator},0)),null==t?void 0:t.referenceKey){var l=this.findLastProperty(t.referenceKey);if(void 0!==l){var c,u="before"===t.position?l.index:l.index+1;return(c=this.nodes).splice.apply(c,[u,0].concat(_to_consumable_array(i))),void recalculateLineNumbers(this.nodes)}}(n=this.nodes).push.apply(n,_to_consumable_array(i)),recalculateLineNumbers(this.nodes)}},{key:"insertComment",value:function(e,r){var t,n,o=null!==(n=null==r?void 0:r.commentDelimiter)&&void 0!==n?n:DEFAULT_COMMENT_DELIMITER,i=buildCommentNodes(e,o,0);if(null==r?void 0:r.referenceKey){var a=this.findLastProperty(r.referenceKey);if(void 0!==a){var s,l="before"===r.position?a.index:a.index+1;return(s=this.nodes).splice.apply(s,[l,0].concat(_to_consumable_array(i))),void recalculateLineNumbers(this.nodes)}}(t=this.nodes).push.apply(t,_to_consumable_array(i)),recalculateLineNumbers(this.nodes)}},{key:"insertBlankLine",value:function(e){var r={type:"blank",rawLine:"",lineNumber:0};if(null==e?void 0:e.referenceKey){var t=this.findLastProperty(e.referenceKey);if(void 0!==t){var n="before"===e.position?t.index:t.index+1;return this.nodes.splice(n,0,r),void recalculateLineNumbers(this.nodes)}}this.nodes.push(r),recalculateLineNumbers(this.nodes)}},{key:"update",value:function(e,r){var t,n,o,i=this.findLastProperty(e);if(void 0===i)return!1;var a=i.index,s=i.node,l=null!==(t=r.newKey)&&void 0!==t?t:s.key,c=null!==(n=r.newValue)&&void 0!==n?n:s.value,u=!0===r.escapeUnicode,p=u?(0,_index.escapeKey)(l,!0):void 0!==r.newKey?(0,_index.escapeKey)(l):s.escapedKey,d=u?(0,_index.escapeValue)(c,!0):void 0!==r.newValue?(0,_index.escapeValue)(c):s.escapedValue,_=r.separator?" "===r.separator?void 0:r.separator:s.separatorChar,y=r.separator?" ":s.separatorLeading,f=r.separator?_?" ":"":s.separatorTrailing,m=_?"".concat(y).concat(_).concat(f):y,v="".concat(p).concat(m).concat(d).split(REGEX_NEWLINE),h={type:"property",rawLines:v,leadingWhitespace:s.leadingWhitespace,key:l,escapedKey:p,separatorLeading:y,separatorChar:_,separatorTrailing:f,value:c,escapedValue:d,startingLineNumber:s.startingLineNumber,endingLineNumber:s.startingLineNumber+v.length-1};if(void 0!==r.newComment){for(var b,L=a,g=a-1;g>=0&&"property"!==this.nodes[g].type;g--)L=g;var E=null!==(o=r.commentDelimiter)&&void 0!==o?o:DEFAULT_COMMENT_DELIMITER,N=buildCommentNodes(r.newComment,E,0);(b=this.nodes).splice.apply(b,[L,a-L+1].concat(_to_consumable_array(N),[h]))}else this.nodes[a]=h;return recalculateLineNumbers(this.nodes),!0}},{key:"upsert",value:function(e,r,t){void 0!==this.findLastProperty(e)?this.update(e,{newValue:r,escapeUnicode:null==t?void 0:t.escapeUnicode,separator:null==t?void 0:t.separator,newComment:null==t?void 0:t.comment,commentDelimiter:null==t?void 0:t.commentDelimiter}):this.insert(e,r,t)}},{key:"delete",value:function(e,r){var t="first"===(null==r?void 0:r.occurrence)?this.findFirstProperty(e):this.findLastProperty(e);if(void 0!==t){var n=t.index,o=t.node;if(!1!==(null==r?void 0:r.deleteLeadingNodes)){for(var i=n,a=n-1;a>=0&&"property"!==this.nodes[a].type;a--)i=a;this.nodes.splice(i,n-i+1)}else this.nodes.splice(n,1);return recalculateLineNumbers(this.nodes),o}}},{key:"deleteAll",value:function(e){for(var r=[],t=this.nodes.length-1;t>=0;t--){var n=this.nodes[t];"property"===n.type&&n.key===e&&(this.nodes.splice(t,1),r.push(n))}return r.length>0&&recalculateLineNumbers(this.nodes),r.reverse()}}]),e}();
@@ -1 +1 @@
1
- "use strict";function _export(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:Object.getOwnPropertyDescriptor(t,r).get})}Object.defineProperty(exports,"__esModule",{value:!0}),_export(exports,{get escapeKey(){return escapeKey},get escapeValue(){return escapeValue}});var escapeKey=function(e){return escapeContent(e,!0,arguments.length>1&&void 0!==arguments[1]&&arguments[1])},escapeValue=function(e){return escapeContent(e,!1,arguments.length>1&&void 0!==arguments[1]&&arguments[1])},REGEX_ESCAPE_NO_UNICODE=/[\s!#:=\\]/g,REGEX_ESCAPE_UNICODE=/[\s!#:=\\\u0000-\u001F\u007F-\uFFFF]/g,escapeContent=function(e,t,r){var n=r?REGEX_ESCAPE_UNICODE:REGEX_ESCAPE_NO_UNICODE;return n.lastIndex=0,e.replace(n,function(e,r){var n;switch(e){case" ":return t||0===r?"\\ ":" ";case"\\":return"\\\\";case"\f":return"\\f";case"\n":return"\\n";case"\r":return"\\r";case"\t":return"\\t";case"=":case":":case"#":case"!":return"\\".concat(e);default:return"\\u"+("0000"+(null!==(n=e.charCodeAt(0))&&void 0!==n?n:0).toString(16)).slice(-4)}})};
1
+ "use strict";function _export(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:Object.getOwnPropertyDescriptor(t,r).get})}Object.defineProperty(exports,"__esModule",{value:!0}),_export(exports,{get escapeKey(){return escapeKey},get escapeValue(){return escapeValue}});var escapeKey=function(e){return escapeContent(e,!0,arguments.length>1&&void 0!==arguments[1]&&arguments[1])},escapeValue=function(e){return escapeContent(e,!1,arguments.length>1&&void 0!==arguments[1]&&arguments[1])},REGEX_ESCAPE_NO_UNICODE=/[\s!#:=\\]/g,REGEX_ESCAPE_UNICODE=/[\s!#:=\\\u0000-\u001F\u007F-\uFFFF]/g,escapeContent=function(e,t,r){var n=r?REGEX_ESCAPE_UNICODE:REGEX_ESCAPE_NO_UNICODE;return n.lastIndex=0,e.replace(n,function(e,r){switch(e){case" ":return t||0===r?"\\ ":" ";case"\\":return"\\\\";case"\f":return"\\f";case"\n":return"\\n";case"\r":return"\\r";case"\t":return"\\t";case"=":case":":case"#":case"!":return"\\".concat(e);default:return"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)}})};
@@ -1,9 +1,7 @@
1
1
  /**
2
2
  * A key-value pair object.
3
3
  */
4
- export type KeyValuePairObject = {
5
- [key: string]: string;
6
- };
4
+ export type KeyValuePairObject = Record<string, string>;
7
5
  /**
8
6
  * Converts the content of a `.properties` file to a key-value pair object.
9
7
  *
package/dist/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"getProperties",{enumerable:!0,get:function(){return getProperties}});var CH_TAB=9,CH_FF=12,CH_SPACE=32,CH_BANG=33,CH_HASH=35,CH_COLON=58,CH_EQUALS=61,CH_BACKSLASH=92,CH_LOWER_F=102,CH_LOWER_N=110,CH_LOWER_R=114,CH_LOWER_T=116,CH_LOWER_U=117,CH_BOM=65279,skipWhitespace=function(e,r,t){for(;r<t;){var C=e.charCodeAt(r);if(C!==CH_SPACE&&C!==CH_TAB&&C!==CH_FF)break;r++}return r},isHexDigit=function(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102},hexValue=function(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e-87},unescapeContent=function(e){for(var r=e.length,t="",C=0,a=0;a<r;)if(e.charCodeAt(a)===CH_BACKSLASH){switch(a>C&&(t+=e.slice(C,a)),a++,e.charCodeAt(a)){case CH_LOWER_N:t+="\n",a++;break;case CH_LOWER_T:t+="\t",a++;break;case CH_LOWER_R:t+="\r",a++;break;case CH_LOWER_F:t+="\f",a++;break;case CH_LOWER_U:if(a+4>=r||!isHexDigit(e.charCodeAt(a+1))||!isHexDigit(e.charCodeAt(a+2))||!isHexDigit(e.charCodeAt(a+3))||!isHexDigit(e.charCodeAt(a+4))){var i=e.slice(a-1,a+5);throw new Error("malformed escaped unicode characters '".concat(i,"'"))}var c=hexValue(e.charCodeAt(a+1))<<12|hexValue(e.charCodeAt(a+2))<<8|hexValue(e.charCodeAt(a+3))<<4|hexValue(e.charCodeAt(a+4));t+=String.fromCharCode(c),a+=5;break;default:t+=e.charAt(a),a++}C=a}else a++;return C<r&&(t+=e.slice(C,r)),t},getProperties=function(e){for(var r="string"==typeof e?e:e.toString(),t={},C=(r.length>0&&r.charCodeAt(0)===CH_BOM?r.slice(1):r).split(/\r\n|\r|\n/),a=C.length,i=0;i<a;){var c=C[i],o=c.length,s=skipWhitespace(c,0,o);if(s>=o)i++;else{var H=c.charCodeAt(s);if(H!==CH_HASH&&H!==CH_BANG){for(var _=0,n=o-1;n>=0&&c.charCodeAt(n)===CH_BACKSLASH;n--)_++;var A=_%2==1,h=void 0,l=void 0;if(A){var f=(s>0?c.slice(s):c).slice(0,-1),d=[f];for(l=-1!==f.indexOf("\\");A&&i+1<a;){var u=C[++i],p=u.length,O=skipWhitespace(u,0,p);_=0;for(var v=p-1;v>=O&&u.charCodeAt(v)===CH_BACKSLASH;v--)_++;var L=(A=_%2==1)?u.slice(O,p-1):u.slice(O);l||-1===L.indexOf("\\")||(l=!0),d.push(L)}h=d.join("")}else l=-1!==(h=s>0?c.slice(s):c).indexOf("\\");for(var S=h.length,g=0,E=!1;g<S;){var x=h.charCodeAt(g);if(x!==CH_BACKSLASH){if(!E&&(x===CH_EQUALS||x===CH_COLON||x===CH_SPACE||x===CH_TAB||x===CH_FF))break;E=!1,g++}else E=!E,g++}var W=g;if(W<S){var B=h.charCodeAt(W);B!==CH_SPACE&&B!==CH_TAB&&B!==CH_FF||(W=skipWhitespace(h,W,S))<S&&(B=h.charCodeAt(W)),W<S&&(B===CH_EQUALS||B===CH_COLON)&&(W++,W=skipWhitespace(h,W,S))}var k=h.slice(0,g),R=h.slice(W);t[l?unescapeContent(k):k]=l?unescapeContent(R):R,i++}else i++}}return t};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"getProperties",{enumerable:!0,get:function(){return q}});var _=function(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1},S=function(e){if(-1===e.indexOf("\\"))return e;for(var r=e.length,a="",t=0,c=0;c<r;)if(92===e.charCodeAt(c)){if(c>t&&(a+=e.slice(t,c)),++c>=r){a+="\\",t=c;break}switch(e.charCodeAt(c)){case 110:a+="\n",c++;break;case 116:a+="\t",c++;break;case 114:a+="\r",c++;break;case 102:a+="\f",c++;break;case 117:if(c+4>=r)throw new Error("malformed escaped unicode characters '".concat(e.slice(c-1,c+5),"'"));var o=_(e.charCodeAt(c+1)),i=_(e.charCodeAt(c+2)),n=_(e.charCodeAt(c+3)),f=_(e.charCodeAt(c+4));if(o<0||i<0||n<0||f<0)throw new Error("malformed escaped unicode characters '".concat(e.slice(c-1,c+5),"'"));a+=String.fromCharCode(o<<12|i<<8|n<<4|f),c+=5;break;default:a+=e.charAt(c),c++}t=c}else c++;return t<r&&(a+=e.slice(t,r)),a},H=function(e,r,a){for(;r<a;){var t=e.charCodeAt(r);if(32!==t&&9!==t&&12!==t)break;r++}return r},q=function(e){for(var r="string"==typeof e?e:e.toString(),a={},t=(r.length>0&&65279===r.charCodeAt(0)?r.slice(1):r).split(/\r\n|\r|\n/),c=t.length,o=0;o<c;){var i=t[o],n=i.length,f=H(i,0,n);if(f>=n)o++;else{var s=i.charCodeAt(f);if(35!==s&&33!==s){for(var d=0,l=n-1;l>=0&&92===i.charCodeAt(l);l--)d++;var h=d%2==1,v=void 0,u=void 0;if(h){var C=(f>0?i.slice(f):i).slice(0,-1),A=[C];for(u=-1!==C.indexOf("\\");h&&o+1<c;){var b=t[++o],g=b.length,p=H(b,0,g);d=0;for(var k=g-1;k>=p&&92===b.charCodeAt(k);k--)d++;var _=(h=d%2==1)?b.slice(p,g-1):b.slice(p);!u&&-1!==_.indexOf("\\")&&(u=!0),A.push(_)}v=A.join("")}else u=-1!==(v=f>0?i.slice(f):i).indexOf("\\");for(var m=v.length,x=0,O=!1;x<m;){var w=v.charCodeAt(x);if(92!==w){if(!O&&(61===w||58===w||32===w||9===w||12===w))break;O=!1,x++}else O=!O,x++}var j=x;if(j<m){var y=v.charCodeAt(j);(32===y||9===y||12===y)&&((j=H(v,j,m))<m&&(y=v.charCodeAt(j))),j<m&&(61===y||58===y)&&(j++,j=H(v,j,m))}var P=v.slice(0,x),q=v.slice(j);a[u?S(P):P]=u?S(q):q,o++}else o++}}return a};
@@ -74,9 +74,7 @@ export type BlankLineNode = {
74
74
  /** Discriminated union of all node types in a `.properties` file. */
75
75
  export type PropertiesNode = PropertyNode | CommentNode | BlankLineNode;
76
76
  /** A plain key-value pair object where every value is a string. */
77
- export type KeyValuePairObject = {
78
- [key: string]: string;
79
- };
77
+ export type KeyValuePairObject = Record<string, string>;
80
78
  /** Information about a key that appears more than once. */
81
79
  export type KeyCollisions = {
82
80
  /** The duplicate key. */
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"formatNormalized",{enumerable:!0,get:function(){return formatNormalized}});var _index=require("../escape/index.js"),BOM="\ufeff",wrapAtWidth=function(e,a){if(e.length<=a)return e;for(var r=[],i=0,t=e.length;i<t;){var o=Math.min(i+a,t);if(o<t)for(var n=0;n<6&&o-n>i;n++){var p=o-n;if(p+5<=t&&"\\"===e[p]&&"u"===e[p+1]){o=p;break}}r.push(e.slice(i,o)),i=o}return r.join("\\\n ")},rebuildPropertyLine=function(e,a){var r,i,t,o,n=!0===a.escapeUnicode,p=a.removeLeadingWhitespace?"":e.leadingWhitespace,s=n?(0,_index.escapeKey)(e.key,!0):e.escapedKey;void 0!==a.separatorChar?(i=void 0!==a.separatorLeading?a.separatorLeading:e.separatorLeading,t=" "===a.separatorChar?"":a.separatorChar,o=void 0!==a.separatorTrailing?a.separatorTrailing:e.separatorTrailing," "===a.separatorChar&&(i=void 0!==a.separatorLeading?a.separatorLeading:" ")):(i=void 0!==a.separatorLeading?a.separatorLeading:e.separatorLeading,t=null!==(r=e.separatorChar)&&void 0!==r?r:"",o=void 0!==a.separatorTrailing?a.separatorTrailing:e.separatorTrailing);var d=n?(0,_index.escapeValue)(e.value,!0):e.escapedValue;return void 0!==a.wrapKeysAt&&a.wrapKeysAt>0&&(s=wrapAtWidth(s,a.wrapKeysAt)),void 0!==a.wrapValuesAt&&a.wrapValuesAt>0&&(d=wrapAtWidth(d,a.wrapValuesAt)),"".concat(p).concat(s).concat(i).concat(t).concat(o).concat(d)},formatNormalized=function(e,a,r,i){var t,o,n=null!==(t=i.endOfLineCharacter)&&void 0!==t?t:r,p=void 0!==i.separatorChar||void 0!==i.separatorLeading||void 0!==i.separatorTrailing||!0===i.escapeUnicode||!0===i.collapseMultiline||void 0!==i.wrapKeysAt||void 0!==i.wrapValuesAt||!0===i.removeLeadingWhitespace;if(i.deduplicateKeys){for(var s={},d=[],c=e.length-1;c>=0;c--){var l=e[c];"property"===l.type&&(s[l.key]?d.push(c):s[l.key]=!0)}o={};var u=!0,v=!1,f=void 0;try{for(var h,y=d[Symbol.iterator]();!(u=(h=y.next()).done);u=!0){var g=h.value;if(o[g]=!0,!i.deduplicateKeysKeepLeadingNodes)for(var L=g-1;L>=0&&"property"!==e[L].type;L--)o[L]=!0}}catch(e){v=!0,f=e}finally{try{u||null==y.return||y.return()}finally{if(v)throw f}}}for(var m=[],w=0;w<e.length;w++)if(!o||!o[w]){var b=e[w];switch(b.type){case"comment":if(i.removeComments)continue;m.push(i.removeLeadingWhitespace?"".concat(b.delimiter).concat(b.body):b.rawLine);break;case"blank":if(i.removeBlankLines)continue;m.push(b.rawLine);break;case"property":p?m.push(rebuildPropertyLine(b,i)):m.push(b.rawLines.join(n))}}return(a?BOM:"")+m.join(n)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"formatNormalized",{enumerable:!0,get:function(){return formatNormalized}});var _index=require("../escape/index.js"),BOM="\ufeff",wrapAtWidth=function(e,a){if(e.length<=a)return e;for(var r=[],i=0,t=e.length;i<t;){var o=Math.min(i+a,t);if(o<t)for(var n=0;n<6&&o-n>i;n++){var p=o-n;if(p+5<=t&&"\\"===e[p]&&"u"===e[p+1]){o=p;break}}r.push(e.slice(i,o)),i=o}return r.join("\\\n ")},rebuildPropertyLine=function(e,a){var r,i,t,o,n,p,s,l,d,c=!0===a.escapeUnicode,u=a.removeLeadingWhitespace?"":e.leadingWhitespace,v=c?(0,_index.escapeKey)(e.key,!0):e.escapedKey;void 0!==a.separatorChar?(s=null!==(r=a.separatorLeading)&&void 0!==r?r:e.separatorLeading,l=" "===a.separatorChar?"":a.separatorChar,d=null!==(i=a.separatorTrailing)&&void 0!==i?i:e.separatorTrailing," "===a.separatorChar&&(s=null!==(t=a.separatorLeading)&&void 0!==t?t:" ")):(s=null!==(o=a.separatorLeading)&&void 0!==o?o:e.separatorLeading,l=null!==(n=e.separatorChar)&&void 0!==n?n:"",d=null!==(p=a.separatorTrailing)&&void 0!==p?p:e.separatorTrailing);var f=c?(0,_index.escapeValue)(e.value,!0):e.escapedValue;return void 0!==a.wrapKeysAt&&a.wrapKeysAt>0&&(v=wrapAtWidth(v,a.wrapKeysAt)),void 0!==a.wrapValuesAt&&a.wrapValuesAt>0&&(f=wrapAtWidth(f,a.wrapValuesAt)),"".concat(u).concat(v).concat(s).concat(l).concat(d).concat(f)},formatNormalized=function(e,a,r,i){var t,o,n=null!==(t=i.endOfLineCharacter)&&void 0!==t?t:r,p=void 0!==i.separatorChar||void 0!==i.separatorLeading||void 0!==i.separatorTrailing||!0===i.escapeUnicode||!0===i.collapseMultiline||void 0!==i.wrapKeysAt||void 0!==i.wrapValuesAt||!0===i.removeLeadingWhitespace;if(i.deduplicateKeys){for(var s={},l=[],d=e.length-1;d>=0;d--){var c=e[d];"property"===c.type&&(s[c.key]?l.push(d):s[c.key]=!0)}o={};var u=!0,v=!1,f=void 0;try{for(var h,y=l[Symbol.iterator]();!(u=(h=y.next()).done);u=!0){var g=h.value;if(o[g]=!0,!i.deduplicateKeysKeepLeadingNodes)for(var m=g-1;m>=0&&"property"!==e[m].type;m--)o[m]=!0}}catch(e){v=!0,f=e}finally{try{u||null==y.return||y.return()}finally{if(v)throw f}}}for(var L=[],w=0;w<e.length;w++)if(!(null==o?void 0:o[w])){var b=e[w];switch(b.type){case"comment":if(i.removeComments)continue;L.push(i.removeLeadingWhitespace?"".concat(b.delimiter).concat(b.body):b.rawLine);break;case"blank":if(i.removeBlankLines)continue;L.push(b.rawLine);break;case"property":p?L.push(rebuildPropertyLine(b,i)):L.push(b.rawLines.join(n))}}return(a?BOM:"")+L.join(n)};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"parseDocument",{enumerable:!0,get:function(){return parseDocument}});var _index=require("../unescape/index.js"),CH_TAB=9,CH_LF=10,CH_FF=12,CH_CR=13,CH_SPACE=32,CH_BANG=33,CH_HASH=35,CH_COLON=58,CH_EQUALS=61,CH_BACKSLASH=92,CH_BOM=65279,isWhitespace=function(e){return e===CH_SPACE||e===CH_TAB||e===CH_FF},countTrailingBackslashes=function(e,r){for(var a=0,i=r-1;i>=0&&e.charCodeAt(i)===CH_BACKSLASH;)a++,i--;return a},parseDocument=function(e){var r="string"==typeof e?e:e.toString(),a=r.length,i=0,t=a>0&&r.charCodeAt(0)===CH_BOM;t&&(i=1);for(var n="\n",s=i;s<a;s++){var c=r.charCodeAt(s);if(c===CH_CR){n=s+1<a&&r.charCodeAt(s+1)===CH_LF?"\r\n":"\r";break}if(c===CH_LF){n="\n";break}}for(var o=(i>0?r.slice(i):r).split(/\r\n|\r|\n/),C=[],l=0,h=o.length;l<h;){for(var H=o[l],p=l+1,d=0,u=H.length;d<u&&isWhitespace(H.charCodeAt(d));)d++;if(d>=u){var _={type:"blank",rawLine:H,lineNumber:p};C.push(_),l++}else{var v=H.charCodeAt(d);if(v!==CH_HASH&&v!==CH_BANG){for(var f=[H],A=p,g=d>0?H.slice(0,d):"",L=countTrailingBackslashes(H,u),S=L%2==1;S&&l+1<h;){var B=o[++l];f.push(B);var b=B.length;S=(L=countTrailingBackslashes(B,b))%2==1}var m=l+1,O=S,y=void 0;if(1===f.length){var N=d>0?H.slice(d):H;y=O?N.slice(0,-1):N}else{for(var k=[],x=0;x<f.length;x++){var W=f[x],F=void 0,E=void 0;if(0===x)F=d,E=W.length-1;else{F=0;for(var T=W.length;F<T&&isWhitespace(W.charCodeAt(F));)F++;E=x===f.length-1&&!O?T:T-1}k.push(W.slice(F,E))}y=k.join("")}for(var j=y.length,K=0,P=!1;K<j;){var Q=y.charCodeAt(K);if(Q!==CH_BACKSLASH){if(!P&&(Q===CH_EQUALS||Q===CH_COLON||isWhitespace(Q)))break;P=!1,K++}else P=!P,K++}var U=y.slice(0,K),w="",D=void 0,M="",G=K;if(G<j){for(var R=G;G<j&&isWhitespace(y.charCodeAt(G));)G++;if(G<j){var q=y.charCodeAt(G);if(q===CH_EQUALS||q===CH_COLON){w=y.slice(R,G),D=q===CH_EQUALS?"=":":";for(var V=++G;G<j&&isWhitespace(y.charCodeAt(G));)G++;M=y.slice(V,G)}else w=y.slice(R,G)}else w=y.slice(R,G)}var z=y.slice(G),I={type:"property",rawLines:f,leadingWhitespace:g,key:-1!==U.indexOf("\\")?(0,_index.unescapeContent)(U):U,escapedKey:U,separatorLeading:w,separatorChar:D,separatorTrailing:M,value:-1!==z.indexOf("\\")?(0,_index.unescapeContent)(z):z,escapedValue:z,startingLineNumber:A,endingLineNumber:m};C.push(I),l++}else{var J={type:"comment",rawLine:H,leadingWhitespace:d>0?H.slice(0,d):"",delimiter:v===CH_HASH?"#":"!",body:H.slice(d+1),lineNumber:p};C.push(J),l++}}}return{hasBom:t,eolCharacter:n,nodes:C}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"parseDocument",{enumerable:!0,get:function(){return parseDocument}});var _characters=require("../characters.js"),_index=require("../unescape/index.js"),isWhitespace=function(e){return e===_characters.CH_SPACE||e===_characters.CH_TAB||e===_characters.CH_FF},countTrailingBackslashes=function(e,r){for(var a=0,c=r-1;c>=0&&e.charCodeAt(c)===_characters.CH_BACKSLASH;)a++,c--;return a},parseDocument=function(e){var r="string"==typeof e?e:e.toString(),a=r.length,c=0,t=a>0&&r.charCodeAt(0)===_characters.CH_BOM;t&&(c=1);for(var s="\n",i=c;i<a;i++){var n=r.charCodeAt(i);if(n===_characters.CH_CR){s=i+1<a&&r.charCodeAt(i+1)===_characters.CH_LF?"\r\n":"\r";break}if(n===_characters.CH_LF){s="\n";break}}for(var h=(c>0?r.slice(c):r).split(/\r\n|\r|\n/),o=[],l=0,_=h.length;l<_;){for(var C=h[l],p=l+1,u=0,d=C.length;u<d&&isWhitespace(C.charCodeAt(u));)u++;if(u>=d){var v={type:"blank",rawLine:C,lineNumber:p};o.push(v),l++}else{var f=C.charCodeAt(u);if(f!==_characters.CH_HASH&&f!==_characters.CH_BANG){for(var A=[C],H=p,g=u>0?C.slice(0,u):"",L=countTrailingBackslashes(C,d),b=L%2==1;b&&l+1<_;){var m=h[++l];A.push(m);var S=m.length;b=(L=countTrailingBackslashes(m,S))%2==1}var y=l+1,B=b,O=void 0;if(1===A.length){var k=u>0?C.slice(u):C;O=B?k.slice(0,-1):k}else{for(var x=[],W=0;W<A.length;W++){var N=A[W],j=void 0,T=void 0;if(0===W)j=u,T=N.length-1;else{j=0;for(var E=N.length;j<E&&isWhitespace(N.charCodeAt(j));)j++;T=W===A.length-1&&!B?E:E-1}x.push(N.slice(j,T))}O=x.join("")}for(var F=O.length,w=0,D=!1;w<F;){var K=O.charCodeAt(w);if(K!==_characters.CH_BACKSLASH){if(!D&&(K===_characters.CH_EQUALS||K===_characters.CH_COLON||isWhitespace(K)))break;D=!1,w++}else D=!D,w++}var P=O.slice(0,w),Q="",U=void 0,q="",M=w;if(M<F){for(var G=M;M<F&&isWhitespace(O.charCodeAt(M));)M++;if(M<F){var R=O.charCodeAt(M);if(R===_characters.CH_EQUALS||R===_characters.CH_COLON){Q=O.slice(G,M),U=R===_characters.CH_EQUALS?"=":":";for(var V=++M;M<F&&isWhitespace(O.charCodeAt(M));)M++;q=O.slice(V,M)}else Q=O.slice(G,M)}else Q=O.slice(G,M)}var z=O.slice(M),I={type:"property",rawLines:A,leadingWhitespace:g,key:-1!==P.indexOf("\\")?(0,_index.unescapeContent)(P):P,escapedKey:P,separatorLeading:Q,separatorChar:U,separatorTrailing:q,value:-1!==z.indexOf("\\")?(0,_index.unescapeContent)(z):z,escapedValue:z,startingLineNumber:H,endingLineNumber:y};o.push(I),l++}else{var J={type:"comment",rawLine:C,leadingWhitespace:u>0?C.slice(0,u):"",delimiter:f===_characters.CH_HASH?"#":"!",body:C.slice(u+1),lineNumber:p};o.push(J),l++}}}return{hasBom:t,eolCharacter:s,nodes:o}};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"Properties",{enumerable:!0,get:function(){return Properties}});var _normalize=require("./normalize.js"),_parse=require("./parse.js");function _instanceof(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):e instanceof r}function _class_call_check(e,r){if(!_instanceof(e,r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _create_class(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),e}var BOM="\ufeff",Properties=function(){function e(r){_class_call_check(this,e);var t=(0,_parse.parseDocument)(r);this.hasBom=t.hasBom,this.eolCharacter=t.eolCharacter,this.nodes=t.nodes}return _create_class(e,[{key:"getProperties",value:function(){return this.nodes.filter(function(e){return"property"===e.type})}},{key:"getComments",value:function(){return this.nodes.filter(function(e){return"comment"===e.type})}},{key:"getBlankLines",value:function(){return this.nodes.filter(function(e){return"blank"===e.type})}},{key:"toObject",value:function(){var e={},r=!0,t=!1,n=void 0;try{for(var o,a=this.nodes[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var i=o.value;"property"===i.type&&(e[i.key]=i.value)}}catch(e){t=!0,n=e}finally{try{r||null==a.return||a.return()}finally{if(t)throw n}}return e}},{key:"getPropertyNodes",value:function(e){return this.nodes.filter(function(r){return"property"===r.type&&r.key===e})}},{key:"getEffectiveProperty",value:function(e){for(var r=this.nodes.length-1;r>=0;r--){var t=this.nodes[r];if("property"===t.type&&t.key===e)return t}}},{key:"getKeyCollisions",value:function(){var e={},r=!0,t=!1,n=void 0;try{for(var o,a=this.nodes[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var i=o.value;"property"===i.type&&(e[i.key]||(e[i.key]=[]),e[i.key].push(i))}}catch(e){t=!0,n=e}finally{try{r||null==a.return||a.return()}finally{if(t)throw n}}var s=[],l=!0,u=!1,f=void 0;try{for(var y,c=Object.keys(e)[Symbol.iterator]();!(l=(y=c.next()).done);l=!0){var p=y.value;e[p].length>1&&s.push({key:p,nodes:e[p]})}}catch(e){u=!0,f=e}finally{try{l||null==c.return||c.return()}finally{if(u)throw f}}return s}},{key:"getLeadingNodes",value:function(e){for(var r=-1,t=this.nodes.length-1;t>=0;t--){var n=this.nodes[t];if("property"===n.type&&n.key===e){r=t;break}}if(r<=0)return[];for(var o=[],a=r-1;a>=0;a--){var i=this.nodes[a];if("property"===i.type)break;o.unshift(i)}return o}},{key:"format",value:function(e){if(!e){var r=this.eolCharacter,t=[],n=!0,o=!1,a=void 0;try{for(var i,s=this.nodes[Symbol.iterator]();!(n=(i=s.next()).done);n=!0){var l=i.value;"property"===l.type?t.push(l.rawLines.join(r)):t.push(l.rawLine)}}catch(e){o=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(o)throw a}}return(this.hasBom?BOM:"")+t.join(r)}return(0,_normalize.formatNormalized)(this.nodes,this.hasBom,this.eolCharacter,e)}}]),e}();
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"Properties",{enumerable:!0,get:function(){return Properties}});var _normalize=require("./normalize.js"),_parse=require("./parse.js");function _instanceof(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):e instanceof r}function _class_call_check(e,r){if(!_instanceof(e,r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _create_class(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),e}var BOM="\ufeff",Properties=function(){function e(r){_class_call_check(this,e);var t=(0,_parse.parseDocument)(r);this.hasBom=t.hasBom,this.eolCharacter=t.eolCharacter,this.nodes=t.nodes}return _create_class(e,[{key:"getProperties",value:function(){return this.nodes.filter(function(e){return"property"===e.type})}},{key:"getComments",value:function(){return this.nodes.filter(function(e){return"comment"===e.type})}},{key:"getBlankLines",value:function(){return this.nodes.filter(function(e){return"blank"===e.type})}},{key:"toObject",value:function(){var e={},r=!0,t=!1,n=void 0;try{for(var o,i=this.nodes[Symbol.iterator]();!(r=(o=i.next()).done);r=!0){var a=o.value;"property"===a.type&&(e[a.key]=a.value)}}catch(e){t=!0,n=e}finally{try{r||null==i.return||i.return()}finally{if(t)throw n}}return e}},{key:"getPropertyNodes",value:function(e){return this.nodes.filter(function(r){return"property"===r.type&&r.key===e})}},{key:"getEffectiveProperty",value:function(e){for(var r=this.nodes.length-1;r>=0;r--){var t=this.nodes[r];if("property"===t.type&&t.key===e)return t}}},{key:"getKeyCollisions",value:function(){var e={},r=!0,t=!1,n=void 0;try{for(var o,i=this.nodes[Symbol.iterator]();!(r=(o=i.next()).done);r=!0){var a=o.value;if("property"===a.type){var s=e[a.key];void 0===s?e[a.key]=[a]:s.push(a)}}}catch(e){t=!0,n=e}finally{try{r||null==i.return||i.return()}finally{if(t)throw n}}var l=[],u=!0,f=!1,y=void 0;try{for(var c,p=Object.keys(e)[Symbol.iterator]();!(u=(c=p.next()).done);u=!0){var h=c.value,v=e[h];void 0!==v&&v.length>1&&l.push({key:h,nodes:v})}}catch(e){f=!0,y=e}finally{try{u||null==p.return||p.return()}finally{if(f)throw y}}return l}},{key:"getLeadingNodes",value:function(e){for(var r=-1,t=this.nodes.length-1;t>=0;t--){var n=this.nodes[t];if("property"===n.type&&n.key===e){r=t;break}}if(r<=0)return[];for(var o=[],i=r-1;i>=0;i--){var a=this.nodes[i];if("property"===a.type)break;o.unshift(a)}return o}},{key:"format",value:function(e){if(!e){var r=this.eolCharacter,t=[],n=!0,o=!1,i=void 0;try{for(var a,s=this.nodes[Symbol.iterator]();!(n=(a=s.next()).done);n=!0){var l=a.value;"property"===l.type?t.push(l.rawLines.join(r)):t.push(l.rawLine)}}catch(e){o=!0,i=e}finally{try{n||null==s.return||s.return()}finally{if(o)throw i}}return(this.hasBom?BOM:"")+t.join(r)}return(0,_normalize.formatNormalized)(this.nodes,this.hasBom,this.eolCharacter,e)}}]),e}();
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"unescapeContent",{enumerable:!0,get:function(){return unescapeContent}});var CH_BACKSLASH=92,CH_LOWER_F=102,CH_LOWER_N=110,CH_LOWER_R=114,CH_LOWER_T=116,CH_LOWER_U=117,isHexDigit=function(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102},hexValue=function(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e-87},unescapeContent=function(e){if(-1===e.indexOf("\\"))return e;for(var r=e.length,t="",a=0,c=0;c<r;)if(e.charCodeAt(c)===CH_BACKSLASH){if(c>a&&(t+=e.slice(a,c)),++c>=r){t+="\\",a=c;break}switch(e.charCodeAt(c)){case CH_LOWER_N:t+="\n",c++;break;case CH_LOWER_T:t+="\t",c++;break;case CH_LOWER_R:t+="\r",c++;break;case CH_LOWER_F:t+="\f",c++;break;case CH_LOWER_U:if(c+4>=r||!isHexDigit(e.charCodeAt(c+1))||!isHexDigit(e.charCodeAt(c+2))||!isHexDigit(e.charCodeAt(c+3))||!isHexDigit(e.charCodeAt(c+4))){var i=e.slice(c-1,c+5);throw new Error("malformed escaped unicode characters '".concat(i,"'"))}var n=hexValue(e.charCodeAt(c+1))<<12|hexValue(e.charCodeAt(c+2))<<8|hexValue(e.charCodeAt(c+3))<<4|hexValue(e.charCodeAt(c+4));t+=String.fromCharCode(n),c+=5;break;default:t+=e.charAt(c),c++}a=c}else c++;return a<r&&(t+=e.slice(a,r)),t};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"unescapeContent",{enumerable:!0,get:function(){return unescapeContent}});var _characters=require("../characters.js"),hexValue=function(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1},unescapeContent=function(e){if(-1===e.indexOf("\\"))return e;for(var r=e.length,a="",c=0,t=0;t<r;)if(e.charCodeAt(t)===_characters.CH_BACKSLASH){if(t>c&&(a+=e.slice(c,t)),++t>=r){a+="\\",c=t;break}switch(e.charCodeAt(t)){case _characters.CH_LOWER_N:a+="\n",t++;break;case _characters.CH_LOWER_T:a+="\t",t++;break;case _characters.CH_LOWER_R:a+="\r",t++;break;case _characters.CH_LOWER_F:a+="\f",t++;break;case _characters.CH_LOWER_U:if(t+4>=r)throw new Error("malformed escaped unicode characters '".concat(e.slice(t-1,t+5),"'"));var n=hexValue(e.charCodeAt(t+1)),s=hexValue(e.charCodeAt(t+2)),o=hexValue(e.charCodeAt(t+3)),h=hexValue(e.charCodeAt(t+4));if(n<0||s<0||o<0||h<0)throw new Error("malformed escaped unicode characters '".concat(e.slice(t-1,t+5),"'"));a+=String.fromCharCode(n<<12|s<<8|o<<4|h),t+=5;break;default:a+=e.charAt(t),t++}c=t}else t++;return c<r&&(a+=e.slice(c,r)),a};
@@ -0,0 +1,32 @@
1
+ /** Tab character code. */
2
+ export declare const CH_TAB = 9;
3
+ /** Line feed character code. */
4
+ export declare const CH_LF = 10;
5
+ /** Form feed character code. */
6
+ export declare const CH_FF = 12;
7
+ /** Carriage return character code. */
8
+ export declare const CH_CR = 13;
9
+ /** Space character code. */
10
+ export declare const CH_SPACE = 32;
11
+ /** Exclamation mark character code (comment delimiter). */
12
+ export declare const CH_BANG = 33;
13
+ /** Hash character code (comment delimiter). */
14
+ export declare const CH_HASH = 35;
15
+ /** Colon character code (separator). */
16
+ export declare const CH_COLON = 58;
17
+ /** Equals character code (separator). */
18
+ export declare const CH_EQUALS = 61;
19
+ /** Backslash character code (escape / continuation). */
20
+ export declare const CH_BACKSLASH = 92;
21
+ /** Lowercase 'f' character code (formfeed escape). */
22
+ export declare const CH_LOWER_F = 102;
23
+ /** Lowercase 'n' character code (newline escape). */
24
+ export declare const CH_LOWER_N = 110;
25
+ /** Lowercase 'r' character code (carriage return escape). */
26
+ export declare const CH_LOWER_R = 114;
27
+ /** Lowercase 't' character code (tab escape). */
28
+ export declare const CH_LOWER_T = 116;
29
+ /** Lowercase 'u' character code (unicode escape). */
30
+ export declare const CH_LOWER_U = 117;
31
+ /** Byte Order Mark character code. */
32
+ export declare const CH_BOM = 65279;
@@ -0,0 +1 @@
1
+ export var CH_TAB=9;export var CH_LF=10;export var CH_FF=12;export var CH_CR=13;export var CH_SPACE=32;export var CH_BANG=33;export var CH_HASH=35;export var CH_COLON=58;export var CH_EQUALS=61;export var CH_BACKSLASH=92;export var CH_LOWER_F=102;export var CH_LOWER_N=110;export var CH_LOWER_R=114;export var CH_LOWER_T=116;export var CH_LOWER_U=117;export var CH_BOM=65279;
@@ -104,21 +104,21 @@ export type DeleteOptions = {
104
104
  */
105
105
  export declare class PropertiesEditor extends Properties {
106
106
  /**
107
- * Find the index of the first property node with the given key.
107
+ * Find the first property node with the given key.
108
108
  *
109
109
  * @param key - The unescaped key to search for.
110
110
  *
111
- * @returns The index in `this.nodes`, or `-1` if not found.
111
+ * @returns The matching node and its index in `this.nodes`, or `undefined`.
112
112
  */
113
- private findFirstPropertyIndex;
113
+ private findFirstProperty;
114
114
  /**
115
- * Find the index of the last property node with the given key.
115
+ * Find the last property node with the given key.
116
116
  *
117
117
  * @param key - The unescaped key to search for.
118
118
  *
119
- * @returns The index in `this.nodes`, or `-1` if not found.
119
+ * @returns The matching node and its index in `this.nodes`, or `undefined`.
120
120
  */
121
- private findLastPropertyIndex;
121
+ private findLastProperty;
122
122
  /**
123
123
  * Insert a new property.
124
124
  *
@@ -1 +1 @@
1
- function _array_like_to_array(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function _array_without_holes(e){if(Array.isArray(e))return _array_like_to_array(e)}function _assert_this_initialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _call_super(e,r,t){return r=_get_prototype_of(r),_possible_constructor_return(e,_is_native_reflect_construct()?Reflect.construct(r,t||[],_get_prototype_of(e).constructor):r.apply(e,t))}function _class_call_check(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _create_class(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),e}function _get_prototype_of(e){return _get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},_get_prototype_of(e)}function _inherits(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),r&&_set_prototype_of(e,r)}function _iterable_to_array(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _non_iterable_spread(){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 _possible_constructor_return(e,r){return!r||"object"!==_type_of(r)&&"function"!=typeof r?_assert_this_initialized(e):r}function _set_prototype_of(e,r){return _set_prototype_of=Object.setPrototypeOf||function(e,r){return e.__proto__=r,e},_set_prototype_of(e,r)}function _to_consumable_array(e){return _array_without_holes(e)||_iterable_to_array(e)||_unsupported_iterable_to_array(e)||_non_iterable_spread()}function _type_of(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function _unsupported_iterable_to_array(e,r){if(e){if("string"==typeof e)return _array_like_to_array(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(t):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_array_like_to_array(e,r):void 0}}function _is_native_reflect_construct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_is_native_reflect_construct=function(){return!!e})()}import{escapeKey,escapeValue}from"../escape/index.js";import{Properties}from"../parser/properties.js";var DEFAULT_SEPARATOR="=",DEFAULT_COMMENT_DELIMITER="#",REGEX_NEWLINE=/\r\n|\r|\n/,buildPropertyNode=function(e,r,t,n){var o,a=!0===t.escapeUnicode,i=escapeKey(e,a),s=escapeValue(r,a),l=" "===t.separator?void 0:null!==(o=t.separator)&&void 0!==o?o:DEFAULT_SEPARATOR,c=l?" ":"",u=l?"".concat(" ").concat(l).concat(c):" ",p="".concat(i).concat(u).concat(s).split(REGEX_NEWLINE);return{type:"property",rawLines:p,leadingWhitespace:"",key:e,escapedKey:i,separatorLeading:" ",separatorChar:l,separatorTrailing:c,value:r,escapedValue:s,startingLineNumber:n,endingLineNumber:n+p.length-1}},buildCommentNodes=function(e,r,t){return e.split(REGEX_NEWLINE).map(function(e,n){return""===e?{type:"blank",rawLine:"",lineNumber:t+n}:{type:"comment",rawLine:"".concat(r," ").concat(e),leadingWhitespace:"",delimiter:r,body:" ".concat(e),lineNumber:t+n}})},recalculateLineNumbers=function(e){var r=1,t=!0,n=!1,o=void 0;try{for(var a,i=e[Symbol.iterator]();!(t=(a=i.next()).done);t=!0){var s=a.value;if("property"===s.type){var l=s.rawLines.length;s.startingLineNumber=r,s.endingLineNumber=r+l-1,r+=l}else s.lineNumber=r,r++}}catch(e){n=!0,o=e}finally{try{t||null==i.return||i.return()}finally{if(n)throw o}}};export var PropertiesEditor=function(e){"use strict";function r(){return _class_call_check(this,r),_call_super(this,r,arguments)}return _inherits(r,e),_create_class(r,[{key:"findFirstPropertyIndex",value:function(e){for(var r=0;r<this.nodes.length;r++){var t=this.nodes[r];if("property"===t.type&&t.key===e)return r}return-1}},{key:"findLastPropertyIndex",value:function(e){for(var r=this.nodes.length-1;r>=0;r--){var t=this.nodes[r];if("property"===t.type&&t.key===e)return r}return-1}},{key:"insert",value:function(e,r,t){var n,o,a=[];if(void 0!==(null==t?void 0:t.comment)){var i,s=null!==(o=t.commentDelimiter)&&void 0!==o?o:DEFAULT_COMMENT_DELIMITER;(i=a).push.apply(i,_to_consumable_array(buildCommentNodes(t.comment,s,0)))}if(a.push(buildPropertyNode(e,r,{escapeUnicode:null==t?void 0:t.escapeUnicode,separator:null==t?void 0:t.separator},0)),null==t?void 0:t.referenceKey){var l=this.findLastPropertyIndex(t.referenceKey);if(-1!==l){var c,u="before"===t.position?l:l+1;return(c=this.nodes).splice.apply(c,[u,0].concat(_to_consumable_array(a))),void recalculateLineNumbers(this.nodes)}}(n=this.nodes).push.apply(n,_to_consumable_array(a)),recalculateLineNumbers(this.nodes)}},{key:"insertComment",value:function(e,r){var t,n,o=null!==(n=null==r?void 0:r.commentDelimiter)&&void 0!==n?n:DEFAULT_COMMENT_DELIMITER,a=buildCommentNodes(e,o,0);if(null==r?void 0:r.referenceKey){var i=this.findLastPropertyIndex(r.referenceKey);if(-1!==i){var s,l="before"===r.position?i:i+1;return(s=this.nodes).splice.apply(s,[l,0].concat(_to_consumable_array(a))),void recalculateLineNumbers(this.nodes)}}(t=this.nodes).push.apply(t,_to_consumable_array(a)),recalculateLineNumbers(this.nodes)}},{key:"insertBlankLine",value:function(e){var r={type:"blank",rawLine:"",lineNumber:0};if(null==e?void 0:e.referenceKey){var t=this.findLastPropertyIndex(e.referenceKey);if(-1!==t){var n="before"===e.position?t:t+1;return this.nodes.splice(n,0,r),void recalculateLineNumbers(this.nodes)}}this.nodes.push(r),recalculateLineNumbers(this.nodes)}},{key:"update",value:function(e,r){var t,n,o,a=this.findLastPropertyIndex(e);if(-1===a)return!1;var i=this.nodes[a],s=null!==(t=r.newKey)&&void 0!==t?t:i.key,l=null!==(n=r.newValue)&&void 0!==n?n:i.value,c=!0===r.escapeUnicode,u=c?escapeKey(s,!0):void 0!==r.newKey?escapeKey(s):i.escapedKey,p=c?escapeValue(l,!0):void 0!==r.newValue?escapeValue(l):i.escapedValue,_=r.separator?" "===r.separator?void 0:r.separator:i.separatorChar,d=r.separator?" ":i.separatorLeading,y=r.separator?_?" ":"":i.separatorTrailing,f=_?"".concat(d).concat(_).concat(y):d,m="".concat(u).concat(f).concat(p).split(REGEX_NEWLINE),v={type:"property",rawLines:m,leadingWhitespace:i.leadingWhitespace,key:s,escapedKey:u,separatorLeading:d,separatorChar:_,separatorTrailing:y,value:l,escapedValue:p,startingLineNumber:i.startingLineNumber,endingLineNumber:i.startingLineNumber+m.length-1};if(void 0!==r.newComment){for(var h,b=a,L=a-1;L>=0&&"property"!==this.nodes[L].type;L--)b=L;var g=null!==(o=r.commentDelimiter)&&void 0!==o?o:DEFAULT_COMMENT_DELIMITER,E=buildCommentNodes(r.newComment,g,0);(h=this.nodes).splice.apply(h,[b,a-b+1].concat(_to_consumable_array(E),[v]))}else this.nodes[a]=v;return recalculateLineNumbers(this.nodes),!0}},{key:"upsert",value:function(e,r,t){-1!==this.findLastPropertyIndex(e)?this.update(e,{newValue:r,escapeUnicode:null==t?void 0:t.escapeUnicode,separator:null==t?void 0:t.separator,newComment:null==t?void 0:t.comment,commentDelimiter:null==t?void 0:t.commentDelimiter}):this.insert(e,r,t)}},{key:"delete",value:function(e,r){var t="first"===(null==r?void 0:r.occurrence)?this.findFirstPropertyIndex(e):this.findLastPropertyIndex(e);if(-1!==t){var n=this.nodes[t];if(!1!==(null==r?void 0:r.deleteLeadingNodes)){for(var o=t,a=t-1;a>=0&&"property"!==this.nodes[a].type;a--)o=a;this.nodes.splice(o,t-o+1)}else this.nodes.splice(t,1);return recalculateLineNumbers(this.nodes),n}}},{key:"deleteAll",value:function(e){for(var r=[],t=this.nodes.length-1;t>=0;t--){var n=this.nodes[t];"property"===n.type&&n.key===e&&(this.nodes.splice(t,1),r.push(n))}return r.length>0&&recalculateLineNumbers(this.nodes),r.reverse()}}]),r}(Properties);
1
+ function _array_like_to_array(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function _array_without_holes(e){if(Array.isArray(e))return _array_like_to_array(e)}function _assert_this_initialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _call_super(e,r,t){return r=_get_prototype_of(r),_possible_constructor_return(e,_is_native_reflect_construct()?Reflect.construct(r,t||[],_get_prototype_of(e).constructor):r.apply(e,t))}function _class_call_check(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _create_class(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),e}function _get_prototype_of(e){return _get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},_get_prototype_of(e)}function _inherits(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),r&&_set_prototype_of(e,r)}function _iterable_to_array(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _non_iterable_spread(){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 _possible_constructor_return(e,r){return!r||"object"!==_type_of(r)&&"function"!=typeof r?_assert_this_initialized(e):r}function _set_prototype_of(e,r){return _set_prototype_of=Object.setPrototypeOf||function(e,r){return e.__proto__=r,e},_set_prototype_of(e,r)}function _to_consumable_array(e){return _array_without_holes(e)||_iterable_to_array(e)||_unsupported_iterable_to_array(e)||_non_iterable_spread()}function _type_of(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function _unsupported_iterable_to_array(e,r){if(e){if("string"==typeof e)return _array_like_to_array(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(t):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_array_like_to_array(e,r):void 0}}function _is_native_reflect_construct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_is_native_reflect_construct=function(){return!!e})()}import{escapeKey,escapeValue}from"../escape/index.js";import{Properties}from"../parser/properties.js";var DEFAULT_SEPARATOR="=",DEFAULT_COMMENT_DELIMITER="#",REGEX_NEWLINE=/\r\n|\r|\n/,buildPropertyNode=function(e,r,t,n){var o,a=!0===t.escapeUnicode,i=escapeKey(e,a),s=escapeValue(r,a),l=" "===t.separator?void 0:null!==(o=t.separator)&&void 0!==o?o:DEFAULT_SEPARATOR,c=l?" ":"",p=l?"".concat(" ").concat(l).concat(c):" ",u="".concat(i).concat(p).concat(s).split(REGEX_NEWLINE);return{type:"property",rawLines:u,leadingWhitespace:"",key:e,escapedKey:i,separatorLeading:" ",separatorChar:l,separatorTrailing:c,value:r,escapedValue:s,startingLineNumber:n,endingLineNumber:n+u.length-1}},buildCommentNodes=function(e,r,t){return e.split(REGEX_NEWLINE).map(function(e,n){return""===e?{type:"blank",rawLine:"",lineNumber:t+n}:{type:"comment",rawLine:"".concat(r," ").concat(e),leadingWhitespace:"",delimiter:r,body:" ".concat(e),lineNumber:t+n}})},recalculateLineNumbers=function(e){for(var r=1,t=0;t<e.length;t++){var n=e[t];if("property"===n.type){var o=n.rawLines.length;e[t]={type:"property",rawLines:n.rawLines,leadingWhitespace:n.leadingWhitespace,key:n.key,escapedKey:n.escapedKey,separatorLeading:n.separatorLeading,separatorChar:n.separatorChar,separatorTrailing:n.separatorTrailing,value:n.value,escapedValue:n.escapedValue,startingLineNumber:r,endingLineNumber:r+o-1},r+=o}else"comment"===n.type?(e[t]={type:"comment",rawLine:n.rawLine,leadingWhitespace:n.leadingWhitespace,delimiter:n.delimiter,body:n.body,lineNumber:r},r++):(e[t]={type:"blank",rawLine:n.rawLine,lineNumber:r},r++)}};export var PropertiesEditor=function(e){"use strict";function r(){return _class_call_check(this,r),_call_super(this,r,arguments)}return _inherits(r,e),_create_class(r,[{key:"findFirstProperty",value:function(e){for(var r=0;r<this.nodes.length;r++){var t=this.nodes[r];if("property"===t.type&&t.key===e)return{index:r,node:t}}}},{key:"findLastProperty",value:function(e){for(var r=this.nodes.length-1;r>=0;r--){var t=this.nodes[r];if("property"===t.type&&t.key===e)return{index:r,node:t}}}},{key:"insert",value:function(e,r,t){var n,o,a=[];if(void 0!==(null==t?void 0:t.comment)){var i,s=null!==(o=t.commentDelimiter)&&void 0!==o?o:DEFAULT_COMMENT_DELIMITER;(i=a).push.apply(i,_to_consumable_array(buildCommentNodes(t.comment,s,0)))}if(a.push(buildPropertyNode(e,r,{escapeUnicode:null==t?void 0:t.escapeUnicode,separator:null==t?void 0:t.separator},0)),null==t?void 0:t.referenceKey){var l=this.findLastProperty(t.referenceKey);if(void 0!==l){var c,p="before"===t.position?l.index:l.index+1;return(c=this.nodes).splice.apply(c,[p,0].concat(_to_consumable_array(a))),void recalculateLineNumbers(this.nodes)}}(n=this.nodes).push.apply(n,_to_consumable_array(a)),recalculateLineNumbers(this.nodes)}},{key:"insertComment",value:function(e,r){var t,n,o=null!==(n=null==r?void 0:r.commentDelimiter)&&void 0!==n?n:DEFAULT_COMMENT_DELIMITER,a=buildCommentNodes(e,o,0);if(null==r?void 0:r.referenceKey){var i=this.findLastProperty(r.referenceKey);if(void 0!==i){var s,l="before"===r.position?i.index:i.index+1;return(s=this.nodes).splice.apply(s,[l,0].concat(_to_consumable_array(a))),void recalculateLineNumbers(this.nodes)}}(t=this.nodes).push.apply(t,_to_consumable_array(a)),recalculateLineNumbers(this.nodes)}},{key:"insertBlankLine",value:function(e){var r={type:"blank",rawLine:"",lineNumber:0};if(null==e?void 0:e.referenceKey){var t=this.findLastProperty(e.referenceKey);if(void 0!==t){var n="before"===e.position?t.index:t.index+1;return this.nodes.splice(n,0,r),void recalculateLineNumbers(this.nodes)}}this.nodes.push(r),recalculateLineNumbers(this.nodes)}},{key:"update",value:function(e,r){var t,n,o,a=this.findLastProperty(e);if(void 0===a)return!1;var i=a.index,s=a.node,l=null!==(t=r.newKey)&&void 0!==t?t:s.key,c=null!==(n=r.newValue)&&void 0!==n?n:s.value,p=!0===r.escapeUnicode,u=p?escapeKey(l,!0):void 0!==r.newKey?escapeKey(l):s.escapedKey,d=p?escapeValue(c,!0):void 0!==r.newValue?escapeValue(c):s.escapedValue,_=r.separator?" "===r.separator?void 0:r.separator:s.separatorChar,y=r.separator?" ":s.separatorLeading,f=r.separator?_?" ":"":s.separatorTrailing,m=_?"".concat(y).concat(_).concat(f):y,v="".concat(u).concat(m).concat(d).split(REGEX_NEWLINE),h={type:"property",rawLines:v,leadingWhitespace:s.leadingWhitespace,key:l,escapedKey:u,separatorLeading:y,separatorChar:_,separatorTrailing:f,value:c,escapedValue:d,startingLineNumber:s.startingLineNumber,endingLineNumber:s.startingLineNumber+v.length-1};if(void 0!==r.newComment){for(var b,L=i,g=i-1;g>=0&&"property"!==this.nodes[g].type;g--)L=g;var N=null!==(o=r.commentDelimiter)&&void 0!==o?o:DEFAULT_COMMENT_DELIMITER,E=buildCommentNodes(r.newComment,N,0);(b=this.nodes).splice.apply(b,[L,i-L+1].concat(_to_consumable_array(E),[h]))}else this.nodes[i]=h;return recalculateLineNumbers(this.nodes),!0}},{key:"upsert",value:function(e,r,t){void 0!==this.findLastProperty(e)?this.update(e,{newValue:r,escapeUnicode:null==t?void 0:t.escapeUnicode,separator:null==t?void 0:t.separator,newComment:null==t?void 0:t.comment,commentDelimiter:null==t?void 0:t.commentDelimiter}):this.insert(e,r,t)}},{key:"delete",value:function(e,r){var t="first"===(null==r?void 0:r.occurrence)?this.findFirstProperty(e):this.findLastProperty(e);if(void 0!==t){var n=t.index,o=t.node;if(!1!==(null==r?void 0:r.deleteLeadingNodes)){for(var a=n,i=n-1;i>=0&&"property"!==this.nodes[i].type;i--)a=i;this.nodes.splice(a,n-a+1)}else this.nodes.splice(n,1);return recalculateLineNumbers(this.nodes),o}}},{key:"deleteAll",value:function(e){for(var r=[],t=this.nodes.length-1;t>=0;t--){var n=this.nodes[t];"property"===n.type&&n.key===e&&(this.nodes.splice(t,1),r.push(n))}return r.length>0&&recalculateLineNumbers(this.nodes),r.reverse()}}]),r}(Properties);
@@ -1 +1 @@
1
- export var escapeKey=function(e){return escapeContent(e,!0,arguments.length>1&&void 0!==arguments[1]&&arguments[1])};export var escapeValue=function(e){return escapeContent(e,!1,arguments.length>1&&void 0!==arguments[1]&&arguments[1])};var REGEX_ESCAPE_NO_UNICODE=/[\s!#:=\\]/g,REGEX_ESCAPE_UNICODE=/[\s!#:=\\\u0000-\u001F\u007F-\uFFFF]/g,escapeContent=function(e,r,t){var n=t?REGEX_ESCAPE_UNICODE:REGEX_ESCAPE_NO_UNICODE;return n.lastIndex=0,e.replace(n,function(e,t){var n;switch(e){case" ":return r||0===t?"\\ ":" ";case"\\":return"\\\\";case"\f":return"\\f";case"\n":return"\\n";case"\r":return"\\r";case"\t":return"\\t";case"=":case":":case"#":case"!":return"\\".concat(e);default:return"\\u"+("0000"+(null!==(n=e.charCodeAt(0))&&void 0!==n?n:0).toString(16)).slice(-4)}})};
1
+ export var escapeKey=function(e){return escapeContent(e,!0,arguments.length>1&&void 0!==arguments[1]&&arguments[1])};export var escapeValue=function(e){return escapeContent(e,!1,arguments.length>1&&void 0!==arguments[1]&&arguments[1])};var REGEX_ESCAPE_NO_UNICODE=/[\s!#:=\\]/g,REGEX_ESCAPE_UNICODE=/[\s!#:=\\\u0000-\u001F\u007F-\uFFFF]/g,escapeContent=function(e,t,r){var n=r?REGEX_ESCAPE_UNICODE:REGEX_ESCAPE_NO_UNICODE;return n.lastIndex=0,e.replace(n,function(e,r){switch(e){case" ":return t||0===r?"\\ ":" ";case"\\":return"\\\\";case"\f":return"\\f";case"\n":return"\\n";case"\r":return"\\r";case"\t":return"\\t";case"=":case":":case"#":case"!":return"\\".concat(e);default:return"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)}})};
@@ -1,9 +1,7 @@
1
1
  /**
2
2
  * A key-value pair object.
3
3
  */
4
- export type KeyValuePairObject = {
5
- [key: string]: string;
6
- };
4
+ export type KeyValuePairObject = Record<string, string>;
7
5
  /**
8
6
  * Converts the content of a `.properties` file to a key-value pair object.
9
7
  *
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- var CH_TAB=9,CH_FF=12,CH_SPACE=32,CH_BANG=33,CH_HASH=35,CH_COLON=58,CH_EQUALS=61,CH_BACKSLASH=92,CH_LOWER_F=102,CH_LOWER_N=110,CH_LOWER_R=114,CH_LOWER_T=116,CH_LOWER_U=117,CH_BOM=65279,skipWhitespace=function(e,r,C){for(;r<C;){var a=e.charCodeAt(r);if(a!==CH_SPACE&&a!==CH_TAB&&a!==CH_FF)break;r++}return r},isHexDigit=function(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102},hexValue=function(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e-87},unescapeContent=function(e){for(var r=e.length,C="",a=0,t=0;t<r;)if(e.charCodeAt(t)===CH_BACKSLASH){switch(t>a&&(C+=e.slice(a,t)),t++,e.charCodeAt(t)){case CH_LOWER_N:C+="\n",t++;break;case CH_LOWER_T:C+="\t",t++;break;case CH_LOWER_R:C+="\r",t++;break;case CH_LOWER_F:C+="\f",t++;break;case CH_LOWER_U:if(t+4>=r||!isHexDigit(e.charCodeAt(t+1))||!isHexDigit(e.charCodeAt(t+2))||!isHexDigit(e.charCodeAt(t+3))||!isHexDigit(e.charCodeAt(t+4))){var i=e.slice(t-1,t+5);throw new Error("malformed escaped unicode characters '".concat(i,"'"))}var c=hexValue(e.charCodeAt(t+1))<<12|hexValue(e.charCodeAt(t+2))<<8|hexValue(e.charCodeAt(t+3))<<4|hexValue(e.charCodeAt(t+4));C+=String.fromCharCode(c),t+=5;break;default:C+=e.charAt(t),t++}a=t}else t++;return a<r&&(C+=e.slice(a,r)),C};export var getProperties=function(e){for(var r="string"==typeof e?e:e.toString(),C={},a=(r.length>0&&r.charCodeAt(0)===CH_BOM?r.slice(1):r).split(/\r\n|\r|\n/),t=a.length,i=0;i<t;){var c=a[i],H=c.length,_=skipWhitespace(c,0,H);if(_>=H)i++;else{var o=c.charCodeAt(_);if(o!==CH_HASH&&o!==CH_BANG){for(var s=0,A=H-1;A>=0&&c.charCodeAt(A)===CH_BACKSLASH;A--)s++;var n=s%2==1,h=void 0,l=void 0;if(n){var f=(_>0?c.slice(_):c).slice(0,-1),d=[f];for(l=-1!==f.indexOf("\\");n&&i+1<t;){var v=a[++i],u=v.length,L=skipWhitespace(v,0,u);s=0;for(var O=u-1;O>=L&&v.charCodeAt(O)===CH_BACKSLASH;O--)s++;var S=(n=s%2==1)?v.slice(L,u-1):v.slice(L);l||-1===S.indexOf("\\")||(l=!0),d.push(S)}h=d.join("")}else l=-1!==(h=_>0?c.slice(_):c).indexOf("\\");for(var p=h.length,E=0,g=!1;E<p;){var W=h.charCodeAt(E);if(W!==CH_BACKSLASH){if(!g&&(W===CH_EQUALS||W===CH_COLON||W===CH_SPACE||W===CH_TAB||W===CH_FF))break;g=!1,E++}else g=!g,E++}var x=E;if(x<p){var B=h.charCodeAt(x);B!==CH_SPACE&&B!==CH_TAB&&B!==CH_FF||(x=skipWhitespace(h,x,p))<p&&(B=h.charCodeAt(x)),x<p&&(B===CH_EQUALS||B===CH_COLON)&&(x++,x=skipWhitespace(h,x,p))}var k=h.slice(0,E),R=h.slice(x);C[l?unescapeContent(k):k]=l?unescapeContent(R):R,i++}else i++}}return C};
1
+ var _=function(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1},S=function(e){if(-1===e.indexOf("\\"))return e;for(var r=e.length,a="",c=0,t=0;t<r;)if(92===e.charCodeAt(t)){if(t>c&&(a+=e.slice(c,t)),++t>=r){a+="\\",c=t;break}switch(e.charCodeAt(t)){case 110:a+="\n",t++;break;case 116:a+="\t",t++;break;case 114:a+="\r",t++;break;case 102:a+="\f",t++;break;case 117:if(t+4>=r)throw new Error("malformed escaped unicode characters '".concat(e.slice(t-1,t+5),"'"));var o=_(e.charCodeAt(t+1)),i=_(e.charCodeAt(t+2)),n=_(e.charCodeAt(t+3)),f=_(e.charCodeAt(t+4));if(o<0||i<0||n<0||f<0)throw new Error("malformed escaped unicode characters '".concat(e.slice(t-1,t+5),"'"));a+=String.fromCharCode(o<<12|i<<8|n<<4|f),t+=5;break;default:a+=e.charAt(t),t++}c=t}else t++;return c<r&&(a+=e.slice(c,r)),a},H=function(e,r,a){for(;r<a;){var c=e.charCodeAt(r);if(32!==c&&9!==c&&12!==c)break;r++}return r},q=function(e){for(var r="string"==typeof e?e:e.toString(),a={},c=(r.length>0&&65279===r.charCodeAt(0)?r.slice(1):r).split(/\r\n|\r|\n/),t=c.length,o=0;o<t;){var i=c[o],n=i.length,f=H(i,0,n);if(f>=n)o++;else{var s=i.charCodeAt(f);if(35!==s&&33!==s){for(var d=0,h=n-1;h>=0&&92===i.charCodeAt(h);h--)d++;var l=d%2==1,v=void 0,C=void 0;if(l){var A=(f>0?i.slice(f):i).slice(0,-1),u=[A];for(C=-1!==A.indexOf("\\");l&&o+1<t;){var g=c[++o],b=g.length,k=H(g,0,b);d=0;for(var p=b-1;p>=k&&92===g.charCodeAt(p);p--)d++;var m=(l=d%2==1)?g.slice(k,b-1):g.slice(k);!C&&-1!==m.indexOf("\\")&&(C=!0),u.push(m)}v=u.join("")}else C=-1!==(v=f>0?i.slice(f):i).indexOf("\\");for(var w=v.length,x=0,_=!1;x<w;){var O=v.charCodeAt(x);if(92!==O){if(!_&&(61===O||58===O||32===O||9===O||12===O))break;_=!1,x++}else _=!_,x++}var q=x;if(q<w){var E=v.charCodeAt(q);(32===E||9===E||12===E)&&((q=H(v,q,w))<w&&(E=v.charCodeAt(q))),q<w&&(61===E||58===E)&&(q++,q=H(v,q,w))}var j=v.slice(0,x),y=v.slice(q);a[C?S(j):j]=C?S(y):y,o++}else o++}}return a};export{q as getProperties};
@@ -74,9 +74,7 @@ export type BlankLineNode = {
74
74
  /** Discriminated union of all node types in a `.properties` file. */
75
75
  export type PropertiesNode = PropertyNode | CommentNode | BlankLineNode;
76
76
  /** A plain key-value pair object where every value is a string. */
77
- export type KeyValuePairObject = {
78
- [key: string]: string;
79
- };
77
+ export type KeyValuePairObject = Record<string, string>;
80
78
  /** Information about a key that appears more than once. */
81
79
  export type KeyCollisions = {
82
80
  /** The duplicate key. */
@@ -1 +1 @@
1
- import{escapeKey,escapeValue}from"../escape/index.js";var BOM="\ufeff",wrapAtWidth=function(e,a){if(e.length<=a)return e;for(var r=[],i=0,t=e.length;i<t;){var o=Math.min(i+a,t);if(o<t)for(var n=0;n<6&&o-n>i;n++){var p=o-n;if(p+5<=t&&"\\"===e[p]&&"u"===e[p+1]){o=p;break}}r.push(e.slice(i,o)),i=o}return r.join("\\\n ")},rebuildPropertyLine=function(e,a){var r,i,t,o,n=!0===a.escapeUnicode,p=a.removeLeadingWhitespace?"":e.leadingWhitespace,s=n?escapeKey(e.key,!0):e.escapedKey;void 0!==a.separatorChar?(i=void 0!==a.separatorLeading?a.separatorLeading:e.separatorLeading,t=" "===a.separatorChar?"":a.separatorChar,o=void 0!==a.separatorTrailing?a.separatorTrailing:e.separatorTrailing," "===a.separatorChar&&(i=void 0!==a.separatorLeading?a.separatorLeading:" ")):(i=void 0!==a.separatorLeading?a.separatorLeading:e.separatorLeading,t=null!==(r=e.separatorChar)&&void 0!==r?r:"",o=void 0!==a.separatorTrailing?a.separatorTrailing:e.separatorTrailing);var d=n?escapeValue(e.value,!0):e.escapedValue;return void 0!==a.wrapKeysAt&&a.wrapKeysAt>0&&(s=wrapAtWidth(s,a.wrapKeysAt)),void 0!==a.wrapValuesAt&&a.wrapValuesAt>0&&(d=wrapAtWidth(d,a.wrapValuesAt)),"".concat(p).concat(s).concat(i).concat(t).concat(o).concat(d)};export var formatNormalized=function(e,a,r,i){var t,o,n=null!==(t=i.endOfLineCharacter)&&void 0!==t?t:r,p=void 0!==i.separatorChar||void 0!==i.separatorLeading||void 0!==i.separatorTrailing||!0===i.escapeUnicode||!0===i.collapseMultiline||void 0!==i.wrapKeysAt||void 0!==i.wrapValuesAt||!0===i.removeLeadingWhitespace;if(i.deduplicateKeys){for(var s={},d=[],c=e.length-1;c>=0;c--){var l=e[c];"property"===l.type&&(s[l.key]?d.push(c):s[l.key]=!0)}o={};var v=!0,u=!1,h=void 0;try{for(var f,y=d[Symbol.iterator]();!(v=(f=y.next()).done);v=!0){var g=f.value;if(o[g]=!0,!i.deduplicateKeysKeepLeadingNodes)for(var L=g-1;L>=0&&"property"!==e[L].type;L--)o[L]=!0}}catch(e){u=!0,h=e}finally{try{v||null==y.return||y.return()}finally{if(u)throw h}}}for(var m=[],w=0;w<e.length;w++)if(!o||!o[w]){var A=e[w];switch(A.type){case"comment":if(i.removeComments)continue;m.push(i.removeLeadingWhitespace?"".concat(A.delimiter).concat(A.body):A.rawLine);break;case"blank":if(i.removeBlankLines)continue;m.push(A.rawLine);break;case"property":p?m.push(rebuildPropertyLine(A,i)):m.push(A.rawLines.join(n))}}return(a?BOM:"")+m.join(n)};
1
+ import{escapeKey,escapeValue}from"../escape/index.js";var BOM="\ufeff",wrapAtWidth=function(e,a){if(e.length<=a)return e;for(var r=[],i=0,t=e.length;i<t;){var o=Math.min(i+a,t);if(o<t)for(var n=0;n<6&&o-n>i;n++){var p=o-n;if(p+5<=t&&"\\"===e[p]&&"u"===e[p+1]){o=p;break}}r.push(e.slice(i,o)),i=o}return r.join("\\\n ")},rebuildPropertyLine=function(e,a){var r,i,t,o,n,p,s,l,c,d=!0===a.escapeUnicode,u=a.removeLeadingWhitespace?"":e.leadingWhitespace,v=d?escapeKey(e.key,!0):e.escapedKey;void 0!==a.separatorChar?(s=null!==(r=a.separatorLeading)&&void 0!==r?r:e.separatorLeading,l=" "===a.separatorChar?"":a.separatorChar,c=null!==(i=a.separatorTrailing)&&void 0!==i?i:e.separatorTrailing," "===a.separatorChar&&(s=null!==(t=a.separatorLeading)&&void 0!==t?t:" ")):(s=null!==(o=a.separatorLeading)&&void 0!==o?o:e.separatorLeading,l=null!==(n=e.separatorChar)&&void 0!==n?n:"",c=null!==(p=a.separatorTrailing)&&void 0!==p?p:e.separatorTrailing);var h=d?escapeValue(e.value,!0):e.escapedValue;return void 0!==a.wrapKeysAt&&a.wrapKeysAt>0&&(v=wrapAtWidth(v,a.wrapKeysAt)),void 0!==a.wrapValuesAt&&a.wrapValuesAt>0&&(h=wrapAtWidth(h,a.wrapValuesAt)),"".concat(u).concat(v).concat(s).concat(l).concat(c).concat(h)};export var formatNormalized=function(e,a,r,i){var t,o,n=null!==(t=i.endOfLineCharacter)&&void 0!==t?t:r,p=void 0!==i.separatorChar||void 0!==i.separatorLeading||void 0!==i.separatorTrailing||!0===i.escapeUnicode||!0===i.collapseMultiline||void 0!==i.wrapKeysAt||void 0!==i.wrapValuesAt||!0===i.removeLeadingWhitespace;if(i.deduplicateKeys){for(var s={},l=[],c=e.length-1;c>=0;c--){var d=e[c];"property"===d.type&&(s[d.key]?l.push(c):s[d.key]=!0)}o={};var u=!0,v=!1,h=void 0;try{for(var f,y=l[Symbol.iterator]();!(u=(f=y.next()).done);u=!0){var g=f.value;if(o[g]=!0,!i.deduplicateKeysKeepLeadingNodes)for(var L=g-1;L>=0&&"property"!==e[L].type;L--)o[L]=!0}}catch(e){v=!0,h=e}finally{try{u||null==y.return||y.return()}finally{if(v)throw h}}}for(var m=[],w=0;w<e.length;w++)if(!(null==o?void 0:o[w])){var A=e[w];switch(A.type){case"comment":if(i.removeComments)continue;m.push(i.removeLeadingWhitespace?"".concat(A.delimiter).concat(A.body):A.rawLine);break;case"blank":if(i.removeBlankLines)continue;m.push(A.rawLine);break;case"property":p?m.push(rebuildPropertyLine(A,i)):m.push(A.rawLines.join(n))}}return(a?BOM:"")+m.join(n)};
@@ -1 +1 @@
1
- import{unescapeContent}from"../unescape/index.js";var CH_TAB=9,CH_LF=10,CH_FF=12,CH_CR=13,CH_SPACE=32,CH_BANG=33,CH_HASH=35,CH_COLON=58,CH_EQUALS=61,CH_BACKSLASH=92,CH_BOM=65279,isWhitespace=function(e){return e===CH_SPACE||e===CH_TAB||e===CH_FF},countTrailingBackslashes=function(e,r){for(var a=0,i=r-1;i>=0&&e.charCodeAt(i)===CH_BACKSLASH;)a++,i--;return a};export var parseDocument=function(e){var r="string"==typeof e?e:e.toString(),a=r.length,i=0,s=a>0&&r.charCodeAt(0)===CH_BOM;s&&(i=1);for(var n="\n",t=i;t<a;t++){var C=r.charCodeAt(t);if(C===CH_CR){n=t+1<a&&r.charCodeAt(t+1)===CH_LF?"\r\n":"\r";break}if(C===CH_LF){n="\n";break}}for(var c=(i>0?r.slice(i):r).split(/\r\n|\r|\n/),o=[],l=0,h=c.length;l<h;){for(var H=c[l],p=l+1,v=0,A=H.length;v<A&&isWhitespace(H.charCodeAt(v));)v++;if(v>=A){var f={type:"blank",rawLine:H,lineNumber:p};o.push(f),l++}else{var _=H.charCodeAt(v);if(_!==CH_HASH&&_!==CH_BANG){for(var d=[H],u=p,g=v>0?H.slice(0,v):"",L=countTrailingBackslashes(H,A),S=L%2==1;S&&l+1<h;){var B=c[++l];d.push(B);var m=B.length;S=(L=countTrailingBackslashes(B,m))%2==1}var O=l+1,b=S,N=void 0;if(1===d.length){var k=v>0?H.slice(v):H;N=b?k.slice(0,-1):k}else{for(var y=[],W=0;W<d.length;W++){var F=d[W],E=void 0,T=void 0;if(0===W)E=v,T=F.length-1;else{E=0;for(var x=F.length;E<x&&isWhitespace(F.charCodeAt(E));)E++;T=W===d.length-1&&!b?x:x-1}y.push(F.slice(E,T))}N=y.join("")}for(var K=N.length,Q=0,U=!1;Q<K;){var w=N.charCodeAt(Q);if(w!==CH_BACKSLASH){if(!U&&(w===CH_EQUALS||w===CH_COLON||isWhitespace(w)))break;U=!1,Q++}else U=!U,Q++}var j=N.slice(0,Q),G="",M=void 0,P="",R=Q;if(R<K){for(var D=R;R<K&&isWhitespace(N.charCodeAt(R));)R++;if(R<K){var V=N.charCodeAt(R);if(V===CH_EQUALS||V===CH_COLON){G=N.slice(D,R),M=V===CH_EQUALS?"=":":";for(var q=++R;R<K&&isWhitespace(N.charCodeAt(R));)R++;P=N.slice(q,R)}else G=N.slice(D,R)}else G=N.slice(D,R)}var z=N.slice(R),I={type:"property",rawLines:d,leadingWhitespace:g,key:-1!==j.indexOf("\\")?unescapeContent(j):j,escapedKey:j,separatorLeading:G,separatorChar:M,separatorTrailing:P,value:-1!==z.indexOf("\\")?unescapeContent(z):z,escapedValue:z,startingLineNumber:u,endingLineNumber:O};o.push(I),l++}else{var J={type:"comment",rawLine:H,leadingWhitespace:v>0?H.slice(0,v):"",delimiter:_===CH_HASH?"#":"!",body:H.slice(v+1),lineNumber:p};o.push(J),l++}}}return{hasBom:s,eolCharacter:n,nodes:o}};
1
+ import{CH_BACKSLASH,CH_BANG,CH_BOM,CH_COLON,CH_CR,CH_EQUALS,CH_FF,CH_HASH,CH_LF,CH_SPACE,CH_TAB}from"../characters.js";import{unescapeContent}from"../unescape/index.js";var isWhitespace=function(e){return e===CH_SPACE||e===CH_TAB||e===CH_FF},countTrailingBackslashes=function(e,r){for(var a=0,i=r-1;i>=0&&e.charCodeAt(i)===CH_BACKSLASH;)a++,i--;return a};export var parseDocument=function(e){var r="string"==typeof e?e:e.toString(),a=r.length,i=0,s=a>0&&r.charCodeAt(0)===CH_BOM;s&&(i=1);for(var t="\n",n=i;n<a;n++){var C=r.charCodeAt(n);if(C===CH_CR){t=n+1<a&&r.charCodeAt(n+1)===CH_LF?"\r\n":"\r";break}if(C===CH_LF){t="\n";break}}for(var c=(i>0?r.slice(i):r).split(/\r\n|\r|\n/),o=[],l=0,h=c.length;l<h;){for(var H=c[l],p=l+1,v=0,A=H.length;v<A&&isWhitespace(H.charCodeAt(v));)v++;if(v>=A){var f={type:"blank",rawLine:H,lineNumber:p};o.push(f),l++}else{var _=H.charCodeAt(v);if(_!==CH_HASH&&_!==CH_BANG){for(var d=[H],u=p,g=v>0?H.slice(0,v):"",L=countTrailingBackslashes(H,A),S=L%2==1;S&&l+1<h;){var m=c[++l];d.push(m);var B=m.length;S=(L=countTrailingBackslashes(m,B))%2==1}var O=l+1,b=S,N=void 0;if(1===d.length){var k=v>0?H.slice(v):H;N=b?k.slice(0,-1):k}else{for(var y=[],W=0;W<d.length;W++){var F=d[W],E=void 0,T=void 0;if(0===W)E=v,T=F.length-1;else{E=0;for(var x=F.length;E<x&&isWhitespace(F.charCodeAt(E));)E++;T=W===d.length-1&&!b?x:x-1}y.push(F.slice(E,T))}N=y.join("")}for(var K=N.length,Q=0,U=!1;Q<K;){var j=N.charCodeAt(Q);if(j!==CH_BACKSLASH){if(!U&&(j===CH_EQUALS||j===CH_COLON||isWhitespace(j)))break;U=!1,Q++}else U=!U,Q++}var w=N.slice(0,Q),G="",M=void 0,P="",R=Q;if(R<K){for(var D=R;R<K&&isWhitespace(N.charCodeAt(R));)R++;if(R<K){var V=N.charCodeAt(R);if(V===CH_EQUALS||V===CH_COLON){G=N.slice(D,R),M=V===CH_EQUALS?"=":":";for(var q=++R;R<K&&isWhitespace(N.charCodeAt(R));)R++;P=N.slice(q,R)}else G=N.slice(D,R)}else G=N.slice(D,R)}var z=N.slice(R),I={type:"property",rawLines:d,leadingWhitespace:g,key:-1!==w.indexOf("\\")?unescapeContent(w):w,escapedKey:w,separatorLeading:G,separatorChar:M,separatorTrailing:P,value:-1!==z.indexOf("\\")?unescapeContent(z):z,escapedValue:z,startingLineNumber:u,endingLineNumber:O};o.push(I),l++}else{var J={type:"comment",rawLine:H,leadingWhitespace:v>0?H.slice(0,v):"",delimiter:_===CH_HASH?"#":"!",body:H.slice(v+1),lineNumber:p};o.push(J),l++}}}return{hasBom:s,eolCharacter:t,nodes:o}};
@@ -1 +1 @@
1
- function _class_call_check(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _create_class(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),e}import{formatNormalized as formatNormalizedImpl}from"./normalize.js";import{parseDocument}from"./parse.js";var BOM="\ufeff";export var Properties=function(){"use strict";function e(r){_class_call_check(this,e);var t=parseDocument(r);this.hasBom=t.hasBom,this.eolCharacter=t.eolCharacter,this.nodes=t.nodes}return _create_class(e,[{key:"getProperties",value:function(){return this.nodes.filter(function(e){return"property"===e.type})}},{key:"getComments",value:function(){return this.nodes.filter(function(e){return"comment"===e.type})}},{key:"getBlankLines",value:function(){return this.nodes.filter(function(e){return"blank"===e.type})}},{key:"toObject",value:function(){var e={},r=!0,t=!1,n=void 0;try{for(var o,a=this.nodes[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var i=o.value;"property"===i.type&&(e[i.key]=i.value)}}catch(e){t=!0,n=e}finally{try{r||null==a.return||a.return()}finally{if(t)throw n}}return e}},{key:"getPropertyNodes",value:function(e){return this.nodes.filter(function(r){return"property"===r.type&&r.key===e})}},{key:"getEffectiveProperty",value:function(e){for(var r=this.nodes.length-1;r>=0;r--){var t=this.nodes[r];if("property"===t.type&&t.key===e)return t}}},{key:"getKeyCollisions",value:function(){var e={},r=!0,t=!1,n=void 0;try{for(var o,a=this.nodes[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var i=o.value;"property"===i.type&&(e[i.key]||(e[i.key]=[]),e[i.key].push(i))}}catch(e){t=!0,n=e}finally{try{r||null==a.return||a.return()}finally{if(t)throw n}}var l=[],s=!0,u=!1,f=void 0;try{for(var y,c=Object.keys(e)[Symbol.iterator]();!(s=(y=c.next()).done);s=!0){var h=y.value;e[h].length>1&&l.push({key:h,nodes:e[h]})}}catch(e){u=!0,f=e}finally{try{s||null==c.return||c.return()}finally{if(u)throw f}}return l}},{key:"getLeadingNodes",value:function(e){for(var r=-1,t=this.nodes.length-1;t>=0;t--){var n=this.nodes[t];if("property"===n.type&&n.key===e){r=t;break}}if(r<=0)return[];for(var o=[],a=r-1;a>=0;a--){var i=this.nodes[a];if("property"===i.type)break;o.unshift(i)}return o}},{key:"format",value:function(e){if(!e){var r=this.eolCharacter,t=[],n=!0,o=!1,a=void 0;try{for(var i,l=this.nodes[Symbol.iterator]();!(n=(i=l.next()).done);n=!0){var s=i.value;"property"===s.type?t.push(s.rawLines.join(r)):t.push(s.rawLine)}}catch(e){o=!0,a=e}finally{try{n||null==l.return||l.return()}finally{if(o)throw a}}return(this.hasBom?BOM:"")+t.join(r)}return formatNormalizedImpl(this.nodes,this.hasBom,this.eolCharacter,e)}}]),e}();
1
+ function _class_call_check(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _create_class(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),e}import{formatNormalized as formatNormalizedImpl}from"./normalize.js";import{parseDocument}from"./parse.js";var BOM="\ufeff";export var Properties=function(){"use strict";function e(r){_class_call_check(this,e);var t=parseDocument(r);this.hasBom=t.hasBom,this.eolCharacter=t.eolCharacter,this.nodes=t.nodes}return _create_class(e,[{key:"getProperties",value:function(){return this.nodes.filter(function(e){return"property"===e.type})}},{key:"getComments",value:function(){return this.nodes.filter(function(e){return"comment"===e.type})}},{key:"getBlankLines",value:function(){return this.nodes.filter(function(e){return"blank"===e.type})}},{key:"toObject",value:function(){var e={},r=!0,t=!1,n=void 0;try{for(var o,a=this.nodes[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var i=o.value;"property"===i.type&&(e[i.key]=i.value)}}catch(e){t=!0,n=e}finally{try{r||null==a.return||a.return()}finally{if(t)throw n}}return e}},{key:"getPropertyNodes",value:function(e){return this.nodes.filter(function(r){return"property"===r.type&&r.key===e})}},{key:"getEffectiveProperty",value:function(e){for(var r=this.nodes.length-1;r>=0;r--){var t=this.nodes[r];if("property"===t.type&&t.key===e)return t}}},{key:"getKeyCollisions",value:function(){var e={},r=!0,t=!1,n=void 0;try{for(var o,a=this.nodes[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var i=o.value;if("property"===i.type){var l=e[i.key];void 0===l?e[i.key]=[i]:l.push(i)}}}catch(e){t=!0,n=e}finally{try{r||null==a.return||a.return()}finally{if(t)throw n}}var s=[],u=!0,f=!1,y=void 0;try{for(var c,h=Object.keys(e)[Symbol.iterator]();!(u=(c=h.next()).done);u=!0){var p=c.value,v=e[p];void 0!==v&&v.length>1&&s.push({key:p,nodes:v})}}catch(e){f=!0,y=e}finally{try{u||null==h.return||h.return()}finally{if(f)throw y}}return s}},{key:"getLeadingNodes",value:function(e){for(var r=-1,t=this.nodes.length-1;t>=0;t--){var n=this.nodes[t];if("property"===n.type&&n.key===e){r=t;break}}if(r<=0)return[];for(var o=[],a=r-1;a>=0;a--){var i=this.nodes[a];if("property"===i.type)break;o.unshift(i)}return o}},{key:"format",value:function(e){if(!e){var r=this.eolCharacter,t=[],n=!0,o=!1,a=void 0;try{for(var i,l=this.nodes[Symbol.iterator]();!(n=(i=l.next()).done);n=!0){var s=i.value;"property"===s.type?t.push(s.rawLines.join(r)):t.push(s.rawLine)}}catch(e){o=!0,a=e}finally{try{n||null==l.return||l.return()}finally{if(o)throw a}}return(this.hasBom?BOM:"")+t.join(r)}return formatNormalizedImpl(this.nodes,this.hasBom,this.eolCharacter,e)}}]),e}();
@@ -1 +1 @@
1
- var CH_BACKSLASH=92,CH_LOWER_F=102,CH_LOWER_N=110,CH_LOWER_R=114,CH_LOWER_T=116,CH_LOWER_U=117,isHexDigit=function(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102},hexValue=function(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e-87};export var unescapeContent=function(e){if(-1===e.indexOf("\\"))return e;for(var r=e.length,a="",t=0,c=0;c<r;)if(e.charCodeAt(c)===CH_BACKSLASH){if(c>t&&(a+=e.slice(t,c)),++c>=r){a+="\\",t=c;break}switch(e.charCodeAt(c)){case CH_LOWER_N:a+="\n",c++;break;case CH_LOWER_T:a+="\t",c++;break;case CH_LOWER_R:a+="\r",c++;break;case CH_LOWER_F:a+="\f",c++;break;case CH_LOWER_U:if(c+4>=r||!isHexDigit(e.charCodeAt(c+1))||!isHexDigit(e.charCodeAt(c+2))||!isHexDigit(e.charCodeAt(c+3))||!isHexDigit(e.charCodeAt(c+4))){var i=e.slice(c-1,c+5);throw new Error("malformed escaped unicode characters '".concat(i,"'"))}var C=hexValue(e.charCodeAt(c+1))<<12|hexValue(e.charCodeAt(c+2))<<8|hexValue(e.charCodeAt(c+3))<<4|hexValue(e.charCodeAt(c+4));a+=String.fromCharCode(C),c+=5;break;default:a+=e.charAt(c),c++}t=c}else c++;return t<r&&(a+=e.slice(t,r)),a};
1
+ import{CH_BACKSLASH,CH_LOWER_F,CH_LOWER_N,CH_LOWER_R,CH_LOWER_T,CH_LOWER_U}from"../characters.js";var hexValue=function(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1};export var unescapeContent=function(e){if(-1===e.indexOf("\\"))return e;for(var r=e.length,a="",c=0,t=0;t<r;)if(e.charCodeAt(t)===CH_BACKSLASH){if(t>c&&(a+=e.slice(c,t)),++t>=r){a+="\\",c=t;break}switch(e.charCodeAt(t)){case CH_LOWER_N:a+="\n",t++;break;case CH_LOWER_T:a+="\t",t++;break;case CH_LOWER_R:a+="\r",t++;break;case CH_LOWER_F:a+="\f",t++;break;case CH_LOWER_U:if(t+4>=r)throw new Error("malformed escaped unicode characters '".concat(e.slice(t-1,t+5),"'"));var o=hexValue(e.charCodeAt(t+1)),C=hexValue(e.charCodeAt(t+2)),_=hexValue(e.charCodeAt(t+3)),h=hexValue(e.charCodeAt(t+4));if(o<0||C<0||_<0||h<0)throw new Error("malformed escaped unicode characters '".concat(e.slice(t-1,t+5),"'"));a+=String.fromCharCode(o<<12|C<<8|_<<4|h),t+=5;break;default:a+=e.charAt(t),t++}c=t}else t++;return c<r&&(a+=e.slice(c,r)),a};
package/package.json CHANGED
@@ -1,184 +1,185 @@
1
- {
2
- "name": "properties-file",
3
- "version": "5.0.3",
4
- "description": ".properties file parser, editor, formatter and bundler integrations.",
5
- "keywords": [
6
- ".properties",
7
- "properties",
8
- ".properties file",
9
- "properties file",
10
- "parser",
11
- "editor",
12
- "formatter",
13
- "Java",
14
- "intl",
15
- "i18n",
16
- "Webpack loader",
17
- "Rollup plugin",
18
- "Vite plugin",
19
- "esbuild plugin",
20
- "Bun plugin",
21
- "internationalization"
22
- ],
23
- "repository": {
24
- "type": "git",
25
- "url": "git+https://github.com/properties-file/properties-file.git"
26
- },
27
- "license": "MIT",
28
- "author": "properties-file",
29
- "sideEffects": false,
30
- "type": "module",
31
- "exports": {
32
- ".": {
33
- "import": {
34
- "types": "./dist/esm/index.d.ts",
35
- "default": "./dist/esm/index.js"
36
- },
37
- "require": {
38
- "types": "./dist/cjs/index.d.ts",
39
- "default": "./dist/cjs/index.js"
40
- }
41
- },
42
- "./bundler/bun": {
43
- "import": {
44
- "types": "./dist/esm/bundler/bun.d.ts",
45
- "default": "./dist/esm/bundler/bun.js"
46
- },
47
- "require": {
48
- "types": "./dist/cjs/bundler/bun.d.ts",
49
- "default": "./dist/cjs/bundler/bun.js"
50
- }
51
- },
52
- "./bundler/esbuild": {
53
- "import": {
54
- "types": "./dist/esm/bundler/esbuild.d.ts",
55
- "default": "./dist/esm/bundler/esbuild.js"
56
- },
57
- "require": {
58
- "types": "./dist/cjs/bundler/esbuild.d.ts",
59
- "default": "./dist/cjs/bundler/esbuild.js"
60
- }
61
- },
62
- "./bundler/rollup": {
63
- "import": {
64
- "types": "./dist/esm/bundler/rollup.d.ts",
65
- "default": "./dist/esm/bundler/rollup.js"
66
- },
67
- "require": {
68
- "types": "./dist/cjs/bundler/rollup.d.ts",
69
- "default": "./dist/cjs/bundler/rollup.js"
70
- }
71
- },
72
- "./bundler/webpack": {
73
- "import": {
74
- "types": "./dist/esm/bundler/webpack.d.ts",
75
- "default": "./dist/esm/bundler/webpack.js"
76
- },
77
- "require": {
78
- "types": "./dist/cjs/bundler/webpack.d.ts",
79
- "default": "./dist/cjs/bundler/webpack.js"
80
- }
81
- },
82
- "./editor": {
83
- "import": {
84
- "types": "./dist/esm/editor/index.d.ts",
85
- "default": "./dist/esm/editor/index.js"
86
- },
87
- "require": {
88
- "types": "./dist/cjs/editor/index.d.ts",
89
- "default": "./dist/cjs/editor/index.js"
90
- }
91
- },
92
- "./escape": {
93
- "import": {
94
- "types": "./dist/esm/escape/index.d.ts",
95
- "default": "./dist/esm/escape/index.js"
96
- },
97
- "require": {
98
- "types": "./dist/cjs/escape/index.d.ts",
99
- "default": "./dist/cjs/escape/index.js"
100
- }
101
- },
102
- "./parser": {
103
- "import": {
104
- "types": "./dist/esm/parser/index.d.ts",
105
- "default": "./dist/esm/parser/index.js"
106
- },
107
- "require": {
108
- "types": "./dist/cjs/parser/index.d.ts",
109
- "default": "./dist/cjs/parser/index.js"
110
- }
111
- },
112
- "./unescape": {
113
- "import": {
114
- "types": "./dist/esm/unescape/index.d.ts",
115
- "default": "./dist/esm/unescape/index.js"
116
- },
117
- "require": {
118
- "types": "./dist/cjs/unescape/index.d.ts",
119
- "default": "./dist/cjs/unescape/index.js"
120
- }
121
- }
122
- },
123
- "main": "dist/cjs/index.js",
124
- "module": "dist/esm/index.js",
125
- "types": "dist/esm/index.d.ts",
126
- "files": [
127
- "dist"
128
- ],
129
- "scripts": {
130
- "benchmark": "npx tsx performance/benchmarks/compare.ts",
131
- "build": "npm run check-nvm-node-version && npm run prettier-write && npm run eslint-fix && rm -Rf ./dist && tsc && npx tsx src/build-scripts/build.ts && npm run test && npm run size",
132
- "check-nvm-node-version": "check-node-version --node $(node -p \"'>='+require('fs').readFileSync('.nvmrc','utf-8').trim()\")",
133
- "depcheck": "depcheck",
134
- "eslint-fix": "eslint --fix",
135
- "ncu": "npm-check-updates",
136
- "ncu-update": "npm-check-updates -u",
137
- "performance-clean": "rm -rf performance/published-packages/.cache performance/benchmarks/.results performance/size/.results",
138
- "prepare": "husky",
139
- "prettier-write": "prettier --write .",
140
- "release": "dotenv -- release-it --only-version",
141
- "size": "npx tsx performance/size/compare.ts",
142
- "snapshot": "npx tsx performance/snapshots/manage.ts",
143
- "test": "jest --coverage",
144
- "test-node-compat": "docker build --platform linux/amd64 -f tests/node-compat/Dockerfile ."
145
- },
146
- "devDependencies": {
147
- "@release-it/conventional-changelog": "10.0.6",
148
- "@swc/core": "1.15.24",
149
- "@types/bun": "1.3.12",
150
- "@types/jest": "30.0.0",
151
- "@types/node": "25.6.0",
152
- "check-node-version": "4.2.1",
153
- "depcheck": "1.4.7",
154
- "dotenv-cli": "11.0.0",
155
- "esbuild": "0.28.0",
156
- "eslint": "10.2.0",
157
- "eslint-config-prettier": "10.1.8",
158
- "eslint-import-resolver-typescript": "4.4.4",
159
- "eslint-plugin-es-x": "9.6.0",
160
- "eslint-plugin-import-x": "4.16.2",
161
- "eslint-plugin-jest": "29.15.2",
162
- "eslint-plugin-package-json": "0.91.1",
163
- "eslint-plugin-prefer-arrow-functions": "3.9.1",
164
- "eslint-plugin-prettier": "5.5.5",
165
- "eslint-plugin-tsdoc": "0.5.2",
166
- "eslint-plugin-unicorn": "64.0.0",
167
- "husky": "9.1.7",
168
- "jest": "30.3.0",
169
- "jiti": "2.6.1",
170
- "jsonc-eslint-parser": "3.1.0",
171
- "npm-check-updates": "20.0.1",
172
- "prettier": "3.8.2",
173
- "release-it": "20.0.0-1",
174
- "rollup": "4.60.1",
175
- "terser": "5.46.1",
176
- "tinybench": "6.0.0",
177
- "ts-jest": "29.4.9",
178
- "typescript": "6.0.2",
179
- "typescript-eslint": "8.58.1"
180
- },
181
- "engines": {
182
- "node": "*"
183
- }
184
- }
1
+ {
2
+ "name": "properties-file",
3
+ "version": "5.0.5",
4
+ "description": ".properties file parser, editor, formatter and bundler integrations.",
5
+ "keywords": [
6
+ ".properties",
7
+ "properties",
8
+ ".properties file",
9
+ "properties file",
10
+ "parser",
11
+ "editor",
12
+ "formatter",
13
+ "Java",
14
+ "intl",
15
+ "i18n",
16
+ "Webpack loader",
17
+ "Rollup plugin",
18
+ "Vite plugin",
19
+ "esbuild plugin",
20
+ "Bun plugin",
21
+ "internationalization"
22
+ ],
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/properties-file/properties-file.git"
26
+ },
27
+ "license": "MIT",
28
+ "author": "properties-file",
29
+ "sideEffects": false,
30
+ "type": "module",
31
+ "exports": {
32
+ ".": {
33
+ "import": {
34
+ "types": "./dist/esm/index.d.ts",
35
+ "default": "./dist/esm/index.js"
36
+ },
37
+ "require": {
38
+ "types": "./dist/cjs/index.d.ts",
39
+ "default": "./dist/cjs/index.js"
40
+ }
41
+ },
42
+ "./bundler/bun": {
43
+ "import": {
44
+ "types": "./dist/esm/bundler/bun.d.ts",
45
+ "default": "./dist/esm/bundler/bun.js"
46
+ },
47
+ "require": {
48
+ "types": "./dist/cjs/bundler/bun.d.ts",
49
+ "default": "./dist/cjs/bundler/bun.js"
50
+ }
51
+ },
52
+ "./bundler/esbuild": {
53
+ "import": {
54
+ "types": "./dist/esm/bundler/esbuild.d.ts",
55
+ "default": "./dist/esm/bundler/esbuild.js"
56
+ },
57
+ "require": {
58
+ "types": "./dist/cjs/bundler/esbuild.d.ts",
59
+ "default": "./dist/cjs/bundler/esbuild.js"
60
+ }
61
+ },
62
+ "./bundler/rollup": {
63
+ "import": {
64
+ "types": "./dist/esm/bundler/rollup.d.ts",
65
+ "default": "./dist/esm/bundler/rollup.js"
66
+ },
67
+ "require": {
68
+ "types": "./dist/cjs/bundler/rollup.d.ts",
69
+ "default": "./dist/cjs/bundler/rollup.js"
70
+ }
71
+ },
72
+ "./bundler/webpack": {
73
+ "import": {
74
+ "types": "./dist/esm/bundler/webpack.d.ts",
75
+ "default": "./dist/esm/bundler/webpack.js"
76
+ },
77
+ "require": {
78
+ "types": "./dist/cjs/bundler/webpack.d.ts",
79
+ "default": "./dist/cjs/bundler/webpack.js"
80
+ }
81
+ },
82
+ "./editor": {
83
+ "import": {
84
+ "types": "./dist/esm/editor/index.d.ts",
85
+ "default": "./dist/esm/editor/index.js"
86
+ },
87
+ "require": {
88
+ "types": "./dist/cjs/editor/index.d.ts",
89
+ "default": "./dist/cjs/editor/index.js"
90
+ }
91
+ },
92
+ "./escape": {
93
+ "import": {
94
+ "types": "./dist/esm/escape/index.d.ts",
95
+ "default": "./dist/esm/escape/index.js"
96
+ },
97
+ "require": {
98
+ "types": "./dist/cjs/escape/index.d.ts",
99
+ "default": "./dist/cjs/escape/index.js"
100
+ }
101
+ },
102
+ "./parser": {
103
+ "import": {
104
+ "types": "./dist/esm/parser/index.d.ts",
105
+ "default": "./dist/esm/parser/index.js"
106
+ },
107
+ "require": {
108
+ "types": "./dist/cjs/parser/index.d.ts",
109
+ "default": "./dist/cjs/parser/index.js"
110
+ }
111
+ },
112
+ "./unescape": {
113
+ "import": {
114
+ "types": "./dist/esm/unescape/index.d.ts",
115
+ "default": "./dist/esm/unescape/index.js"
116
+ },
117
+ "require": {
118
+ "types": "./dist/cjs/unescape/index.d.ts",
119
+ "default": "./dist/cjs/unescape/index.js"
120
+ }
121
+ }
122
+ },
123
+ "main": "dist/cjs/index.js",
124
+ "module": "dist/esm/index.js",
125
+ "types": "dist/esm/index.d.ts",
126
+ "files": [
127
+ "dist"
128
+ ],
129
+ "scripts": {
130
+ "benchmark": "npx tsx performance/benchmarks/compare.ts",
131
+ "build": "npm run check-nvm-node-version && npm run prettier-write && npm run eslint-fix && npm run typecheck && rm -Rf ./dist && tsc && npx tsx src/build-scripts/build.ts && npm run test && npm run size",
132
+ "check-nvm-node-version": "check-node-version --node $(node -p \"'>='+require('fs').readFileSync('.nvmrc','utf-8').trim()\")",
133
+ "depcheck": "depcheck",
134
+ "eslint-fix": "eslint --fix",
135
+ "ncu": "npm-check-updates",
136
+ "ncu-update": "npm-check-updates -u",
137
+ "performance-clean": "rm -rf performance/published-packages/.cache performance/benchmarks/.results performance/size/.results",
138
+ "prepare": "husky",
139
+ "prettier-write": "prettier --write .",
140
+ "release": "dotenv -- release-it --only-version",
141
+ "size": "npx tsx performance/size/compare.ts",
142
+ "snapshot": "npx tsx performance/snapshots/manage.ts",
143
+ "test": "jest --coverage",
144
+ "test-node-compat": "docker build --platform linux/amd64 -f tests/node-compat/Dockerfile.node-0.4 .",
145
+ "typecheck": "find . -name tsconfig.json -not -path '*/node_modules/*' -not -path '*/dist/*' -not -path '*/.*/*' -print0 | xargs -0 -n1 -I{} npx tsc --noEmit -p {}"
146
+ },
147
+ "devDependencies": {
148
+ "@release-it/conventional-changelog": "11.0.0",
149
+ "@swc/core": "1.15.33",
150
+ "@types/bun": "1.3.14",
151
+ "@types/jest": "30.0.0",
152
+ "@types/node": "25.9.0",
153
+ "check-node-version": "4.2.1",
154
+ "depcheck": "1.4.7",
155
+ "dotenv-cli": "11.0.0",
156
+ "esbuild": "0.28.0",
157
+ "eslint": "10.4.0",
158
+ "eslint-config-prettier": "10.1.8",
159
+ "eslint-import-resolver-typescript": "4.4.4",
160
+ "eslint-plugin-es-x": "9.6.0",
161
+ "eslint-plugin-import-x": "4.16.2",
162
+ "eslint-plugin-jest": "29.15.2",
163
+ "eslint-plugin-package-json": "1.0.0",
164
+ "eslint-plugin-prefer-arrow-functions": "3.9.1",
165
+ "eslint-plugin-prettier": "5.5.5",
166
+ "eslint-plugin-tsdoc": "0.5.2",
167
+ "eslint-plugin-unicorn": "64.0.0",
168
+ "husky": "9.1.7",
169
+ "jest": "30.4.2",
170
+ "jiti": "2.7.0",
171
+ "jsonc-eslint-parser": "3.1.0",
172
+ "npm-check-updates": "22.2.0",
173
+ "prettier": "3.8.3",
174
+ "release-it": "20.0.1",
175
+ "rollup": "4.60.4",
176
+ "terser": "5.47.1",
177
+ "tinybench": "6.0.2",
178
+ "ts-jest": "29.4.9",
179
+ "typescript": "6.0.3",
180
+ "typescript-eslint": "8.59.4"
181
+ },
182
+ "engines": {
183
+ "node": ">=0.4.0"
184
+ }
185
+ }