Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

properties

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

properties - npm Package Compare versions

Comparing version 0.1.9 to 0.1.10

2

package.json
{
"name": "properties",
"version": "0.1.9",
"version": "0.1.10",
"description": "A Java .properties file parser ported to node.js.",

@@ -5,0 +5,0 @@ "keywords": ["properties", "persistence", "parser"],

@@ -1,1 +0,1 @@

"use strict";var BufferedReader=require("buffered-reader"),BufferedWriter=require("buffered-writer"),unicodeStringToCharacter=function(e){var t=0,n;for(var r=0;r<4;r++){n=e[r];switch(n){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":t=(t<<4)+n.charCodeAt(0)-48;break;case"a":case"b":case"c":case"d":case"e":case"f":t=(t<<4)+n.charCodeAt(0)-88;break;case"A":case"B":case"C":case"D":case"E":case"F":t=(t<<4)+n.charCodeAt(0)-55}}return String.fromCharCode(t)},characterToUnicodeString=function(e){var t=e.charCodeAt(0);return"\\u"+toHex(t>>12)+toHex(t>>8)+toHex(t>>4)+toHex(t)},toHex=function(e){var t="0123456789ABCDEF";return t[e&15]},PropertyReader=function(e,t){this._onLine=e,this._onEOF=t,this._skipWhiteSpace=!0,this._isCommentLine=!1,this._isNewLine=!0,this._appendedLineBegin=!1,this._precedingBackslash=!1,this._skipLF=!1,this._line=""};PropertyReader.prototype._convert=function(e,t,n){var r,i="",s;while(e<t)r=n[e++],r==="\\"?(r=n[e++],r==="u"?i+=unicodeStringToCharacter(n[e++]+n[e++]+n[e++]+n[e++]):(r==="t"?r=" ":r==="r"?r="\r":r==="n"?r="\n":r==="f"&&(r="\f"),i+=r)):i+=r;return i},PropertyReader.prototype._readKeyValue=function(e){var t=!1,n=!1,r=e.length,i=r,s=0,o;while(s<r){o=e[s];if((o==="="||o===":")&&!n){i=s+1,t=!0;break}if((o===" "||o===" "||o=="\f")&&!n){i=s+1;break}o==="\\"?n=!n:n=!1,s++}while(i<r){o=e[i];if(o!==" "&&o!==" "&&o!=="\f"){if(!!t||o!=="="&&o!==":")break;t=!0}i++}this._onLine(this._convert(0,s,e),this._convert(i,r,e))},PropertyReader.prototype.eof=function(){this._line&&this._readKeyValue(this._line),this._onEOF()},PropertyReader.prototype.parse=function(e){if(this._isCommentLine){if(e==="\r"||e==="\n")this._isCommentLine=!1,this._isNewLine=!0,this._skipWhiteSpace=!0;return}if(this._skipLF){this._skipLF=!1;if(e==="\n")return}if(this._skipWhiteSpace){if(e===" "||e===" "||e==="\f")return;if(!this._appendedLineBegin&&(e==="\r"||e==="\n"))return;this._skipWhiteSpace=!1,this._appendedLineBegin=!1}if(this._isNewLine){this._isNewLine=!1;if(e==="#"||e==="!"){this._isCommentLine=!0;return}}e!=="\n"&&e!=="\r"?(this._line+=e,e==="\\"?this._precedingBackslash=!this._precedingBackslash:this._precedingBackslash=!1):this._precedingBackslash?(this._line=this._line.substring(0,this._line.length-1),this._skipWhiteSpace=!0,this._appendedLineBegin=!0,this._precedingBackslash=!1,e==="\r"&&(this._skipLF=!0)):(this._isNewLine=!0,this._skipWhiteSpace=!0,this._line&&this._readKeyValue(this._line),this._line="")};var Properties=function(){this._keys={}};Properties.COMMENT="#",Properties.SENSITIVITY=!0,Properties.SEPARATOR="=",Properties.prototype.get=function(e,t){var n=this._keys[e];return n!==undefined?n.value:t},Properties.prototype.keys=function(){return Object.keys(this._keys)},Properties.prototype.load=function(e,t){t&&(t=t.bind(this));var n=this,r=new PropertyReader(function(e,t){if(!Properties.SENSITIVITY){var r=e.toLowerCase();for(var i in n._keys)if(r===i.toLowerCase())return}n._keys[e]={value:t}},function(){t&&t(null)});(new BufferedReader(e,{encoding:"utf8"})).on("error",function(e){t&&t(e)}).on("character",function(e){r.parse(e)}).on("end",function(){r.eof()}).read()},Properties.prototype.remove=function(e){if(!Properties.SENSITIVITY){var t=e.toLowerCase();for(var n in this._keys)if(t===n.toLowerCase()){delete this._keys[n];break}}else delete this._keys[e];return this},Properties.prototype.set=function(e,t,n){if(!Properties.SENSITIVITY){var r=e.toLowerCase();for(var i in this._keys)if(r===i.toLowerCase())return this}return this._keys[e]={value:t?t.toString():t,comment:n},this};var convert=function(e,t,n){var r,i,s="";if(!e)return s;for(var o=0,u=e.length;o<u;o++){r=e[o],i=r.charCodeAt(0);if(i>61&&i<127){r==="\\"?(s+="\\",s+="\\"):s+=r;continue}switch(r){case" ":if(o===0||t)s+="\\";s+=" ";break;case" ":s+="\\",s+="t";break;case"\n":s+="\\",s+="n";break;case"\r":s+="\\",s+="r";break;case"\f":s+="\\",s+="f";break;case"=":case":":case"#":case"!":s+="\\",s+=r;break;default:i<33||i>126?s+=n?characterToUnicodeString(r):r:s+=r}}return s};Properties.prototype.store=function(e,t,n,r){var i=arguments.length,s;i===1?t=!1:i===2?(s=typeof t,s==="function"?(r=t,t=!1,n=null):s==="string"&&(n=t,t=!1)):i===3&&(s=typeof t,s==="boolean"&&typeof n=="function"?(r=n,n=null):s==="string"&&(r=n,n=t,t=!1)),r&&(r=r.bind(this));var o=new BufferedWriter(e,{encoding:"utf8"});o.on("error",function(e){r&&r(e)}),o.write(""),n&&o.write(Properties.COMMENT+n).newLine();var u;for(var a in this._keys)u=this._keys[a],u.comment&&o.write(Properties.COMMENT+u.comment).newLine(),o.write(convert(a,!0,t)+Properties.SEPARATOR+convert(u.value,!1,t)).newLine();o.close(function(){r&&r(null)})},module.exports=Properties;
"use strict";var BufferedReader=require("buffered-reader"),BufferedWriter=require("buffered-writer"),unicodeStringToCharacter=function(e){var t=0,n;for(var r=0;r<4;r++){n=e[r];switch(n){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":t=(t<<4)+n.charCodeAt(0)-48;break;case"a":case"b":case"c":case"d":case"e":case"f":t=(t<<4)+n.charCodeAt(0)-88;break;case"A":case"B":case"C":case"D":case"E":case"F":t=(t<<4)+n.charCodeAt(0)-55}}return String.fromCharCode(t)},characterToUnicodeString=function(e){var t=e.charCodeAt(0);return"\\u"+toHex(t>>12)+toHex(t>>8)+toHex(t>>4)+toHex(t)},toHex=function(e){var t="0123456789ABCDEF";return t[e&15]},PropertyReader=function(e,t){this._onLine=e,this._onEOF=t,this._skipWhiteSpace=!0,this._isCommentLine=!1,this._isNewLine=!0,this._appendedLineBegin=!1,this._precedingBackslash=!1,this._skipLF=!1,this._line=""};PropertyReader.prototype._convert=function(e,t,n){var r,i="",s;while(e<t)r=n[e++],r==="\\"?(r=n[e++],r==="u"?i+=unicodeStringToCharacter(n[e++]+n[e++]+n[e++]+n[e++]):(r==="t"?r=" ":r==="r"?r="\r":r==="n"?r="\n":r==="f"&&(r="\f"),i+=r)):i+=r;return i},PropertyReader.prototype._readKeyValue=function(e){var t=!1,n=!1,r=e.length,i=r,s=0,o;while(s<r){o=e[s];if((o==="="||o===":")&&!n){i=s+1,t=!0;break}if((o===" "||o===" "||o=="\f")&&!n){i=s+1;break}o==="\\"?n=!n:n=!1,s++}while(i<r){o=e[i];if(o!==" "&&o!==" "&&o!=="\f"){if(!!t||o!=="="&&o!==":")break;t=!0}i++}this._onLine(this._convert(0,s,e),this._convert(i,r,e))},PropertyReader.prototype.eof=function(){this._line&&this._readKeyValue(this._line),this._onEOF()},PropertyReader.prototype.parse=function(e){if(this._isCommentLine){if(e==="\r"||e==="\n")this._isCommentLine=!1,this._isNewLine=!0,this._skipWhiteSpace=!0;return}if(this._skipLF){this._skipLF=!1;if(e==="\n")return}if(this._skipWhiteSpace){if(e===" "||e===" "||e==="\f")return;if(!this._appendedLineBegin&&(e==="\r"||e==="\n"))return;this._skipWhiteSpace=!1,this._appendedLineBegin=!1}if(this._isNewLine){this._isNewLine=!1;if(e==="#"||e==="!"){this._isCommentLine=!0;return}}e!=="\n"&&e!=="\r"?(this._line+=e,e==="\\"?this._precedingBackslash=!this._precedingBackslash:this._precedingBackslash=!1):this._precedingBackslash?(this._line=this._line.substring(0,this._line.length-1),this._skipWhiteSpace=!0,this._appendedLineBegin=!0,this._precedingBackslash=!1,e==="\r"&&(this._skipLF=!0)):(this._isNewLine=!0,this._skipWhiteSpace=!0,this._line&&this._readKeyValue(this._line),this._line="")};var Properties=function(){this._keys={}};Properties.COMMENT="#",Properties.SENSITIVITY=!0,Properties.SEPARATOR="=",Properties.prototype.get=function(e,t){var n=this._keys[e],r;return n!==undefined?r=n.value:r=t===undefined?null:t,r},Properties.prototype.keys=function(){return Object.keys(this._keys)},Properties.prototype.load=function(e,t){t&&(t=t.bind(this));var n=this,r=new PropertyReader(function(e,t){if(!Properties.SENSITIVITY){var r=e.toLowerCase();for(var i in n._keys)if(r===i.toLowerCase())return}n._keys[e]={value:t===""?null:t}},function(){t&&t(null)});(new BufferedReader(e,{encoding:"utf8"})).on("error",function(e){t&&t(e)}).on("character",function(e){r.parse(e)}).on("end",function(){r.eof()}).read()},Properties.prototype.remove=function(e){if(!Properties.SENSITIVITY){var t=e.toLowerCase();for(var n in this._keys)if(t===n.toLowerCase()){delete this._keys[n];break}}else delete this._keys[e];return this},Properties.prototype.set=function(e,t,n){if(!Properties.SENSITIVITY){var r=e.toLowerCase();for(var i in this._keys)if(r===i.toLowerCase())return this}return this._keys[e]={value:t?t.toString():t,comment:n},this};var convert=function(e,t,n){var r,i,s="";if(!e)return s;for(var o=0,u=e.length;o<u;o++){r=e[o],i=r.charCodeAt(0);if(i>61&&i<127){r==="\\"?(s+="\\",s+="\\"):s+=r;continue}switch(r){case" ":if(o===0||t)s+="\\";s+=" ";break;case" ":s+="\\",s+="t";break;case"\n":s+="\\",s+="n";break;case"\r":s+="\\",s+="r";break;case"\f":s+="\\",s+="f";break;case"=":case":":case"#":case"!":s+="\\",s+=r;break;default:i<33||i>126?s+=n?characterToUnicodeString(r):r:s+=r}}return s};Properties.prototype.store=function(e,t,n,r){var i=arguments.length,s;i===1?t=!1:i===2?(s=typeof t,s==="function"?(r=t,t=!1,n=null):s==="string"&&(n=t,t=!1)):i===3&&(s=typeof t,s==="boolean"&&typeof n=="function"?(r=n,n=null):s==="string"&&(r=n,n=t,t=!1)),r&&(r=r.bind(this));var o=new BufferedWriter(e,{encoding:"utf8"});o.on("error",function(e){r&&r(e)}),o.write(""),n&&o.write(Properties.COMMENT+n).newLine();var u;for(var a in this._keys)u=this._keys[a],u.comment&&o.write(Properties.COMMENT+u.comment).newLine(),o.write(convert(a,!0,t)+Properties.SEPARATOR+convert(u.value,!1,t)).newLine();o.close(function(){r&&r(null)})},module.exports=Properties;

@@ -10,3 +10,3 @@ <a name="start"></a>

Version: 0.1.9
Version: 0.1.10

@@ -13,0 +13,0 @@ A Java .properties file parser ported to node.js.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc