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

string

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

string - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

8

CHANGELOG.md

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

1.3.0 / 2013-03-18
------------------
* Added methods `between()`, `chompLeft()`, `chompRight()`, `ensureLeft()`, `ensureRight()`. (mgutz / #31)
* Removed support for Node v0.6. Added support for v0.10
* Modified `parseCSV` to allow for escape input. (seanodell #32)
* Allow `toCSV()` to have `null`.
* Fix `decodeHTMLEntities()` bug. #30
1.2.1 / 2013-02-09

@@ -2,0 +10,0 @@ ------------------

543

lib/string.js
/*
string.js - Copyright (C) 2012-2013, JP Richardson <jprichardson@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is furnished to
do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/

@@ -22,4 +8,6 @@

var VERSION = '1.2.1';
var VERSION = '1.3.0';
var ENTITIES = {};
function S(s) {

@@ -29,3 +17,3 @@ if (s !== null && s !== undefined) {

this.s = s;
else
else
this.s = s.toString();

@@ -53,2 +41,11 @@ } else {

var __sp = S.prototype = {
between: function(left, right) {
var s = this.s;
var startPos = s.indexOf(left);
var endPos = s.indexOf(right);
var start = startPos + left.length;
return new S(endPos > startPos ? s.slice(start, endPos) : "");
},
//# modified slightly from https://github.com/epeli/underscore.string

@@ -61,3 +58,3 @@ camelize: function() {

},
capitalize: function() {

@@ -71,2 +68,22 @@ return new S(this.s.substr(0, 1).toUpperCase() + this.s.substring(1).toLowerCase());

chompLeft: function(prefix) {
var s = this.s;
if (s.indexOf(prefix) === 0) {
s = s.slice(prefix.length);
return new S(s);
} else {
return this;
}
},
chompRight: function(suffix) {
if (this.endsWith(suffix)) {
var s = this.s;
s = s.slice(0, s.length - suffix.length);
return new S(s);
} else {
return this;
}
},
//#thanks Google

@@ -88,16 +105,26 @@ collapseWhitespace: function() {

decodeHtmlEntities: function(quote_style) { //from php.js
var symbol = "", entity = "", hash_map = {};
var tmp_str = this.s;
if (false === (hash_map = get_html_translation_table("HTML_ENTITIES", quote_style))) {
return false;
}
delete hash_map["&"];
hash_map["&"] = "&amp;";
for (symbol in hash_map) {
entity = hash_map[symbol];
tmp_str = tmp_str.split(entity).join(symbol);
}
tmp_str = tmp_str.split("&#039;").join("'");
return new S(tmp_str);
decodeHtmlEntities: function() { //https://github.com/substack/node-ent/blob/master/index.js
var s = this.s;
s = s.replace(/&#(\d+);?/g, function (_, code) {
return String.fromCharCode(code);
})
.replace(/&#[xX]([A-Fa-f0-9]+);?/g, function (_, hex) {
return String.fromCharCode(parseInt(hex, 16));
})
.replace(/&([^;\W]+;?)/g, function (m, e) {
var ee = e.replace(/;$/, '');
var target = ENTITIES[e] || (e.match(/;$/) && ENTITIES[ee]);
if (typeof target === 'number') {
return String.fromCharCode(target);
}
else if (typeof target === 'string') {
return target;
}
else {
return m;
}
})
return new S(s);
},

@@ -114,2 +141,20 @@

ensureLeft: function(prefix) {
var s = this.s;
if (s.indexOf(prefix) === 0) {
return this;
} else {
return new S(prefix + s);
}
},
ensureRight: function(suffix) {
var s = this.s;
if (this.endsWith(suffix)) {
return this;
} else {
return new S(s + suffix);
}
},
isAlpha: function() {

@@ -177,5 +222,5 @@ return !/[^a-z\xC0-\xFF]/.test(this.s.toLowerCase());

parseCSV: function(delimiter, qualifier) { //try to parse no matter what
parseCSV: function(delimiter, qualifier, escape) { //try to parse no matter what
delimiter = delimiter || ',';
escape = '\\'
escape = escape || '\\'
if (typeof qualifier == 'undefined')

@@ -213,3 +258,3 @@ qualifier = '"';

if (qualifier)
if (ca(i+1) !== qualifier)
if (ca(i+1) !== qualifier)
fieldBuffer.push(current);

@@ -275,6 +320,6 @@ break;

var matches = s.match(r) || [];
matches.forEach(function(match) {
var key = match.substring(opening.length, match.length - closing.length);//chop {{ and }}
if (values[key])
if (values[key])
s = s.replace(match, values[key]);

@@ -293,3 +338,3 @@ });

return s === 'true' || s === 'yes' || s === 'on';
} else
} else
return this.orig === true || this.orig === 1;

@@ -325,3 +370,3 @@ },

s = this.s.trimLeft();
else
else
s = this.s.replace(/(^\s*)/g, '');

@@ -384,3 +429,3 @@ return new S(s);

if (this.orig instanceof Array)
if (this.orig instanceof Array)
dataArray = this.orig;

@@ -402,8 +447,15 @@ else { //object

shouldQualify &= encloseNumbers;
if (shouldQualify)
buildString.push(qualifier);
var d = new S(dataArray[i]).replaceAll(qualifier, rep).s;
buildString.push(d);
if (dataArray[i] !== null) {
var d = new S(dataArray[i]).replaceAll(qualifier, rep).s;
buildString.push(d);
} else
buildString.push('')
if (shouldQualify)
buildString.push(qualifier);
if (delim)

@@ -466,3 +518,3 @@ buildString.push(delim);

}
})(name);
})(name);
}

@@ -526,3 +578,3 @@ }

try {
var type = typeof func.apply('teststring', []);
var type = typeof func.apply('teststring', []);
retObj[name] = type;

@@ -535,3 +587,3 @@ } catch (e) {}

function getNativeStringPropertyNames() {
var results = [];
var results = [];
if (Object.getOwnPropertyNames) {

@@ -547,3 +599,3 @@ results = Object.getOwnPropertyNames(__nsp);

stringNames[name] = name;
for (var name in Object.prototype)

@@ -570,2 +622,3 @@ delete stringNames[name];

Export.TMPL_CLOSE = '}}';
Export.ENTITIES = ENTITIES;

@@ -620,149 +673,259 @@

//from PHP.js
function get_html_translation_table (table, quote_style) {
var entities = {},
hash_map = {},
decimal;
var constMappingTable = {},
constMappingQuoteStyle = {};
var useTable = {},
useQuoteStyle = {};
ENTITIES = {
"amp" : "&",
"gt" : ">",
"lt" : "<",
"quot" : "\"",
"apos" : "'",
"AElig" : 198,
"Aacute" : 193,
"Acirc" : 194,
"Agrave" : 192,
"Aring" : 197,
"Atilde" : 195,
"Auml" : 196,
"Ccedil" : 199,
"ETH" : 208,
"Eacute" : 201,
"Ecirc" : 202,
"Egrave" : 200,
"Euml" : 203,
"Iacute" : 205,
"Icirc" : 206,
"Igrave" : 204,
"Iuml" : 207,
"Ntilde" : 209,
"Oacute" : 211,
"Ocirc" : 212,
"Ograve" : 210,
"Oslash" : 216,
"Otilde" : 213,
"Ouml" : 214,
"THORN" : 222,
"Uacute" : 218,
"Ucirc" : 219,
"Ugrave" : 217,
"Uuml" : 220,
"Yacute" : 221,
"aacute" : 225,
"acirc" : 226,
"aelig" : 230,
"agrave" : 224,
"aring" : 229,
"atilde" : 227,
"auml" : 228,
"ccedil" : 231,
"eacute" : 233,
"ecirc" : 234,
"egrave" : 232,
"eth" : 240,
"euml" : 235,
"iacute" : 237,
"icirc" : 238,
"igrave" : 236,
"iuml" : 239,
"ntilde" : 241,
"oacute" : 243,
"ocirc" : 244,
"ograve" : 242,
"oslash" : 248,
"otilde" : 245,
"ouml" : 246,
"szlig" : 223,
"thorn" : 254,
"uacute" : 250,
"ucirc" : 251,
"ugrave" : 249,
"uuml" : 252,
"yacute" : 253,
"yuml" : 255,
"copy" : 169,
"reg" : 174,
"nbsp" : 160,
"iexcl" : 161,
"cent" : 162,
"pound" : 163,
"curren" : 164,
"yen" : 165,
"brvbar" : 166,
"sect" : 167,
"uml" : 168,
"ordf" : 170,
"laquo" : 171,
"not" : 172,
"shy" : 173,
"macr" : 175,
"deg" : 176,
"plusmn" : 177,
"sup1" : 185,
"sup2" : 178,
"sup3" : 179,
"acute" : 180,
"micro" : 181,
"para" : 182,
"middot" : 183,
"cedil" : 184,
"ordm" : 186,
"raquo" : 187,
"frac14" : 188,
"frac12" : 189,
"frac34" : 190,
"iquest" : 191,
"times" : 215,
"divide" : 247,
"OElig;" : 338,
"oelig;" : 339,
"Scaron;" : 352,
"scaron;" : 353,
"Yuml;" : 376,
"fnof;" : 402,
"circ;" : 710,
"tilde;" : 732,
"Alpha;" : 913,
"Beta;" : 914,
"Gamma;" : 915,
"Delta;" : 916,
"Epsilon;" : 917,
"Zeta;" : 918,
"Eta;" : 919,
"Theta;" : 920,
"Iota;" : 921,
"Kappa;" : 922,
"Lambda;" : 923,
"Mu;" : 924,
"Nu;" : 925,
"Xi;" : 926,
"Omicron;" : 927,
"Pi;" : 928,
"Rho;" : 929,
"Sigma;" : 931,
"Tau;" : 932,
"Upsilon;" : 933,
"Phi;" : 934,
"Chi;" : 935,
"Psi;" : 936,
"Omega;" : 937,
"alpha;" : 945,
"beta;" : 946,
"gamma;" : 947,
"delta;" : 948,
"epsilon;" : 949,
"zeta;" : 950,
"eta;" : 951,
"theta;" : 952,
"iota;" : 953,
"kappa;" : 954,
"lambda;" : 955,
"mu;" : 956,
"nu;" : 957,
"xi;" : 958,
"omicron;" : 959,
"pi;" : 960,
"rho;" : 961,
"sigmaf;" : 962,
"sigma;" : 963,
"tau;" : 964,
"upsilon;" : 965,
"phi;" : 966,
"chi;" : 967,
"psi;" : 968,
"omega;" : 969,
"thetasym;" : 977,
"upsih;" : 978,
"piv;" : 982,
"ensp;" : 8194,
"emsp;" : 8195,
"thinsp;" : 8201,
"zwnj;" : 8204,
"zwj;" : 8205,
"lrm;" : 8206,
"rlm;" : 8207,
"ndash;" : 8211,
"mdash;" : 8212,
"lsquo;" : 8216,
"rsquo;" : 8217,
"sbquo;" : 8218,
"ldquo;" : 8220,
"rdquo;" : 8221,
"bdquo;" : 8222,
"dagger;" : 8224,
"Dagger;" : 8225,
"bull;" : 8226,
"hellip;" : 8230,
"permil;" : 8240,
"prime;" : 8242,
"Prime;" : 8243,
"lsaquo;" : 8249,
"rsaquo;" : 8250,
"oline;" : 8254,
"frasl;" : 8260,
"euro;" : 8364,
"image;" : 8465,
"weierp;" : 8472,
"real;" : 8476,
"trade;" : 8482,
"alefsym;" : 8501,
"larr;" : 8592,
"uarr;" : 8593,
"rarr;" : 8594,
"darr;" : 8595,
"harr;" : 8596,
"crarr;" : 8629,
"lArr;" : 8656,
"uArr;" : 8657,
"rArr;" : 8658,
"dArr;" : 8659,
"hArr;" : 8660,
"forall;" : 8704,
"part;" : 8706,
"exist;" : 8707,
"empty;" : 8709,
"nabla;" : 8711,
"isin;" : 8712,
"notin;" : 8713,
"ni;" : 8715,
"prod;" : 8719,
"sum;" : 8721,
"minus;" : 8722,
"lowast;" : 8727,
"radic;" : 8730,
"prop;" : 8733,
"infin;" : 8734,
"ang;" : 8736,
"and;" : 8743,
"or;" : 8744,
"cap;" : 8745,
"cup;" : 8746,
"int;" : 8747,
"there4;" : 8756,
"sim;" : 8764,
"cong;" : 8773,
"asymp;" : 8776,
"ne;" : 8800,
"equiv;" : 8801,
"le;" : 8804,
"ge;" : 8805,
"sub;" : 8834,
"sup;" : 8835,
"nsub;" : 8836,
"sube;" : 8838,
"supe;" : 8839,
"oplus;" : 8853,
"otimes;" : 8855,
"perp;" : 8869,
"sdot;" : 8901,
"lceil;" : 8968,
"rceil;" : 8969,
"lfloor;" : 8970,
"rfloor;" : 8971,
"lang;" : 9001,
"rang;" : 9002,
"loz;" : 9674,
"spades;" : 9824,
"clubs;" : 9827,
"hearts;" : 9829,
"diams;" : 9830
}
// Translate arguments
constMappingTable[0] = 'HTML_SPECIALCHARS';
constMappingTable[1] = 'HTML_ENTITIES';
constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
constMappingQuoteStyle[2] = 'ENT_COMPAT';
constMappingQuoteStyle[3] = 'ENT_QUOTES';
useTable = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS';
useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT';
if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') {
throw new Error("Table: " + useTable + ' not supported');
// return false;
}
entities['38'] = '&amp;';
if (useTable === 'HTML_ENTITIES') {
entities['160'] = '&nbsp;';
entities['161'] = '&iexcl;';
entities['162'] = '&cent;';
entities['163'] = '&pound;';
entities['164'] = '&curren;';
entities['165'] = '&yen;';
entities['166'] = '&brvbar;';
entities['167'] = '&sect;';
entities['168'] = '&uml;';
entities['169'] = '&copy;';
entities['170'] = '&ordf;';
entities['171'] = '&laquo;';
entities['172'] = '&not;';
entities['173'] = '&shy;';
entities['174'] = '&reg;';
entities['175'] = '&macr;';
entities['176'] = '&deg;';
entities['177'] = '&plusmn;';
entities['178'] = '&sup2;';
entities['179'] = '&sup3;';
entities['180'] = '&acute;';
entities['181'] = '&micro;';
entities['182'] = '&para;';
entities['183'] = '&middot;';
entities['184'] = '&cedil;';
entities['185'] = '&sup1;';
entities['186'] = '&ordm;';
entities['187'] = '&raquo;';
entities['188'] = '&frac14;';
entities['189'] = '&frac12;';
entities['190'] = '&frac34;';
entities['191'] = '&iquest;';
entities['192'] = '&Agrave;';
entities['193'] = '&Aacute;';
entities['194'] = '&Acirc;';
entities['195'] = '&Atilde;';
entities['196'] = '&Auml;';
entities['197'] = '&Aring;';
entities['198'] = '&AElig;';
entities['199'] = '&Ccedil;';
entities['200'] = '&Egrave;';
entities['201'] = '&Eacute;';
entities['202'] = '&Ecirc;';
entities['203'] = '&Euml;';
entities['204'] = '&Igrave;';
entities['205'] = '&Iacute;';
entities['206'] = '&Icirc;';
entities['207'] = '&Iuml;';
entities['208'] = '&ETH;';
entities['209'] = '&Ntilde;';
entities['210'] = '&Ograve;';
entities['211'] = '&Oacute;';
entities['212'] = '&Ocirc;';
entities['213'] = '&Otilde;';
entities['214'] = '&Ouml;';
entities['215'] = '&times;';
entities['216'] = '&Oslash;';
entities['217'] = '&Ugrave;';
entities['218'] = '&Uacute;';
entities['219'] = '&Ucirc;';
entities['220'] = '&Uuml;';
entities['221'] = '&Yacute;';
entities['222'] = '&THORN;';
entities['223'] = '&szlig;';
entities['224'] = '&agrave;';
entities['225'] = '&aacute;';
entities['226'] = '&acirc;';
entities['227'] = '&atilde;';
entities['228'] = '&auml;';
entities['229'] = '&aring;';
entities['230'] = '&aelig;';
entities['231'] = '&ccedil;';
entities['232'] = '&egrave;';
entities['233'] = '&eacute;';
entities['234'] = '&ecirc;';
entities['235'] = '&euml;';
entities['236'] = '&igrave;';
entities['237'] = '&iacute;';
entities['238'] = '&icirc;';
entities['239'] = '&iuml;';
entities['240'] = '&eth;';
entities['241'] = '&ntilde;';
entities['242'] = '&ograve;';
entities['243'] = '&oacute;';
entities['244'] = '&ocirc;';
entities['245'] = '&otilde;';
entities['246'] = '&ouml;';
entities['247'] = '&divide;';
entities['248'] = '&oslash;';
entities['249'] = '&ugrave;';
entities['250'] = '&uacute;';
entities['251'] = '&ucirc;';
entities['252'] = '&uuml;';
entities['253'] = '&yacute;';
entities['254'] = '&thorn;';
entities['255'] = '&yuml;';
}
if (useQuoteStyle !== 'ENT_NOQUOTES') {
entities['34'] = '&quot;';
}
if (useQuoteStyle === 'ENT_QUOTES') {
entities['39'] = '&#39;';
}
entities['60'] = '&lt;';
entities['62'] = '&gt;';
// ascii decimals to real symbols
for (decimal in entities) {
if (entities.hasOwnProperty(decimal)) {
hash_map[String.fromCharCode(decimal)] = entities[decimal];
}
}
return hash_map;
};
}).call(this);
/*
string.js - Copyright (C) 2012-2013, JP Richardson <jprichardson@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is furnished to
do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
!function(){"use strict";var VERSION="1.2.1";function S(s){if(s!==null&&s!==undefined){if(typeof s==="string")this.s=s;else this.s=s.toString()}else{this.s=s}this.orig=s;if(s!==null&&s!==undefined){if(this.__defineGetter__){this.__defineGetter__("length",function(){return this.s.length})}else{this.length=s.length}}else{this.length=-1}}var __nsp=String.prototype;var __sp=S.prototype={camelize:function(){var s=this.trim().s.replace(/(\-|_|\s)+(.)?/g,function(mathc,sep,c){return c?c.toUpperCase():""});return new S(s)},capitalize:function(){return new S(this.s.substr(0,1).toUpperCase()+this.s.substring(1).toLowerCase())},charAt:function(index){return this.s.charAt(index)},collapseWhitespace:function(){var s=this.s.replace(/[\s\xa0]+/g," ").replace(/^\s+|\s+$/g,"");return new S(s)},contains:function(ss){return this.s.indexOf(ss)>=0},dasherize:function(){var s=this.trim().s.replace(/[_\s]+/g,"-").replace(/([A-Z])/g,"-$1").replace(/-+/g,"-").toLowerCase();return new S(s)},decodeHtmlEntities:function(quote_style){var symbol="",entity="",hash_map={};var tmp_str=this.s;if(false===(hash_map=get_html_translation_table("HTML_ENTITIES",quote_style))){return false}delete hash_map["&"];hash_map["&"]="&amp;";for(symbol in hash_map){entity=hash_map[symbol];tmp_str=tmp_str.split(entity).join(symbol)}tmp_str=tmp_str.split("&#039;").join("'");return new S(tmp_str)},endsWith:function(suffix){var l=this.s.length-suffix.length;return l>=0&&this.s.indexOf(suffix,l)===l},escapeHTML:function(){return new S(this.s.replace(/[&<>"']/g,function(m){return"&"+reversedEscapeChars[m]+";"}))},isAlpha:function(){return!/[^a-z\xC0-\xFF]/.test(this.s.toLowerCase())},isAlphaNumeric:function(){return!/[^0-9a-z\xC0-\xFF]/.test(this.s.toLowerCase())},isEmpty:function(){return this.s===null||this.s===undefined?true:/^[\s\xa0]*$/.test(this.s)},isLower:function(){return this.isAlpha()&&this.s.toLowerCase()===this.s},isNumeric:function(){return!/[^0-9]/.test(this.s)},isUpper:function(){return this.isAlpha()&&this.s.toUpperCase()===this.s},left:function(N){if(N>=0){var s=this.s.substr(0,N);return new S(s)}else{return this.right(-N)}},lines:function(){var lines=this.s.split("\n");for(var i=0;i<lines.length;++i){lines[i]=lines[i].replace(/(^\s*|\s*$)/g,"")}return lines},pad:function(len,ch){ch=ch||" ";if(this.s.length>=len)return new S(this.s);len=len-this.s.length;var left=Array(Math.ceil(len/2)+1).join(ch);var right=Array(Math.floor(len/2)+1).join(ch);return new S(left+this.s+right)},padLeft:function(len,ch){ch=ch||" ";if(this.s.length>=len)return new S(this.s);return new S(Array(len-this.s.length+1).join(ch)+this.s)},padRight:function(len,ch){ch=ch||" ";if(this.s.length>=len)return new S(this.s);return new S(this.s+Array(len-this.s.length+1).join(ch))},parseCSV:function(delimiter,qualifier){delimiter=delimiter||",";escape="\\";if(typeof qualifier=="undefined")qualifier='"';var i=0,fieldBuffer=[],fields=[],len=this.s.length,inField=false,self=this;var ca=function(i){return self.s.charAt(i)};if(!qualifier)inField=true;while(i<len){var current=ca(i);switch(current){case qualifier:if(!inField){inField=true}else{if(ca(i-1)===escape)fieldBuffer.push(current);else inField=false}break;case delimiter:if(inField&&qualifier)fieldBuffer.push(current);else{fields.push(fieldBuffer.join(""));fieldBuffer.length=0}break;case escape:if(qualifier)if(ca(i+1)!==qualifier)fieldBuffer.push(current);break;default:if(inField)fieldBuffer.push(current);break}i+=1}fields.push(fieldBuffer.join(""));return fields},replaceAll:function(ss,r){var s=this.s.split(ss).join(r);return new S(s)},right:function(N){if(N>=0){var s=this.s.substr(this.s.length-N,N);return new S(s)}else{return this.left(-N)}},slugify:function(){var sl=new S(this.s.replace(/[^\w\s-]/g,"").toLowerCase()).dasherize().s;if(sl.charAt(0)==="-")sl=sl.substr(1);return new S(sl)},startsWith:function(prefix){return this.s.lastIndexOf(prefix,0)===0},stripPunctuation:function(){return new S(this.s.replace(/[^\w\s]|_/g,"").replace(/\s+/g," "))},stripTags:function(){var s=this.s,args=arguments.length>0?arguments:[""];multiArgs(args,function(tag){s=s.replace(RegExp("</?"+tag+"[^<>]*>","gi"),"")});return new S(s)},template:function(values,opening,closing){var s=this.s;var opening=opening||Export.TMPL_OPEN;var closing=closing||Export.TMPL_CLOSE;var r=new RegExp(opening+"(.+?)"+closing,"g");var matches=s.match(r)||[];matches.forEach(function(match){var key=match.substring(opening.length,match.length-closing.length);if(values[key])s=s.replace(match,values[key])});return new S(s)},times:function(n){return new S(new Array(n+1).join(this.s))},toBoolean:function(){if(typeof this.orig==="string"){var s=this.s.toLowerCase();return s==="true"||s==="yes"||s==="on"}else return this.orig===true||this.orig===1},toFloat:function(precision){var num=parseFloat(this.s,10);if(precision)return parseFloat(num.toFixed(precision));else return num},toInt:function(){return/^\s*-?0x/i.test(this.s)?parseInt(this.s,16):parseInt(this.s,10)},trim:function(){var s;if(typeof String.prototype.trim==="undefined"){s=this.s.replace(/(^\s*|\s*$)/g,"")}else{s=this.s.trim()}return new S(s)},trimLeft:function(){var s;if(__nsp.trimLeft)s=this.s.trimLeft();else s=this.s.replace(/(^\s*)/g,"");return new S(s)},trimRight:function(){var s;if(__nsp.trimRight)s=this.s.trimRight();else s=this.s.replace(/\s+$/,"");return new S(s)},truncate:function(length,pruneStr){var str=this.s;length=~~length;pruneStr=pruneStr||"...";if(str.length<=length)return new S(str);var tmpl=function(c){return c.toUpperCase()!==c.toLowerCase()?"A":" "},template=str.slice(0,length+1).replace(/.(?=\W*\w*$)/g,tmpl);if(template.slice(template.length-2).match(/\w\w/))template=template.replace(/\s*\S+$/,"");else template=new S(template.slice(0,template.length-1)).trimRight().s;return(template+pruneStr).length>str.length?new S(str):new S(str.slice(0,template.length)+pruneStr)},toCSV:function(){var delim=",",qualifier='"',escapeChar="\\",encloseNumbers=true,keys=false;var dataArray=[];function hasVal(it){return it!==null&&it!==""}if(typeof arguments[0]==="object"){delim=arguments[0].delimiter||delim;delim=arguments[0].separator||delim;qualifier=arguments[0].qualifier||qualifier;encloseNumbers=!!arguments[0].encloseNumbers;escapeChar=arguments[0].escapeChar||escapeChar;keys=!!arguments[0].keys}else if(typeof arguments[0]==="string"){delim=arguments[0]}if(typeof arguments[1]==="string")qualifier=arguments[1];if(arguments[1]===null)qualifier=null;if(this.orig instanceof Array)dataArray=this.orig;else{for(var key in this.orig)if(this.orig.hasOwnProperty(key))if(keys)dataArray.push(key);else dataArray.push(this.orig[key])}var rep=escapeChar+qualifier;var buildString=[];for(var i=0;i<dataArray.length;++i){var shouldQualify=hasVal(qualifier);if(typeof dataArray[i]=="number")shouldQualify&=encloseNumbers;if(shouldQualify)buildString.push(qualifier);var d=new S(dataArray[i]).replaceAll(qualifier,rep).s;buildString.push(d);if(shouldQualify)buildString.push(qualifier);if(delim)buildString.push(delim)}buildString.length=buildString.length-1;return new S(buildString.join(""))},toString:function(){return this.s},underscore:function(){var s=this.trim().s.replace(/([a-z\d])([A-Z]+)/g,"$1_$2").replace(/[-\s]+/g,"_").toLowerCase();if(new S(this.s.charAt(0)).isUpper()){s="_"+s}return new S(s)},unescapeHTML:function(){return new S(this.s.replace(/\&([^;]+);/g,function(entity,entityCode){var match;if(entityCode in escapeChars){return escapeChars[entityCode]}else if(match=entityCode.match(/^#x([\da-fA-F]+)$/)){return String.fromCharCode(parseInt(match[1],16))}else if(match=entityCode.match(/^#(\d+)$/)){return String.fromCharCode(~~match[1])}else{return entity}}))},valueOf:function(){return this.s.valueOf()}};var methodsAdded=[];function extendPrototype(){for(var name in __sp){(function(name){var func=__sp[name];if(!__nsp.hasOwnProperty(name)){methodsAdded.push(name);__nsp[name]=function(){String.prototype.s=this;return func.apply(this,arguments)}}})(name)}}function restorePrototype(){for(var i=0;i<methodsAdded.length;++i)delete String.prototype[methodsAdded[i]];methodsAdded.length=0}var nativeProperties=getNativeStringProperties();for(var name in nativeProperties){(function(name){var stringProp=__nsp[name];if(typeof stringProp=="function"){if(!__sp[name]){if(nativeProperties[name]==="string"){__sp[name]=function(){return new S(stringProp.apply(this,arguments))}}else{__sp[name]=stringProp}}}})(name)}__sp.repeat=__sp.times;__sp.include=__sp.contains;__sp.toInteger=__sp.toInt;__sp.toBool=__sp.toBoolean;__sp.decodeHTMLEntities=__sp.decodeHtmlEntities;function getNativeStringProperties(){var names=getNativeStringPropertyNames();var retObj={};for(var i=0;i<names.length;++i){var name=names[i];var func=__nsp[name];try{var type=typeof func.apply("teststring",[]);retObj[name]=type}catch(e){}}return retObj}function getNativeStringPropertyNames(){var results=[];if(Object.getOwnPropertyNames){results=Object.getOwnPropertyNames(__nsp);results.splice(results.indexOf("valueOf"),1);results.splice(results.indexOf("toString"),1);return results}else{var stringNames={};var objectNames=[];for(var name in String.prototype)stringNames[name]=name;for(var name in Object.prototype)delete stringNames[name];for(var name in stringNames){results.push(name)}return results}}function Export(str){return new S(str)}Export.extendPrototype=extendPrototype;Export.restorePrototype=restorePrototype;Export.VERSION=VERSION;Export.TMPL_OPEN="{{";Export.TMPL_CLOSE="}}";if(typeof module!=="undefined"&&typeof module.exports!=="undefined"){module.exports=Export}else{if(typeof define==="function"&&define.amd){define([],function(){return Export})}else{window.S=Export}}function multiArgs(args,fn){var result=[],i;for(i=0;i<args.length;i++){result.push(args[i]);if(fn)fn.call(args,args[i],i)}return result}var escapeChars={lt:"<",gt:">",quot:'"',apos:"'",amp:"&"};var reversedEscapeChars={};for(var key in escapeChars){reversedEscapeChars[escapeChars[key]]=key}function get_html_translation_table(table,quote_style){var entities={},hash_map={},decimal;var constMappingTable={},constMappingQuoteStyle={};var useTable={},useQuoteStyle={};constMappingTable[0]="HTML_SPECIALCHARS";constMappingTable[1]="HTML_ENTITIES";constMappingQuoteStyle[0]="ENT_NOQUOTES";constMappingQuoteStyle[2]="ENT_COMPAT";constMappingQuoteStyle[3]="ENT_QUOTES";useTable=!isNaN(table)?constMappingTable[table]:table?table.toUpperCase():"HTML_SPECIALCHARS";useQuoteStyle=!isNaN(quote_style)?constMappingQuoteStyle[quote_style]:quote_style?quote_style.toUpperCase():"ENT_COMPAT";if(useTable!=="HTML_SPECIALCHARS"&&useTable!=="HTML_ENTITIES"){throw new Error("Table: "+useTable+" not supported")}entities["38"]="&amp;";if(useTable==="HTML_ENTITIES"){entities["160"]="&nbsp;";entities["161"]="&iexcl;";entities["162"]="&cent;";entities["163"]="&pound;";entities["164"]="&curren;";entities["165"]="&yen;";entities["166"]="&brvbar;";entities["167"]="&sect;";entities["168"]="&uml;";entities["169"]="&copy;";entities["170"]="&ordf;";entities["171"]="&laquo;";entities["172"]="&not;";entities["173"]="&shy;";entities["174"]="&reg;";entities["175"]="&macr;";entities["176"]="&deg;";entities["177"]="&plusmn;";entities["178"]="&sup2;";entities["179"]="&sup3;";entities["180"]="&acute;";entities["181"]="&micro;";entities["182"]="&para;";entities["183"]="&middot;";entities["184"]="&cedil;";entities["185"]="&sup1;";entities["186"]="&ordm;";entities["187"]="&raquo;";entities["188"]="&frac14;";entities["189"]="&frac12;";entities["190"]="&frac34;";entities["191"]="&iquest;";entities["192"]="&Agrave;";entities["193"]="&Aacute;";entities["194"]="&Acirc;";entities["195"]="&Atilde;";entities["196"]="&Auml;";entities["197"]="&Aring;";entities["198"]="&AElig;";entities["199"]="&Ccedil;";entities["200"]="&Egrave;";entities["201"]="&Eacute;";entities["202"]="&Ecirc;";entities["203"]="&Euml;";entities["204"]="&Igrave;";entities["205"]="&Iacute;";entities["206"]="&Icirc;";entities["207"]="&Iuml;";entities["208"]="&ETH;";entities["209"]="&Ntilde;";entities["210"]="&Ograve;";entities["211"]="&Oacute;";entities["212"]="&Ocirc;";entities["213"]="&Otilde;";entities["214"]="&Ouml;";entities["215"]="&times;";entities["216"]="&Oslash;";entities["217"]="&Ugrave;";entities["218"]="&Uacute;";entities["219"]="&Ucirc;";entities["220"]="&Uuml;";entities["221"]="&Yacute;";entities["222"]="&THORN;";entities["223"]="&szlig;";entities["224"]="&agrave;";entities["225"]="&aacute;";entities["226"]="&acirc;";entities["227"]="&atilde;";entities["228"]="&auml;";entities["229"]="&aring;";entities["230"]="&aelig;";entities["231"]="&ccedil;";entities["232"]="&egrave;";entities["233"]="&eacute;";entities["234"]="&ecirc;";entities["235"]="&euml;";entities["236"]="&igrave;";entities["237"]="&iacute;";entities["238"]="&icirc;";entities["239"]="&iuml;";entities["240"]="&eth;";entities["241"]="&ntilde;";entities["242"]="&ograve;";entities["243"]="&oacute;";entities["244"]="&ocirc;";entities["245"]="&otilde;";entities["246"]="&ouml;";entities["247"]="&divide;";entities["248"]="&oslash;";entities["249"]="&ugrave;";entities["250"]="&uacute;";entities["251"]="&ucirc;";entities["252"]="&uuml;";entities["253"]="&yacute;";entities["254"]="&thorn;";entities["255"]="&yuml;"}if(useQuoteStyle!=="ENT_NOQUOTES"){entities["34"]="&quot;"}if(useQuoteStyle==="ENT_QUOTES"){entities["39"]="&#39;"}entities["60"]="&lt;";entities["62"]="&gt;";for(decimal in entities){if(entities.hasOwnProperty(decimal)){hash_map[String.fromCharCode(decimal)]=entities[decimal]}}return hash_map}}.call(this);
*/!function(){"use strict";function n(e){e!==null&&e!==undefined?typeof e=="string"?this.s=e:this.s=e.toString():this.s=e,this.orig=e,e!==null&&e!==undefined?this.__defineGetter__?this.__defineGetter__("length",function(){return this.s.length}):this.length=e.length:this.length=-1}function o(){for(var e in i)(function(e){var t=i[e];r.hasOwnProperty(e)||(s.push(e),r[e]=function(){return String.prototype.s=this,t.apply(this,arguments)})})(e)}function u(){for(var e=0;e<s.length;++e)delete String.prototype[s[e]];s.length=0}function l(){var e=c(),t={};for(var n=0;n<e.length;++n){var i=e[n],s=r[i];try{var o=typeof s.apply("teststring",[]);t[i]=o}catch(u){}}return t}function c(){var e=[];if(Object.getOwnPropertyNames)return e=Object.getOwnPropertyNames(r),e.splice(e.indexOf("valueOf"),1),e.splice(e.indexOf("toString"),1),e;var t={},n=[];for(var i in String.prototype)t[i]=i;for(var i in Object.prototype)delete t[i];for(var i in t)e.push(i);return e}function h(e){return new n(e)}function p(e,t){var n=[],r;for(r=0;r<e.length;r++)n.push(e[r]),t&&t.call(e,e[r],r);return n}var e="1.3.0",t={},r=String.prototype,i=n.prototype={between:function(e,t){var r=this.s,i=r.indexOf(e),s=r.indexOf(t),o=i+e.length;return new n(s>i?r.slice(o,s):"")},camelize:function(){var e=this.trim().s.replace(/(\-|_|\s)+(.)?/g,function(e,t,n){return n?n.toUpperCase():""});return new n(e)},capitalize:function(){return new n(this.s.substr(0,1).toUpperCase()+this.s.substring(1).toLowerCase())},charAt:function(e){return this.s.charAt(e)},chompLeft:function(e){var t=this.s;return t.indexOf(e)===0?(t=t.slice(e.length),new n(t)):this},chompRight:function(e){if(this.endsWith(e)){var t=this.s;return t=t.slice(0,t.length-e.length),new n(t)}return this},collapseWhitespace:function(){var e=this.s.replace(/[\s\xa0]+/g," ").replace(/^\s+|\s+$/g,"");return new n(e)},contains:function(e){return this.s.indexOf(e)>=0},dasherize:function(){var e=this.trim().s.replace(/[_\s]+/g,"-").replace(/([A-Z])/g,"-$1").replace(/-+/g,"-").toLowerCase();return new n(e)},decodeHtmlEntities:function(){var e=this.s;return e=e.replace(/&#(\d+);?/g,function(e,t){return String.fromCharCode(t)}).replace(/&#[xX]([A-Fa-f0-9]+);?/g,function(e,t){return String.fromCharCode(parseInt(t,16))}).replace(/&([^;\W]+;?)/g,function(e,n){var r=n.replace(/;$/,""),i=t[n]||n.match(/;$/)&&t[r];return typeof i=="number"?String.fromCharCode(i):typeof i=="string"?i:e}),new n(e)},endsWith:function(e){var t=this.s.length-e.length;return t>=0&&this.s.indexOf(e,t)===t},escapeHTML:function(){return new n(this.s.replace(/[&<>"']/g,function(e){return"&"+v[e]+";"}))},ensureLeft:function(e){var t=this.s;return t.indexOf(e)===0?this:new n(e+t)},ensureRight:function(e){var t=this.s;return this.endsWith(e)?this:new n(t+e)},isAlpha:function(){return!/[^a-z\xC0-\xFF]/.test(this.s.toLowerCase())},isAlphaNumeric:function(){return!/[^0-9a-z\xC0-\xFF]/.test(this.s.toLowerCase())},isEmpty:function(){return this.s===null||this.s===undefined?!0:/^[\s\xa0]*$/.test(this.s)},isLower:function(){return this.isAlpha()&&this.s.toLowerCase()===this.s},isNumeric:function(){return!/[^0-9]/.test(this.s)},isUpper:function(){return this.isAlpha()&&this.s.toUpperCase()===this.s},left:function(e){if(e>=0){var t=this.s.substr(0,e);return new n(t)}return this.right(-e)},lines:function(){var e=this.s.split("\n");for(var t=0;t<e.length;++t)e[t]=e[t].replace(/(^\s*|\s*$)/g,"");return e},pad:function(e,t){t=t||" ";if(this.s.length>=e)return new n(this.s);e-=this.s.length;var r=Array(Math.ceil(e/2)+1).join(t),i=Array(Math.floor(e/2)+1).join(t);return new n(r+this.s+i)},padLeft:function(e,t){return t=t||" ",this.s.length>=e?new n(this.s):new n(Array(e-this.s.length+1).join(t)+this.s)},padRight:function(e,t){return t=t||" ",this.s.length>=e?new n(this.s):new n(this.s+Array(e-this.s.length+1).join(t))},parseCSV:function(e,t,n){e=e||",",n=n||"\\",typeof t=="undefined"&&(t='"');var r=0,i=[],s=[],o=this.s.length,u=!1,a=this,f=function(e){return a.s.charAt(e)};t||(u=!0);while(r<o){var l=f(r);switch(l){case t:u?f(r-1)===n?i.push(l):u=!1:u=!0;break;case e:u&&t?i.push(l):(s.push(i.join("")),i.length=0);break;case n:t&&f(r+1)!==t&&i.push(l);break;default:u&&i.push(l)}r+=1}return s.push(i.join("")),s},replaceAll:function(e,t){var r=this.s.split(e).join(t);return new n(r)},right:function(e){if(e>=0){var t=this.s.substr(this.s.length-e,e);return new n(t)}return this.left(-e)},slugify:function(){var e=(new n(this.s.replace(/[^\w\s-]/g,"").toLowerCase())).dasherize().s;return e.charAt(0)==="-"&&(e=e.substr(1)),new n(e)},startsWith:function(e){return this.s.lastIndexOf(e,0)===0},stripPunctuation:function(){return new n(this.s.replace(/[^\w\s]|_/g,"").replace(/\s+/g," "))},stripTags:function(){var e=this.s,t=arguments.length>0?arguments:[""];return p(t,function(t){e=e.replace(RegExp("</?"+t+"[^<>]*>","gi"),"")}),new n(e)},template:function(e,t,r){var i=this.s,t=t||h.TMPL_OPEN,r=r||h.TMPL_CLOSE,s=new RegExp(t+"(.+?)"+r,"g"),o=i.match(s)||[];return o.forEach(function(n){var s=n.substring(t.length,n.length-r.length);e[s]&&(i=i.replace(n,e[s]))}),new n(i)},times:function(e){return new n((new Array(e+1)).join(this.s))},toBoolean:function(){if(typeof this.orig=="string"){var e=this.s.toLowerCase();return e==="true"||e==="yes"||e==="on"}return this.orig===!0||this.orig===1},toFloat:function(e){var t=parseFloat(this.s,10);return e?parseFloat(t.toFixed(e)):t},toInt:function(){return/^\s*-?0x/i.test(this.s)?parseInt(this.s,16):parseInt(this.s,10)},trim:function(){var e;return typeof String.prototype.trim=="undefined"?e=this.s.replace(/(^\s*|\s*$)/g,""):e=this.s.trim(),new n(e)},trimLeft:function(){var e;return r.trimLeft?e=this.s.trimLeft():e=this.s.replace(/(^\s*)/g,""),new n(e)},trimRight:function(){var e;return r.trimRight?e=this.s.trimRight():e=this.s.replace(/\s+$/,""),new n(e)},truncate:function(e,t){var r=this.s;e=~~e,t=t||"...";if(r.length<=e)return new n(r);var i=function(e){return e.toUpperCase()!==e.toLowerCase()?"A":" "},s=r.slice(0,e+1).replace(/.(?=\W*\w*$)/g,i);return s.slice(s.length-2).match(/\w\w/)?s=s.replace(/\s*\S+$/,""):s=(new n(s.slice(0,s.length-1))).trimRight().s,(s+t).length>r.length?new n(r):new n(r.slice(0,s.length)+t)},toCSV:function(){function u(e){return e!==null&&e!==""}var e=",",t='"',r="\\",i=!0,s=!1,o=[];typeof arguments[0]=="object"?(e=arguments[0].delimiter||e,e=arguments[0].separator||e,t=arguments[0].qualifier||t,i=!!arguments[0].encloseNumbers,r=arguments[0].escapeChar||r,s=!!arguments[0].keys):typeof arguments[0]=="string"&&(e=arguments[0]),typeof arguments[1]=="string"&&(t=arguments[1]),arguments[1]===null&&(t=null);if(this.orig instanceof Array)o=this.orig;else for(var a in this.orig)this.orig.hasOwnProperty(a)&&(s?o.push(a):o.push(this.orig[a]));var f=r+t,l=[];for(var c=0;c<o.length;++c){var h=u(t);typeof o[c]=="number"&&(h&=i),h&&l.push(t);if(o[c]!==null){var p=(new n(o[c])).replaceAll(t,f).s;l.push(p)}else l.push("");h&&l.push(t),e&&l.push(e)}return l.length=l.length-1,new n(l.join(""))},toString:function(){return this.s},underscore:function(){var e=this.trim().s.replace(/([a-z\d])([A-Z]+)/g,"$1_$2").replace(/[-\s]+/g,"_").toLowerCase();return(new n(this.s.charAt(0))).isUpper()&&(e="_"+e),new n(e)},unescapeHTML:function(){return new n(this.s.replace(/\&([^;]+);/g,function(e,t){var n;return t in d?d[t]:(n=t.match(/^#x([\da-fA-F]+)$/))?String.fromCharCode(parseInt(n[1],16)):(n=t.match(/^#(\d+)$/))?String.fromCharCode(~~n[1]):e}))},valueOf:function(){return this.s.valueOf()}},s=[],a=l();for(var f in a)(function(e){var t=r[e];typeof t=="function"&&(i[e]||(a[e]==="string"?i[e]=function(){return new n(t.apply(this,arguments))}:i[e]=t))})(f);i.repeat=i.times,i.include=i.contains,i.toInteger=i.toInt,i.toBool=i.toBoolean,i.decodeHTMLEntities=i.decodeHtmlEntities,h.extendPrototype=o,h.restorePrototype=u,h.VERSION=e,h.TMPL_OPEN="{{",h.TMPL_CLOSE="}}",h.ENTITIES=t,typeof module!="undefined"&&typeof module.exports!="undefined"?module.exports=h:typeof define=="function"&&define.amd?define([],function(){return h}):window.S=h;var d={lt:"<",gt:">",quot:'"',apos:"'",amp:"&"},v={};for(var m in d)v[d[m]]=m;t={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,"OElig;":338,"oelig;":339,"Scaron;":352,"scaron;":353,"Yuml;":376,"fnof;":402,"circ;":710,"tilde;":732,"Alpha;":913,"Beta;":914,"Gamma;":915,"Delta;":916,"Epsilon;":917,"Zeta;":918,"Eta;":919,"Theta;":920,"Iota;":921,"Kappa;":922,"Lambda;":923,"Mu;":924,"Nu;":925,"Xi;":926,"Omicron;":927,"Pi;":928,"Rho;":929,"Sigma;":931,"Tau;":932,"Upsilon;":933,"Phi;":934,"Chi;":935,"Psi;":936,"Omega;":937,"alpha;":945,"beta;":946,"gamma;":947,"delta;":948,"epsilon;":949,"zeta;":950,"eta;":951,"theta;":952,"iota;":953,"kappa;":954,"lambda;":955,"mu;":956,"nu;":957,"xi;":958,"omicron;":959,"pi;":960,"rho;":961,"sigmaf;":962,"sigma;":963,"tau;":964,"upsilon;":965,"phi;":966,"chi;":967,"psi;":968,"omega;":969,"thetasym;":977,"upsih;":978,"piv;":982,"ensp;":8194,"emsp;":8195,"thinsp;":8201,"zwnj;":8204,"zwj;":8205,"lrm;":8206,"rlm;":8207,"ndash;":8211,"mdash;":8212,"lsquo;":8216,"rsquo;":8217,"sbquo;":8218,"ldquo;":8220,"rdquo;":8221,"bdquo;":8222,"dagger;":8224,"Dagger;":8225,"bull;":8226,"hellip;":8230,"permil;":8240,"prime;":8242,"Prime;":8243,"lsaquo;":8249,"rsaquo;":8250,"oline;":8254,"frasl;":8260,"euro;":8364,"image;":8465,"weierp;":8472,"real;":8476,"trade;":8482,"alefsym;":8501,"larr;":8592,"uarr;":8593,"rarr;":8594,"darr;":8595,"harr;":8596,"crarr;":8629,"lArr;":8656,"uArr;":8657,"rArr;":8658,"dArr;":8659,"hArr;":8660,"forall;":8704,"part;":8706,"exist;":8707,"empty;":8709,"nabla;":8711,"isin;":8712,"notin;":8713,"ni;":8715,"prod;":8719,"sum;":8721,"minus;":8722,"lowast;":8727,"radic;":8730,"prop;":8733,"infin;":8734,"ang;":8736,"and;":8743,"or;":8744,"cap;":8745,"cup;":8746,"int;":8747,"there4;":8756,"sim;":8764,"cong;":8773,"asymp;":8776,"ne;":8800,"equiv;":8801,"le;":8804,"ge;":8805,"sub;":8834,"sup;":8835,"nsub;":8836,"sube;":8838,"supe;":8839,"oplus;":8853,"otimes;":8855,"perp;":8869,"sdot;":8901,"lceil;":8968,"rceil;":8969,"lfloor;":8970,"rfloor;":8971,"lang;":9001,"rang;":9002,"loz;":9674,"spades;":9824,"clubs;":9827,"hearts;":9829,"diams;":9830}}.call(this);
{
"name": "string",
"version": "1.2.1",
"version": "1.3.0",
"description": "string contains methods that aren't included in the vanilla JavaScript string such as escaping HTML, decoding HTML entities, stripping tags, etc.",

@@ -5,0 +5,0 @@ "homepage": [

@@ -31,3 +31,3 @@ [string.js](http://stringjs.com)

npm install string
npm install --save string

@@ -39,7 +39,7 @@

Assuming you're on http://stringjs.com, just simply open up the Webkit inspector in either Chrome or Safari, or the web console in Firefox and you'll notice that `string.js` is included in this page so that you can start experimenting with it right away.
Assuming you're on http://stringjs.com, just simply open up the Webkit inspector in either Chrome or Safari, or the web console in Firefox and you'll notice that `string.js` is included in this page so that you can start experimenting with it right away.
Usage
Usage
-----

@@ -62,3 +62,3 @@

<!-- Note that in the mime type for Javascript is now officially 'application/javascript'. If you
set the type to application/javascript in IE browsers, your Javscript will fail. Just don't set a
set the type to application/javascript in IE browsers, your Javscript will fail. Just don't set a
type via the script tag and set the mime type from your server. Most browsers look at the server mime

@@ -133,5 +133,5 @@ type anyway -->

See [test file][testfile] for more details.
See [test file][testfile] for more details.
I use the same nomenclature as Objective-C regarding methods. **+** means `static` or `class` method. **-** means `non-static` or `instance` method.
I use the same nomenclature as Objective-C regarding methods. **+** means `static` or `class` method. **-** means `non-static` or `instance` method.

@@ -151,2 +151,12 @@ ### - constructor(nativeJsString) ###

### - between(left, right)
Extracts a string between `left` and `right` strings.
Example:
```javascript
S('<a>foobar</a>').between('<a>', '</a>').s; // 'foobar'
```
### - camelize()

@@ -179,2 +189,26 @@

### - chompLeft(prefix)
Removes `prefix` from start of string.
Example:
```javascript
S('foobar').chompLeft('foo').s; //'bar'
S('foobar').chompLeft('bar').s; //'foobar'
```
### - chompRight(suffix)
Removes `suffix` from end of string.
Example:
```javascript
S('foobar').chompRight('bar').s; //'foo'
S('foobar').chompRight('foo').s; //'foobar'
```
### - collapseWhitespace() ###

@@ -261,2 +295,29 @@

### - ensureLeft(prefix)
Ensures string starts with `prefix`.
Example:
```javascript
S('subdir').ensureLeft('/').s; //'/subdir'
S('/subdir').ensureLeft('/').s; //'/subdir'
```
### - ensureRight(suffix)
Ensures string ends with `suffix`.
Example:
```javascript
S('dir').ensureRight('/').s; //'dir/'
S('dir/').ensureRight('/').s; //'dir/'
```
### - include(ss) ###

@@ -328,3 +389,3 @@

```javascript
```javascript
S('a').isLower(); //true

@@ -464,2 +525,3 @@ S('z').isLower(); //true

- `qualifier`: The character that encloses fields. Default: `"`
- `escape`: The character that represents the escape character. Default: `\`

@@ -471,3 +533,3 @@ Example:

S('"a","b","c"').parseCSV() // ['a', 'b', 'c'])
S('a,b,c').parseCSV(',', null) //['a', 'b', 'c'])
S('a,b,c').parseCSV(',', null) //['a', 'b', 'c'])
S("'a,','b','c'").parseCSV(',', "'") //['a,', 'b', 'c'])

@@ -536,3 +598,3 @@ S('"a","b",4,"c"').parseCSV(',', null) //['"a"', '"b"', '4', '"c"'])

The encapsulated native string representation of an `S` object.
The encapsulated native string representation of an `S` object.

@@ -571,3 +633,3 @@ Example:

Strip all of the punctuation.
Strip all of the punctuation.

@@ -577,3 +639,3 @@ Example:

```javascript
S('My, st[ring] *full* of %punct)').stripPunctuation().s; //My string full of punct
S('My, st[ring] *full* of %punct)').stripPunctuation().s; //My string full of punct
```

@@ -608,3 +670,3 @@

console.log(S(str).template(values, '#{', '}').s) //'Hello JP! How are you doing during the year of 2013?'
S.TMPL_OPEN = '{'

@@ -633,3 +695,3 @@ S.TMPL_CLOSE = '}'

Converts a a logical truth string to boolean. That is: `true`, `1`, `'true'`, `'on'`, or `'yes'`.
Converts a a logical truth string to boolean. That is: `true`, `1`, `'true'`, `'on'`, or `'yes'`.

@@ -697,3 +759,3 @@ JavaScript Note: You can easily convert truthy values to `booleans` by prefixing them with `!!`. e.g.

### - toFloat([precision]) ###
Return the float value, wraps parseFloat.

@@ -769,3 +831,3 @@

```javascript
S(' How are you?').trimLeft().s; //'How are you?';
S(' How are you?').trimLeft().s; //'How are you?';
```

@@ -781,3 +843,3 @@

```javascript
S('How are you? ').trimRight().s; //'How are you?';
S('How are you? ').trimRight().s; //'How are you?';
```

@@ -874,11 +936,19 @@

I have looked at the code by the creators in the libraries mentioned in **Motivation**. As noted in the source code, I've specifically used code from Google Closure (Google Inc), Underscore String [Esa-Matti Suuronen](http://esa-matti.suuronen.org/), and php.js (http://phpjs.org/authors/index), and [TJ Holowaychuk](https://github.com/component/pad).
I have looked at the code by the creators in the libraries mentioned in **Motivation**. As noted in the source code, I've specifically used code from Google Closure (Google Inc), Underscore String [Esa-Matti Suuronen](http://esa-matti.suuronen.org/), and php.js (http://phpjs.org/authors/index), [Substack](https://github.com/substack/node-ent) and [TJ Holowaychuk](https://github.com/component/pad).
Author
------
Contributors
------------
`string.js` was written by [JP Richardson][aboutjp]. You should follow him on Twitter [@jprichardson][twitter]. Also read his coding blog [Procbits][procbits]. If you write software with others, you should checkout [Gitpilot][gitpilot] to make collaboration with Git simple.
If you contribute to this library. Please add your name and Github url to this list:
- [JP Richardson](https://github.com/jprichardson)
- [Leonardo Otero](https://github.com/oteroleonardo)
- [Jordan Scales](https://github.com/prezjordan)
- [Eduardo de Matos](https://github.com/eduardo-matos)
- [Christian Maughan Tegnér](https://github.com/CMTegner)
- [Mario Gutierrez](https://github.com/mgutz)
- [Sean O'Dell](https://github.com/seanodell)
- `<your name here>`

@@ -891,3 +961,3 @@

Copyright (C) 2012 JP Richardson <jprichardson@gmail.com>
Copyright (C) 2012-2013 JP Richardson <jprichardson@gmail.com>

@@ -909,4 +979,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

[procbits]: http://procbits.com
[gitpilot]: http://gitpilot.com

@@ -23,8 +23,8 @@

function ARY_EQ(a1, a2) {
T (a1.length === a2.length)
EQ (a1.length, a2.length)
for (var i = 0; i < a1.length; ++i)
T (a1[i] === a2[i])
EQ (a1[i], a2[i])
}
/*if (typeof window !== "undefined" && window !== null) {

@@ -37,3 +37,3 @@ S = window.S;

describe('string.js', function() {
describe('- constructor', function() {

@@ -44,3 +44,3 @@ it('should should set the internal "s" property', function() {

T (S(new Date(2012, 1, 1)).s.indexOf('2012') != -1)
T (S(new RegExp()).s.substr(0,1) === '/')
T (S(new RegExp()).s.substr(0,1) === '/')
T (S({}).s === '[object Object]')

@@ -52,2 +52,11 @@ T (S(null).s === null)

describe('- between(left, right)', function() {
it('should extract string between `left` and `right`', function() {
T (S('<a>foo</a>').between('<a>', '</a>').s === 'foo')
T (S('<a>foo</a></a>').between('<a>', '</a>').s === 'foo')
T (S('<a><a>foo</a></a>').between('<a>', '</a>').s === '<a>foo')
T (S('<a>foo').between('<a>', '</a>').s === '')
})
})
describe('- camelize()', function() {

@@ -62,3 +71,3 @@ it('should remove any underscores or dashes and convert a string into camel casing', function() {

})
describe('- capitalize()', function() {

@@ -77,2 +86,20 @@ it('should capitalize the string', function() {

describe('- chompLeft(prefix)', function() {
it('should remove `prefix` from start of string', function() {
T (S('foobar').chompLeft('foo').s === 'bar')
T (S('foobar').chompLeft('bar').s === 'foobar')
T (S('').chompLeft('foo').s === '')
T (S('').chompLeft('').s === '')
})
})
describe('- chompRight(suffix)', function() {
it('should remove `suffix` from end of string', function() {
T (S('foobar').chompRight('foo').s === 'foobar')
T (S('foobar').chompRight('bar').s === 'foo')
T (S('').chompRight('foo').s === '')
T (S('').chompRight('').s === '')
})
})
describe('- collapseWhitespace()', function() {

@@ -102,4 +129,5 @@ it('should convert all adjacent whitespace characters to a single space and trim the ends', function() {

it('should decode HTML entities into their proper string representation', function() {
T (S('Ken Thompson &amp; Dennis Ritchie').decodeHTMLEntities().s === 'Ken Thompson & Dennis Ritchie');
T (S('3 &lt; 4').decodeHTMLEntities().s === '3 < 4');
EQ (S('Ken Thompson &amp; Dennis Ritchie').decodeHTMLEntities().s, 'Ken Thompson & Dennis Ritchie');
EQ (S('3 &lt; 4').decodeHTMLEntities().s, '3 < 4');
EQ (S('http:&#47;&#47;').decodeHTMLEntities().s, 'http://')
})

@@ -118,2 +146,20 @@ })

describe('- ensureLeft(prefix)', function() {
it('should prepend `prefix` if string does not start with prefix', function() {
T (S('foobar').ensureLeft('foo').s === 'foobar')
T (S('bar').ensureLeft('foo').s === 'foobar')
T (S('').ensureLeft('foo').s === 'foo')
T (S('').ensureLeft('').s === '')
})
})
describe('- ensureRight(suffix)', function() {
it('should append `suffix` if string does not end with suffix', function() {
T (S('foobar').ensureRight('bar').s === 'foobar')
T (S('foo').ensureRight('bar').s === 'foobar')
T (S('').ensureRight('foo').s === 'foo')
T (S('').ensureRight('').s === '')
})
})
describe('- escapeHTML()', function() {

@@ -288,3 +334,3 @@ it('should escape the html', function() {

ARY_EQ (S('"a","b","c"').parseCSV(), ['a', 'b', 'c'])
ARY_EQ (S('a,b,c').parseCSV(',', null), ['a', 'b', 'c'])
ARY_EQ (S('a,b,c').parseCSV(',', null), ['a', 'b', 'c'])
ARY_EQ (S("'a,','b','c'").parseCSV(',', "'"), ['a,', 'b', 'c'])

@@ -296,2 +342,6 @@ ARY_EQ (S('"a","b",4,"c"').parseCSV(',', null), ['"a"', '"b"', '4', '"c"'])

ARY_EQ (S('"a","b\\"","d","c"').parseCSV(), ['a', 'b"', 'd', 'c'])
ARY_EQ (S('"jp","really\tlikes to code"').parseCSV(), ['jp', 'really\tlikes to code'])
ARY_EQ (S('"a","b+"","d","c"').parseCSV(",", "\"", "+"), ['a', 'b"', 'd', 'c'])
ARY_EQ (S('"a","","c"').parseCSV(), ['a', '', 'c'])
ARY_EQ (S('"","b","c"').parseCSV(), ['', 'b', 'c'])
})

@@ -339,3 +389,3 @@ })

})
describe('- s', function() {

@@ -354,3 +404,3 @@ it('should return the native string', function() {

})
describe('- startsWith(prefix)', function() {

@@ -387,3 +437,3 @@ it("should return true if the string starts with the input string", function() {

EQ (S(str).template(values, '#{', '}').s, 'Hello JP! How are you doing during the year of 2013?')
S.TMPL_OPEN = '{'

@@ -441,9 +491,10 @@ S.TMPL_CLOSE = '}'

it('should convert the array to csv', function() {
T (S(['a', 'b', 'c']).toCSV().s === '"a","b","c"');
T (S(['a', 'b', 'c']).toCSV(':').s === '"a":"b":"c"');
T (S(['a', 'b', 'c']).toCSV(':', null).s === 'a:b:c');
T (S(['a', 'b', 'c']).toCSV('*', "'").s === "'a'*'b'*'c'");
T (S(['a"', 'b', 4, 'c']).toCSV({delimiter: ',', qualifier: '"', escape: '\\', encloseNumbers: false}).s === '"a\\"","b",4,"c"');
T (S({firstName: 'JP', lastName: 'Richardson'}).toCSV({keys: true}).s === '"firstName","lastName"');
T (S({firstName: 'JP', lastName: 'Richardson'}).toCSV().s === '"JP","Richardson"');
EQ (S(['a', 'b', 'c']).toCSV().s, '"a","b","c"');
EQ (S(['a', 'b', 'c']).toCSV(':').s, '"a":"b":"c"');
EQ (S(['a', 'b', 'c']).toCSV(':', null).s, 'a:b:c');
EQ (S(['a', 'b', 'c']).toCSV('*', "'").s, "'a'*'b'*'c'");
EQ (S(['a"', 'b', 4, 'c']).toCSV({delimiter: ',', qualifier: '"', escape: '\\', encloseNumbers: false}).s, '"a\\"","b",4,"c"');
EQ (S({firstName: 'JP', lastName: 'Richardson'}).toCSV({keys: true}).s, '"firstName","lastName"');
EQ (S({firstName: 'JP', lastName: 'Richardson'}).toCSV().s, '"JP","Richardson"');
EQ (S(['a', null, 'c']).toCSV().s, '"a","","c"');
})

@@ -450,0 +501,0 @@ })

Sorry, the diff of this file is not supported yet

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