properties-file 3.2.0 → 3.2.2

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
@@ -10,7 +10,7 @@
10
10
 
11
11
  ## Installation 💻
12
12
 
13
- > ⚠ In April 2023, we released version 3 of this package, which includes breaking changes. Please refer to the [migration guide](./V2-TO-V3-MIGRATION-GUIDE.md) before upgrading.
13
+ > ⚠ In April 2023, we released version 3 of this package, which includes breaking changes. Please refer to the [upgrade guide](./V2-TO-V3-UPGRADE-GUIDE.md) before upgrading.
14
14
 
15
15
  Add the package as a dependency:
16
16
 
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PropertiesEditor=exports.DEFAULT_SEPARATOR=exports.DEFAULT_COMMENT_DELIMITER=void 0,require("core-js/modules/es.string.replace.js"),require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/esnext.string.replace-all.js");var _escape=require("../escape"),_properties=require("../properties");/** The default separator between keys and values. */const DEFAULT_SEPARATOR="=";/** The default character used as comment delimiter. */exports.DEFAULT_SEPARATOR="=";const DEFAULT_COMMENT_DELIMITER="#";/** Characters that can be used as key-value pair separators. */ /** Characters that can be used as comment delimiters. */ /** Options on the `Properties.insert` method. */ /** Options on the `Properties.insertComment` method. */ /** Options on the `Properties.update` method. */ /** Options on the `Properties.upsert` method. */exports.DEFAULT_COMMENT_DELIMITER="#";/**
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PropertiesEditor=exports.DEFAULT_SEPARATOR=exports.DEFAULT_COMMENT_DELIMITER=void 0;var _escape=require("../escape"),_properties=require("../properties");/** The default separator between keys and values. */const DEFAULT_SEPARATOR="=";/** The default character used as comment delimiter. */exports.DEFAULT_SEPARATOR="=";const DEFAULT_COMMENT_DELIMITER="#";/** Characters that can be used as key-value pair separators. */ /** Characters that can be used as comment delimiters. */ /** Options on the `Properties.insert` method. */ /** Options on the `Properties.insertComment` method. */ /** Options on the `Properties.update` method. */ /** Options on the `Properties.upsert` method. */exports.DEFAULT_COMMENT_DELIMITER="#";/**
2
2
  * A .properties file editor.
3
3
  */class PropertiesEditor extends _properties.Properties{/**
4
4
  * Create `PropertiesEditor` object.
@@ -24,7 +24,7 @@ if(a){var m,n;const b="after"===g?a.endingLineNumber:null!==(m=null===(n=a.previ
24
24
  * @param options - Additional options.
25
25
  *
26
26
  * @returns True if the comment was inserted, otherwise false.
27
- */insertComment(a,b){const c=null===b||void 0===b?void 0:b.referenceKey,d=(null===b||void 0===b?void 0:b.position)||"after",e="".concat((null===b||void 0===b?void 0:b.commentDelimiter)||DEFAULT_COMMENT_DELIMITER," "),f="".concat(e).concat(a).replaceAll(/\r?\n/g,"\n".concat(e)).split(/\n/);// Allow multiline comments.
27
+ */insertComment(a,b){const c=null===b||void 0===b?void 0:b.referenceKey,d=(null===b||void 0===b?void 0:b.position)||"after",e="".concat((null===b||void 0===b?void 0:b.commentDelimiter)||DEFAULT_COMMENT_DELIMITER," "),f="".concat(e).concat(a).replace(/\r?\n/g,"\n".concat(e)).split(/\n/);// Allow multiline comments.
28
28
  if(void 0===c)return this.lines.push(...f),this.parseLines(),!0;else{// Find the last occurrence of the reference key.
29
29
  const a=[...this.collection].reverse().find(a=>a.key===c);// Insert the new comment when a reference key defined only when found.
30
30
  if(a){var g,h;const b="after"===d?a.endingLineNumber:null!==(g=null===(h=a.previousProperty)||void 0===h?void 0:h.endingLineNumber)&&void 0!==g?g:0;return this.lines=[...this.lines.slice(0,b),...f,...this.lines.slice(b)],this.parseLines(),!0}return!1}}/**
@@ -42,16 +42,14 @@ const c=[...this.collection].reverse().find(b=>b.key===a);if(c){var d,e;const a=
42
42
  *
43
43
  * @returns The key with its original newlines characters restored.
44
44
  */getKeyWithNewlines(a){return 0===a.newlinePositions.length?a.key:// eslint-disable-next-line unicorn/no-array-reduce
45
- [...a.key].reduce((b,c,d)=>// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
46
- "".concat(b).concat(a.newlinePositions.includes(d)?"\n":"").concat(c),"")}/**
45
+ [...a.key].reduce((b,c,d)=>"".concat(b).concat(a.newlinePositions.includes(d)?"\n":"").concat(c),"")}/**
47
46
  * Restore the original newline characters of a value.
48
47
  *
49
48
  * @param property - A property object.
50
49
  *
51
50
  * @returns The value with its original newlines characters restored.
52
51
  */getValueWithNewlines(a){return 0===a.newlinePositions.length||a.valuePosition===void 0?a.value:// eslint-disable-next-line unicorn/no-array-reduce
53
- [...a.value].reduce((b,c,d)=>"".concat(b).concat(a.newlinePositions.includes(d+a.valuePosition)?"\n":""// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
54
- ).concat(c),"")}/**
52
+ [...a.value].reduce((b,c,d)=>"".concat(b).concat(a.newlinePositions.includes(d+a.valuePosition)?"\n":"").concat(c),"")}/**
55
53
  * Update the last occurrence of a given key from the existing object.
56
54
  *
57
55
  * @param key - The name of the key to update.
package/lib/properties.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getFirstEolCharacter=exports.Properties=exports.KeyCollisions=exports.DEFAULT_END_OF_LINE_CHARACTER=exports.BOM_CODE_POINT=exports.BOM=void 0,require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/esnext.string.at.js");var _property=require("./property"),_propertyLine=require("./property-line");function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}/**
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getFirstEolCharacter=exports.Properties=exports.KeyCollisions=exports.DEFAULT_END_OF_LINE_CHARACTER=exports.BOM_CODE_POINT=exports.BOM=void 0;var _property=require("./property"),_propertyLine=require("./property-line");function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}/**
2
2
  * Byte-order mark.
3
3
  */const BOM="\uFEFF";exports.BOM="\uFEFF";const BOM_CODE_POINT="\uFEFF".codePointAt(0);/** The default end of line character. */exports.BOM_CODE_POINT=65279;const DEFAULT_END_OF_LINE_CHARACTER="\n";/**
4
4
  * Get the first end of line (EOL) character from multiline content.
@@ -49,4 +49,4 @@ a.setKeyAndValue(),null!==(b=this.keyLineNumbers[a.key])&&void 0!==b&&b.length?(
49
49
  * @param startingLineNumbers - The starting line numbers where collisions are found.
50
50
  */constructor(a,b){this.key=a,this.startingLineNumbers=b}/**
51
51
  * Get the number of the line from which the value will be used.
52
- */getApplicableLineNumber(){return this.startingLineNumbers.at(-1)}}exports.KeyCollisions=KeyCollisions;
52
+ */getApplicableLineNumber(){return this.startingLineNumbers.slice(-1)[0]}}exports.KeyCollisions=KeyCollisions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "properties-file",
3
- "version": "3.2.0",
3
+ "version": "3.2.2",
4
4
  "description": ".properties file parser, editor, formatter and Webpack loader.",
5
5
  "keywords": [
6
6
  ".properties",
@@ -53,7 +53,7 @@
53
53
  ],
54
54
  "scripts": {
55
55
  "add-import-type": "ts-node ./src/add-import-type.ts && rm -f ./lib/add-import-type.*",
56
- "build": "npm run prettier && npm run lint-fix && rm -Rf ./lib && babel --config-file ./.babelrc --extensions .ts src -d lib && tsc && npm run add-import-type && npm run test",
56
+ "build": "check-node-version --node '>=16' && npm run prettier && npm run lint-fix && rm -Rf ./lib && babel --config-file ./.babelrc --extensions .ts src -d lib && tsc && npm run add-import-type && npm run test",
57
57
  "ci": "npm run build",
58
58
  "lint-check": "eslint --ext .js --ext .jsx --ext .ts --ext .tsx --ext .json .",
59
59
  "lint-fix": "eslint --ext .js --ext .jsx --ext .ts --ext .tsx --ext .json --fix .",
@@ -69,9 +69,10 @@
69
69
  "@babel/preset-typescript": "^7.21.5",
70
70
  "@release-it/conventional-changelog": "5.1.1",
71
71
  "@types/jest": "29.5.1",
72
- "@typescript-eslint/eslint-plugin": "5.59.2",
73
- "@typescript-eslint/parser": "5.59.2",
72
+ "@typescript-eslint/eslint-plugin": "5.59.5",
73
+ "@typescript-eslint/parser": "5.59.5",
74
74
  "babel-preset-minify": "^0.5.2",
75
+ "check-node-version": "^4.2.1",
75
76
  "dotenv-cli": "7.2.1",
76
77
  "eslint": "8.40.0",
77
78
  "eslint-config-prettier": "8.8.0",
@@ -94,6 +95,6 @@
94
95
  "typescript": "5.0.4"
95
96
  },
96
97
  "engines": {
97
- "node": "^14.18.1 || >=16.0.0"
98
+ "node": "*"
98
99
  }
99
100
  }