properties-file 3.2.0 → 3.2.1

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.
@@ -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,8 @@ 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)// eslint-disable-next-line unicorn/prefer-string-replace-all
28
+ .replace(/\r?\n/g,"\n".concat(e)).split(/\n/);// Allow multiline comments.
28
29
  if(void 0===c)return this.lines.push(...f),this.parseLines(),!0;else{// Find the last occurrence of the reference key.
29
30
  const a=[...this.collection].reverse().find(a=>a.key===c);// Insert the new comment when a reference key defined only when found.
30
31
  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}}/**
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,6 @@ 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.at(-1)
53
+ // eslint-disable-next-line unicorn/prefer-at
54
+ 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.1",
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 .",
@@ -72,6 +72,7 @@
72
72
  "@typescript-eslint/eslint-plugin": "5.59.2",
73
73
  "@typescript-eslint/parser": "5.59.2",
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
  }