properties-file
Advanced tools
Comparing version 3.4.0 to 3.4.1
@@ -1,2 +0,1 @@ | ||
/// <reference types="./properties-file" /> | ||
/// <reference types="node" /> | ||
@@ -18,1 +17,4 @@ export { Properties } from './properties'; | ||
export declare const getProperties: (content: string | Buffer) => KeyValuePairObject; | ||
// Enables type recognition for direct `.properties` file imports. | ||
import './properties-file.d.ts' |
@@ -1,2 +0,1 @@ | ||
/// <reference types="../properties-file" /> | ||
/** | ||
@@ -11,1 +10,4 @@ * Webpack file loader for `.properties` files. | ||
export default webpackLoader; | ||
// Enables type recognition for direct `.properties` file imports. | ||
import '../properties-file.d.ts' |
@@ -1,7 +0,8 @@ | ||
/** This allows to get the correct type when using `import` on `.properties` files. */ | ||
declare module '*.properties' { | ||
const properties: { | ||
/** A key/value object representing the content of a `.properties` file. */ | ||
const keyValuePairObject: { | ||
/** The value of a `.properties` file key. */ | ||
readonly [key: string]: string | ||
} | ||
export default properties | ||
export = keyValuePairObject | ||
} |
@@ -1,2 +0,2 @@ | ||
import { Properties } from '../properties'; | ||
import { Properties } from '../properties.js'; | ||
/** The default separator between keys and values. */ | ||
@@ -3,0 +3,0 @@ export declare const DEFAULT_SEPARATOR = "="; |
@@ -1,1 +0,1 @@ | ||
var __extends=this&&this.__extends||function(){var e=function(n,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])},e(n,r)};return function(n,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function t(){this.constructor=n}e(n,r),n.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t)}}(),__read=this&&this.__read||function(e,n){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var t,i,o=r.call(e),a=[];try{for(;(void 0===n||n-- >0)&&!(t=o.next()).done;)a.push(t.value)}catch(e){i={error:e}}finally{try{t&&!t.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a},__spreadArray=this&&this.__spreadArray||function(e,n,r){if(r||2===arguments.length)for(var t,i=0,o=n.length;i<o;i++)!t&&i in n||(t||(t=Array.prototype.slice.call(n,0,i)),t[i]=n[i]);return e.concat(t||Array.prototype.slice.call(n))};import{escapeKey,escapeValue}from"../escape";import{Properties}from"../properties";export var DEFAULT_SEPARATOR="=";export var DEFAULT_COMMENT_DELIMITER="#";var PropertiesEditor=function(e){function n(n){var r=e.call(this,n)||this;return r.needsLineParsing=!1,r}return __extends(n,e),n.prototype.parseLinesIfNeeded=function(){this.needsLineParsing&&(this.parseLines(),this.needsLineParsing=!1)},n.prototype.insert=function(e,n,r){var t,i,o,a=(null==r?void 0:r.escapeUnicode)||!1,s=(null==r?void 0:r.separator)?" "===r.separator?" ":" ".concat(r.separator," "):" ".concat(DEFAULT_SEPARATOR," ").replace(" "," "),c=null==r?void 0:r.referenceKey,l=(null==r?void 0:r.position)||"after";c&&this.parseLinesIfNeeded();var p=e.split(/\r?\n/).map((function(e){return escapeKey(e,a)})).join("\\\n"),d=n.split(/\r?\n/).map((function(e){return escapeValue(e,a)})).join("\\\n"),u="".concat((null==r?void 0:r.commentDelimiter)||DEFAULT_COMMENT_DELIMITER," "),_=void 0===(null==r?void 0:r.comment)?"":"".concat("".concat(u).concat(r.comment).split(/\r?\n/).join("\n".concat(u)),"\n"),v="".concat(_).concat(p).concat(s).concat(d).split(/\n/);if(void 0===c)return(t=this.lines).push.apply(t,__spreadArray([],__read(v),!1)),this.needsLineParsing=!0,!0;var y=__spreadArray([],__read(this.collection),!1).reverse().find((function(e){return e.key===c}));if(y){var f="after"===l?y.endingLineNumber:null!==(o=null===(i=y.previousProperty)||void 0===i?void 0:i.endingLineNumber)&&void 0!==o?o:0;return this.lines=__spreadArray(__spreadArray(__spreadArray([],__read(this.lines.slice(0,f)),!1),__read(v),!1),__read(this.lines.slice(f)),!1),this.needsLineParsing=!0,!0}return!1},n.prototype.insertComment=function(e,n){var r,t,i,o=null==n?void 0:n.referenceKey,a=(null==n?void 0:n.position)||"after";o&&this.parseLinesIfNeeded();var s="".concat((null==n?void 0:n.commentDelimiter)||DEFAULT_COMMENT_DELIMITER," "),c="".concat(s).concat(e).replace(/\r?\n/g,"\n".concat(s)).split(/\n/);if(void 0===o)return(r=this.lines).push.apply(r,__spreadArray([],__read(c),!1)),this.needsLineParsing=!0,!0;var l=__spreadArray([],__read(this.collection),!1).reverse().find((function(e){return e.key===o}));if(l){var p="after"===a?l.endingLineNumber:null!==(i=null===(t=l.previousProperty)||void 0===t?void 0:t.endingLineNumber)&&void 0!==i?i:0;return this.lines=__spreadArray(__spreadArray(__spreadArray([],__read(this.lines.slice(0,p)),!1),__read(c),!1),__read(this.lines.slice(p)),!1),this.needsLineParsing=!0,!0}return!1},n.prototype.delete=function(e,n){var r,t;void 0===n&&(n=!0),this.parseLinesIfNeeded();var i=__spreadArray([],__read(this.collection),!1).reverse().find((function(n){return n.key===e}));if(i){var o=n?null!==(t=null===(r=i.previousProperty)||void 0===r?void 0:r.endingLineNumber)&&void 0!==t?t:0:i.startingLineNumber-1,a=i.endingLineNumber;return this.lines=__spreadArray(__spreadArray([],__read(this.lines.slice(0,o)),!1),__read(this.lines.slice(a)),!1),this.needsLineParsing=!0,!0}return!1},n.prototype.getKeyWithNewlines=function(e){return 0===e.newlinePositions.length?e.key:__spreadArray([],__read(e.key),!1).reduce((function(n,r,t){return"".concat(n).concat(e.newlinePositions.includes(t)?"\n":"").concat(r)}),"")},n.prototype.getValueWithNewlines=function(e){return 0===e.newlinePositions.length||void 0===e.valuePosition?e.value:__spreadArray([],__read(e.value),!1).reduce((function(n,r,t){return"".concat(n).concat(e.newlinePositions.includes(t+e.valuePosition)?"\n":"").concat(r)}),"")},n.prototype.update=function(e,n){var r,t,i,o;this.parseLinesIfNeeded();var a=__spreadArray([],__read(this.collection),!1).reverse().find((function(n){return n.key===e}));if(!a||!n)return!1;var s=n.escapeUnicode||!1,c=n.separator?" "===n.separator?" ":" ".concat(n.separator," "):a.separator||" ".concat(DEFAULT_SEPARATOR," ").replace(" "," "),l=(null!==(r=n.newKey)&&void 0!==r?r:this.getKeyWithNewlines(a)).split(/\r?\n/).map((function(e){return escapeKey(e,s)})).join("\\\n"),p=(null!==(t=n.newValue)&&void 0!==t?t:this.getValueWithNewlines(a)).split(/\r?\n/).map((function(e){return escapeValue(e,s)})).join("\\\n"),d="".concat(n.commentDelimiter||DEFAULT_COMMENT_DELIMITER," "),u=void 0===n.newComment?"":"".concat("".concat(d).concat(n.newComment).split(/\r?\n/).join("\n".concat(d)),"\n"),_="".concat(u).concat(l).concat(c).concat(p).split(/\n/);return this.lines=__spreadArray(__spreadArray(__spreadArray([],__read(this.lines.slice(0,void 0===n.newComment?a.startingLineNumber-1:null!==(o=null===(i=a.previousProperty)||void 0===i?void 0:i.endingLineNumber)&&void 0!==o?o:0)),!1),__read(_),!1),__read(this.lines.slice(a.endingLineNumber)),!1),this.needsLineParsing=!0,!0},n.prototype.upsert=function(e,n,r){return this.parseLinesIfNeeded(),this.keyLineNumbers[e]?this.update(e,{newValue:n,newComment:null==r?void 0:r.comment,commentDelimiter:null==r?void 0:r.commentDelimiter,separator:null==r?void 0:r.separator,escapeUnicode:null==r?void 0:r.escapeUnicode}):this.insert(e,n,r)},n}(Properties);export{PropertiesEditor}; | ||
var __extends=this&&this.__extends||function(){var e=function(n,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])},e(n,r)};return function(n,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function t(){this.constructor=n}e(n,r),n.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t)}}(),__read=this&&this.__read||function(e,n){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var t,i,o=r.call(e),a=[];try{for(;(void 0===n||n-- >0)&&!(t=o.next()).done;)a.push(t.value)}catch(e){i={error:e}}finally{try{t&&!t.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a},__spreadArray=this&&this.__spreadArray||function(e,n,r){if(r||2===arguments.length)for(var t,i=0,o=n.length;i<o;i++)!t&&i in n||(t||(t=Array.prototype.slice.call(n,0,i)),t[i]=n[i]);return e.concat(t||Array.prototype.slice.call(n))};import{escapeKey,escapeValue}from"../escape/index.js";import{Properties}from"../properties.js";export var DEFAULT_SEPARATOR="=";export var DEFAULT_COMMENT_DELIMITER="#";var PropertiesEditor=function(e){function n(n){var r=e.call(this,n)||this;return r.needsLineParsing=!1,r}return __extends(n,e),n.prototype.parseLinesIfNeeded=function(){this.needsLineParsing&&(this.parseLines(),this.needsLineParsing=!1)},n.prototype.insert=function(e,n,r){var t,i,o,a=(null==r?void 0:r.escapeUnicode)||!1,s=(null==r?void 0:r.separator)?" "===r.separator?" ":" ".concat(r.separator," "):" ".concat(DEFAULT_SEPARATOR," ").replace(" "," "),c=null==r?void 0:r.referenceKey,l=(null==r?void 0:r.position)||"after";c&&this.parseLinesIfNeeded();var d=e.split(/\r?\n/).map((function(e){return escapeKey(e,a)})).join("\\\n"),p=n.split(/\r?\n/).map((function(e){return escapeValue(e,a)})).join("\\\n"),u="".concat((null==r?void 0:r.commentDelimiter)||DEFAULT_COMMENT_DELIMITER," "),_=void 0===(null==r?void 0:r.comment)?"":"".concat("".concat(u).concat(r.comment).split(/\r?\n/).join("\n".concat(u)),"\n"),v="".concat(_).concat(d).concat(s).concat(p).split(/\n/);if(void 0===c)return(t=this.lines).push.apply(t,__spreadArray([],__read(v),!1)),this.needsLineParsing=!0,!0;var y=__spreadArray([],__read(this.collection),!1).reverse().find((function(e){return e.key===c}));if(y){var f="after"===l?y.endingLineNumber:null!==(o=null===(i=y.previousProperty)||void 0===i?void 0:i.endingLineNumber)&&void 0!==o?o:0;return this.lines=__spreadArray(__spreadArray(__spreadArray([],__read(this.lines.slice(0,f)),!1),__read(v),!1),__read(this.lines.slice(f)),!1),this.needsLineParsing=!0,!0}return!1},n.prototype.insertComment=function(e,n){var r,t,i,o=null==n?void 0:n.referenceKey,a=(null==n?void 0:n.position)||"after";o&&this.parseLinesIfNeeded();var s="".concat((null==n?void 0:n.commentDelimiter)||DEFAULT_COMMENT_DELIMITER," "),c="".concat(s).concat(e).replace(/\r?\n/g,"\n".concat(s)).split(/\n/);if(void 0===o)return(r=this.lines).push.apply(r,__spreadArray([],__read(c),!1)),this.needsLineParsing=!0,!0;var l=__spreadArray([],__read(this.collection),!1).reverse().find((function(e){return e.key===o}));if(l){var d="after"===a?l.endingLineNumber:null!==(i=null===(t=l.previousProperty)||void 0===t?void 0:t.endingLineNumber)&&void 0!==i?i:0;return this.lines=__spreadArray(__spreadArray(__spreadArray([],__read(this.lines.slice(0,d)),!1),__read(c),!1),__read(this.lines.slice(d)),!1),this.needsLineParsing=!0,!0}return!1},n.prototype.delete=function(e,n){var r,t;void 0===n&&(n=!0),this.parseLinesIfNeeded();var i=__spreadArray([],__read(this.collection),!1).reverse().find((function(n){return n.key===e}));if(i){var o=n?null!==(t=null===(r=i.previousProperty)||void 0===r?void 0:r.endingLineNumber)&&void 0!==t?t:0:i.startingLineNumber-1,a=i.endingLineNumber;return this.lines=__spreadArray(__spreadArray([],__read(this.lines.slice(0,o)),!1),__read(this.lines.slice(a)),!1),this.needsLineParsing=!0,!0}return!1},n.prototype.getKeyWithNewlines=function(e){return 0===e.newlinePositions.length?e.key:__spreadArray([],__read(e.key),!1).reduce((function(n,r,t){return"".concat(n).concat(e.newlinePositions.includes(t)?"\n":"").concat(r)}),"")},n.prototype.getValueWithNewlines=function(e){return 0===e.newlinePositions.length||void 0===e.valuePosition?e.value:__spreadArray([],__read(e.value),!1).reduce((function(n,r,t){return"".concat(n).concat(e.newlinePositions.includes(t+e.valuePosition)?"\n":"").concat(r)}),"")},n.prototype.update=function(e,n){var r,t,i,o;this.parseLinesIfNeeded();var a=__spreadArray([],__read(this.collection),!1).reverse().find((function(n){return n.key===e}));if(!a||!n)return!1;var s=n.escapeUnicode||!1,c=n.separator?" "===n.separator?" ":" ".concat(n.separator," "):a.separator||" ".concat(DEFAULT_SEPARATOR," ").replace(" "," "),l=(null!==(r=n.newKey)&&void 0!==r?r:this.getKeyWithNewlines(a)).split(/\r?\n/).map((function(e){return escapeKey(e,s)})).join("\\\n"),d=(null!==(t=n.newValue)&&void 0!==t?t:this.getValueWithNewlines(a)).split(/\r?\n/).map((function(e){return escapeValue(e,s)})).join("\\\n"),p="".concat(n.commentDelimiter||DEFAULT_COMMENT_DELIMITER," "),u=void 0===n.newComment?"":"".concat("".concat(p).concat(n.newComment).split(/\r?\n/).join("\n".concat(p)),"\n"),_="".concat(u).concat(l).concat(c).concat(d).split(/\n/);return this.lines=__spreadArray(__spreadArray(__spreadArray([],__read(this.lines.slice(0,void 0===n.newComment?a.startingLineNumber-1:null!==(o=null===(i=a.previousProperty)||void 0===i?void 0:i.endingLineNumber)&&void 0!==o?o:0)),!1),__read(_),!1),__read(this.lines.slice(a.endingLineNumber)),!1),this.needsLineParsing=!0,!0},n.prototype.upsert=function(e,n,r){return this.parseLinesIfNeeded(),this.keyLineNumbers[e]?this.update(e,{newValue:n,newComment:null==r?void 0:r.comment,commentDelimiter:null==r?void 0:r.commentDelimiter,separator:null==r?void 0:r.separator,escapeUnicode:null==r?void 0:r.escapeUnicode}):this.insert(e,n,r)},n}(Properties);export{PropertiesEditor}; |
@@ -1,4 +0,3 @@ | ||
/// <reference types="./properties-file" /> | ||
/// <reference types="node" /> | ||
export { Properties } from './properties'; | ||
export { Properties } from './properties.js'; | ||
/** | ||
@@ -18,1 +17,4 @@ * A key-value pair object. | ||
export declare const getProperties: (content: string | Buffer) => KeyValuePairObject; | ||
// Enables type recognition for direct `.properties` file imports. | ||
import './properties-file.d.ts' |
@@ -1,1 +0,1 @@ | ||
import{Properties}from"./properties";export{Properties}from"./properties";export var getProperties=function(r){return new Properties(r).toObject()}; | ||
import{Properties}from"./properties.js";export{Properties}from"./properties.js";export var getProperties=function(r){return new Properties(r).toObject()}; |
@@ -1,2 +0,1 @@ | ||
/// <reference types="../properties-file" /> | ||
/** | ||
@@ -11,1 +10,4 @@ * Webpack file loader for `.properties` files. | ||
export default webpackLoader; | ||
// Enables type recognition for direct `.properties` file imports. | ||
import '../properties-file.d.ts' |
@@ -1,1 +0,1 @@ | ||
import{getProperties}from"..";var webpackLoader=function(e){return"module.exports = ".concat(JSON.stringify(getProperties(e)),";")};export default webpackLoader; | ||
import{getProperties}from"../index.js";var webpackLoader=function(e){return"module.exports = ".concat(JSON.stringify(getProperties(e)),";")};export default webpackLoader; |
@@ -1,7 +0,8 @@ | ||
/** This allows to get the correct type when using `import` on `.properties` files. */ | ||
declare module '*.properties' { | ||
const properties: { | ||
/** A key/value object representing the content of a `.properties` file. */ | ||
const keyValuePairObject: { | ||
/** The value of a `.properties` file key. */ | ||
readonly [key: string]: string | ||
} | ||
export default properties | ||
export = keyValuePairObject | ||
} |
/// <reference types="node" /> | ||
import { KeyValuePairObject } from '.'; | ||
import { Property } from './property'; | ||
import { KeyValuePairObject } from './index.js'; | ||
import { Property } from './property.js'; | ||
/** | ||
@@ -5,0 +5,0 @@ * Byte-order mark. |
@@ -1,1 +0,1 @@ | ||
var __values=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},__read=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s};import{Property}from"./property";import{PropertyLine}from"./property-line";export var BOM="\ufeff";export var BOM_CODE_POINT=BOM.codePointAt(0);export var DEFAULT_END_OF_LINE_CHARACTER="\n";export var getFirstEolCharacter=function(e){var t=e.indexOf("\n");return t<0?void 0:"".concat("\r"===e[t-1]?"\r":"","\n")};var Properties=function(){function e(e){var t;this.collection=[],this.keyLineNumbers={};var r="string"==typeof e?e:e.toString();this.hasBom=r.codePointAt(0)===BOM_CODE_POINT,this.eolCharacter=null!==(t=getFirstEolCharacter(r))&&void 0!==t?t:DEFAULT_END_OF_LINE_CHARACTER,this.lines=(this.hasBom?r.slice(1):r).split(/\r?\n/),this.parseLines()}return e.prototype.parseLines=function(){var e,t;this.collection=[],this.keyLineNumbers={};var r,n,i=0;try{for(var o=__values(this.lines),s=o.next();!s.done;s=o.next()){var l=s.value;i++;var a=new PropertyLine(l,!!r);if(r){if(r.addLine(a),a.isContinuing)continue}else{if(a.isComment||a.isBlank)continue;if(r=new Property(a,i,n),a.isContinuing)continue}this.addToCollection(r),n=r,r=void 0}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}},e.prototype.addToCollection=function(e){var t;e.setKeyAndValue(),(null===(t=this.keyLineNumbers[e.key])||void 0===t?void 0:t.length)?(this.keyLineNumbers[e.key].push(e.startingLineNumber),e.hasKeyCollisions=!0,e.keyCollisionLines=this.keyLineNumbers[e.key],this.collection=this.collection.filter((function(t){return t.key!==e.key}))):this.keyLineNumbers[e.key]=[e.startingLineNumber],this.collection.push(e)},e.prototype.getKeyCollisions=function(){var e,t,r=[];try{for(var n=__values(Object.entries(this.keyLineNumbers)),i=n.next();!i.done;i=n.next()){var o=__read(i.value,2),s=o[0],l=o[1];l.length>1&&r.push(new KeyCollisions(s,l))}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return r},e.prototype.toObject=function(){var e={};return this.collection.forEach((function(t){e[t.key]=t.value})),e},e.prototype.format=function(e){return"".concat(this.hasBom?BOM:"").concat(this.lines.join(e||this.eolCharacter))},e}();export{Properties};var KeyCollisions=function(){function e(e,t){this.key=e,this.startingLineNumbers=t}return e.prototype.getApplicableLineNumber=function(){return this.startingLineNumbers.slice(-1)[0]},e}();export{KeyCollisions}; | ||
var __values=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},__read=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s};import{Property}from"./property.js";import{PropertyLine}from"./property-line.js";export var BOM="\ufeff";export var BOM_CODE_POINT=BOM.codePointAt(0);export var DEFAULT_END_OF_LINE_CHARACTER="\n";export var getFirstEolCharacter=function(e){var t=e.indexOf("\n");return t<0?void 0:"".concat("\r"===e[t-1]?"\r":"","\n")};var Properties=function(){function e(e){var t;this.collection=[],this.keyLineNumbers={};var r="string"==typeof e?e:e.toString();this.hasBom=r.codePointAt(0)===BOM_CODE_POINT,this.eolCharacter=null!==(t=getFirstEolCharacter(r))&&void 0!==t?t:DEFAULT_END_OF_LINE_CHARACTER,this.lines=(this.hasBom?r.slice(1):r).split(/\r?\n/),this.parseLines()}return e.prototype.parseLines=function(){var e,t;this.collection=[],this.keyLineNumbers={};var r,n,i=0;try{for(var o=__values(this.lines),s=o.next();!s.done;s=o.next()){var l=s.value;i++;var a=new PropertyLine(l,!!r);if(r){if(r.addLine(a),a.isContinuing)continue}else{if(a.isComment||a.isBlank)continue;if(r=new Property(a,i,n),a.isContinuing)continue}this.addToCollection(r),n=r,r=void 0}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}},e.prototype.addToCollection=function(e){var t;e.setKeyAndValue(),(null===(t=this.keyLineNumbers[e.key])||void 0===t?void 0:t.length)?(this.keyLineNumbers[e.key].push(e.startingLineNumber),e.hasKeyCollisions=!0,e.keyCollisionLines=this.keyLineNumbers[e.key],this.collection=this.collection.filter((function(t){return t.key!==e.key}))):this.keyLineNumbers[e.key]=[e.startingLineNumber],this.collection.push(e)},e.prototype.getKeyCollisions=function(){var e,t,r=[];try{for(var n=__values(Object.entries(this.keyLineNumbers)),i=n.next();!i.done;i=n.next()){var o=__read(i.value,2),s=o[0],l=o[1];l.length>1&&r.push(new KeyCollisions(s,l))}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return r},e.prototype.toObject=function(){var e={};return this.collection.forEach((function(t){e[t.key]=t.value})),e},e.prototype.format=function(e){return"".concat(this.hasBom?BOM:"").concat(this.lines.join(e||this.eolCharacter))},e}();export{Properties};var KeyCollisions=function(){function e(e,t){this.key=e,this.startingLineNumbers=t}return e.prototype.getApplicableLineNumber=function(){return this.startingLineNumbers.slice(-1)[0]},e}();export{KeyCollisions}; |
@@ -1,2 +0,2 @@ | ||
import { PropertyLine } from './property-line'; | ||
import { PropertyLine } from './property-line.js'; | ||
/** | ||
@@ -3,0 +3,0 @@ * Object representing a property (key/value). |
@@ -1,1 +0,1 @@ | ||
var __values=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,i=e&&t[e],s=0;if(i)return i.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};import{unescapeContent}from"./unescape";var Property=function(){function t(t,e,i){this.key="",this.escapedKey="",this.hasNoKey=!1,this.hasMultilineKey=!1,this.keyCollisionLines=[],this.hasKeyCollisions=!1,this.value="",this.escapedValue="",this.hasNoValue=!1,this.newlinePositions=[],this.linesContent=t.content,this.startingLineNumber=e,this.endingLineNumber=e,this.previousProperty=i,null==i||i.setNextProperty(this)}return t.prototype.setNextProperty=function(t){this.nextProperty=t},t.prototype.addLine=function(t){this.linesContent.length>0&&(this.newlinePositions.push(this.linesContent.length),this.endingLineNumber++),this.linesContent+=t.content},t.prototype.setKeyAndValue=function(){this.findSeparator(),void 0!==this.separatorPosition&&void 0!==this.separatorLength?(this.hasNoKey||(this.escapedKey=this.linesContent.slice(0,this.separatorPosition),this.key=this.unescapeLine(this.escapedKey,this.startingLineNumber)),this.hasNoValue||(this.escapedValue=this.linesContent.slice(this.separatorPosition+this.separatorLength),this.value=this.unescapeLine(this.escapedValue,this.startingLineNumber))):this.hasNoValue&&(this.escapedKey=this.linesContent,this.key=this.unescapeLine(this.escapedKey,this.startingLineNumber))},t.prototype.unescapeLine=function(t,e){try{return unescapeContent(t)}catch(t){throw new Error("".concat(t.message," in property starting at line ").concat(e))}},t.prototype.findSeparator=function(){var t,e,i,s;if(!(this.hasNoKey||this.hasNoValue||this.separatorPosition)){try{for(var n=__values(this.linesContent.matchAll(/[\t\f :=]/g)),o=n.next();!o.done;o=n.next()){var r=o.value.index,a=this.linesContent.slice(0,r).match(/(?<backslashes>\\+)$/);if(null==a?void 0:a.groups)if(!!(a.groups.backslashes.length%2))continue;var h="";this.separatorPosition=r;var l=this.linesContent.slice(r),p=l.match(/^(?<whitespace>[\t\n\v\f\r ]+)/),u=(null===(i=null==p?void 0:p.groups)||void 0===i?void 0:i.whitespace)||"";if(u.length>0&&(h+=u,l=l.slice(u.length)),/[:=]/.test(l[0])){h+=l[0];var c=(l=l.slice(1)).match(/^(?<whitespace>[\t\n\v\f\r ]+)/);h+=(null===(s=null==c?void 0:c.groups)||void 0===s?void 0:s.whitespace)||""}this.separatorLength=h.length,this.valuePosition=this.separatorPosition+this.separatorLength,this.separator=this.linesContent.slice(this.separatorPosition,this.separatorPosition+this.separatorLength),r||(this.hasNoKey=!0);break}}catch(e){t={error:e}}finally{try{o&&!o.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}void 0===this.separatorPosition?this.hasNoValue=!0:this.newlinePositions.length>0&&this.newlinePositions[0]<this.separatorPosition&&(this.hasMultilineKey=!0)}},t}();export{Property}; | ||
var __values=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,i=e&&t[e],s=0;if(i)return i.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};import{unescapeContent}from"./unescape/index.js";var Property=function(){function t(t,e,i){this.key="",this.escapedKey="",this.hasNoKey=!1,this.hasMultilineKey=!1,this.keyCollisionLines=[],this.hasKeyCollisions=!1,this.value="",this.escapedValue="",this.hasNoValue=!1,this.newlinePositions=[],this.linesContent=t.content,this.startingLineNumber=e,this.endingLineNumber=e,this.previousProperty=i,null==i||i.setNextProperty(this)}return t.prototype.setNextProperty=function(t){this.nextProperty=t},t.prototype.addLine=function(t){this.linesContent.length>0&&(this.newlinePositions.push(this.linesContent.length),this.endingLineNumber++),this.linesContent+=t.content},t.prototype.setKeyAndValue=function(){this.findSeparator(),void 0!==this.separatorPosition&&void 0!==this.separatorLength?(this.hasNoKey||(this.escapedKey=this.linesContent.slice(0,this.separatorPosition),this.key=this.unescapeLine(this.escapedKey,this.startingLineNumber)),this.hasNoValue||(this.escapedValue=this.linesContent.slice(this.separatorPosition+this.separatorLength),this.value=this.unescapeLine(this.escapedValue,this.startingLineNumber))):this.hasNoValue&&(this.escapedKey=this.linesContent,this.key=this.unescapeLine(this.escapedKey,this.startingLineNumber))},t.prototype.unescapeLine=function(t,e){try{return unescapeContent(t)}catch(t){throw new Error("".concat(t.message," in property starting at line ").concat(e))}},t.prototype.findSeparator=function(){var t,e,i,s;if(!(this.hasNoKey||this.hasNoValue||this.separatorPosition)){try{for(var n=__values(this.linesContent.matchAll(/[\t\f :=]/g)),o=n.next();!o.done;o=n.next()){var r=o.value.index,a=this.linesContent.slice(0,r).match(/(?<backslashes>\\+)$/);if(null==a?void 0:a.groups)if(!!(a.groups.backslashes.length%2))continue;var h="";this.separatorPosition=r;var l=this.linesContent.slice(r),p=l.match(/^(?<whitespace>[\t\n\v\f\r ]+)/),u=(null===(i=null==p?void 0:p.groups)||void 0===i?void 0:i.whitespace)||"";if(u.length>0&&(h+=u,l=l.slice(u.length)),/[:=]/.test(l[0])){h+=l[0];var c=(l=l.slice(1)).match(/^(?<whitespace>[\t\n\v\f\r ]+)/);h+=(null===(s=null==c?void 0:c.groups)||void 0===s?void 0:s.whitespace)||""}this.separatorLength=h.length,this.valuePosition=this.separatorPosition+this.separatorLength,this.separator=this.linesContent.slice(this.separatorPosition,this.separatorPosition+this.separatorLength),r||(this.hasNoKey=!0);break}}catch(e){t={error:e}}finally{try{o&&!o.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}void 0===this.separatorPosition?this.hasNoValue=!0:this.newlinePositions.length>0&&this.newlinePositions[0]<this.separatorPosition&&(this.hasMultilineKey=!0)}},t}();export{Property}; |
{ | ||
"name": "properties-file", | ||
"version": "3.4.0", | ||
"version": "3.4.1", | ||
"description": ".properties file parser, editor, formatter and Webpack loader.", | ||
@@ -87,7 +87,5 @@ "keywords": [ | ||
"add-file-type-declaration": "node ./lib/esm/add-import-type.js && find ./lib -name 'add-import-type.*' -type f -delete", | ||
"build": "check-node-version --node '>=16' && npm run prettier && npm run lint-fix && rm -Rf ./lib && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json && tsc -p tsconfig.build-scripts.json && node lib/build-scripts/run-all.js && npm run test", | ||
"build": "check-node-version --node '>=16' && npm run prettier && npm run lint-fix && rm -Rf ./lib && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json && tsc -p tsconfig.build-scripts.json && node lib/build-scripts/build.js && npm run test", | ||
"ci": "npm run build", | ||
"lint-check": "eslint --ext .js --ext .jsx --ext .ts --ext .tsx --ext .json .", | ||
"lint-fix": "eslint --fix .", | ||
"lint-print-config": "eslint --print-config ./eslintrc.yaml", | ||
"prettier": "prettier --write .", | ||
@@ -100,3 +98,3 @@ "release": "dotenv -- release-it --only-version", | ||
"@types/jest": "29.5.12", | ||
"@types/node": "^20.11.21", | ||
"@types/node": "^20.11.24", | ||
"@typescript-eslint/eslint-plugin": "7.1.0", | ||
@@ -103,0 +101,0 @@ "@typescript-eslint/parser": "7.1.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
74400
810
0