Created
December 12, 2014 14:04
-
-
Save stoeffel/80d470a9de841cc67f8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
"use strict"; | |
var lib$helpers$to_string$$toString = Object.prototype.toString; | |
function lib$helpers$str_repeat$$strRepeat(str, qty) { | |
if (qty < 1) return ''; | |
var result = ''; | |
while (qty > 0) { | |
if (qty & 1) result += str; | |
qty >>= 1, str += str; | |
} | |
return result; | |
} | |
var lib$helpers$sprintf$$sprintf = (function() { | |
function get_type(variable) { | |
return lib$helpers$to_string$$toString.call(variable).slice(8, -1).toLowerCase(); | |
} | |
var str_repeat = lib$helpers$str_repeat$$strRepeat; | |
var str_format = function() { | |
if (!str_format.cache.hasOwnProperty(arguments[0])) { | |
str_format.cache[arguments[0]] = str_format.parse(arguments[0]); | |
} | |
return str_format.format.call(null, str_format.cache[arguments[0]], arguments); | |
}; | |
str_format.format = function(parse_tree, argv) { | |
var cursor = 1, | |
tree_length = parse_tree.length, | |
node_type = '', | |
arg, output = [], | |
i, k, match, pad, pad_character, pad_length; | |
for (i = 0; i < tree_length; i++) { | |
node_type = get_type(parse_tree[i]); | |
if (node_type === 'string') { | |
output.push(parse_tree[i]); | |
} else if (node_type === 'array') { | |
match = parse_tree[i]; // convenience purposes only | |
if (match[2]) { // keyword argument | |
arg = argv[cursor]; | |
for (k = 0; k < match[2].length; k++) { | |
if (!arg.hasOwnProperty(match[2][k])) { | |
throw new Error(lib$helpers$sprintf$$sprintf('[_.sprintf] property "%s" does not exist', match[2][k])); | |
} | |
arg = arg[match[2][k]]; | |
} | |
} else if (match[1]) { // positional argument (explicit) | |
arg = argv[match[1]]; | |
} else { // positional argument (implicit) | |
arg = argv[cursor++]; | |
} | |
if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) { | |
throw new Error(lib$helpers$sprintf$$sprintf('[_.sprintf] expecting number but found %s', get_type(arg))); | |
} | |
switch (match[8]) { | |
case 'b': | |
arg = arg.toString(2); | |
break; | |
case 'c': | |
arg = String.fromCharCode(arg); | |
break; | |
case 'd': | |
arg = parseInt(arg, 10); | |
break; | |
case 'e': | |
arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); | |
break; | |
case 'f': | |
arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); | |
break; | |
case 'o': | |
arg = arg.toString(8); | |
break; | |
case 's': | |
arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); | |
break; | |
case 'u': | |
arg = Math.abs(arg); | |
break; | |
case 'x': | |
arg = arg.toString(16); | |
break; | |
case 'X': | |
arg = arg.toString(16).toUpperCase(); | |
break; | |
} | |
arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+' + arg : arg); | |
pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' '; | |
pad_length = match[6] - String(arg).length; | |
pad = match[6] ? str_repeat(pad_character, pad_length) : ''; | |
output.push(match[5] ? arg + pad : pad + arg); | |
} | |
} | |
return output.join(''); | |
}; | |
str_format.cache = {}; | |
str_format.parse = function(fmt) { | |
var _fmt = fmt, | |
match = [], | |
parse_tree = [], | |
arg_names = 0; | |
while (_fmt) { | |
if ((match = /^[^\x25]+/.exec(_fmt)) !== null) { | |
parse_tree.push(match[0]); | |
} else if ((match = /^\x25{2}/.exec(_fmt)) !== null) { | |
parse_tree.push('%'); | |
} else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) { | |
if (match[2]) { | |
arg_names |= 1; | |
var field_list = [], | |
replacement_field = match[2], | |
field_match = []; | |
if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { | |
field_list.push(field_match[1]); | |
while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') { | |
if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { | |
field_list.push(field_match[1]); | |
} else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) { | |
field_list.push(field_match[1]); | |
} else { | |
throw new Error('[_.sprintf] huh?'); | |
} | |
} | |
} else { | |
throw new Error('[_.sprintf] huh?'); | |
} | |
match[2] = field_list; | |
} else { | |
arg_names |= 2; | |
} | |
if (arg_names === 3) { | |
throw new Error('[_.sprintf] mixing positional and named placeholders is not (yet) supported'); | |
} | |
parse_tree.push(match); | |
} else { | |
throw new Error('[_.sprintf] huh?'); | |
} | |
_fmt = _fmt.substring(match[0].length); | |
} | |
return parse_tree; | |
}; | |
return str_format; | |
})(); | |
function lib$helpers$sprintf$$vsprintf(fmt, argv) { | |
argv.unshift(fmt); | |
return lib$helpers$sprintf$$sprintf.apply(null, argv); | |
} | |
function lib$helpers$make_string$$makeString(object) { | |
if (object == null) return ''; | |
return '' + object; | |
} | |
function lib$is_blank$$isBlank(str) { | |
return (/^\s*$/).test(lib$helpers$make_string$$makeString(str)); | |
} | |
function lib$strip_tags$$stripTags(str) { | |
return lib$helpers$make_string$$makeString(str).replace(/<\/?[^>]+>/g, ''); | |
} | |
function lib$capitalize$$capitalize(str) { | |
str = lib$helpers$make_string$$makeString(str); | |
return str.charAt(0).toUpperCase() + str.slice(1); | |
} | |
function lib$decapitalize$$decapitalize(str) { | |
str = lib$helpers$make_string$$makeString(str); | |
return str.charAt(0).toLowerCase() + str.slice(1); | |
} | |
function lib$chop$$chop(str, step) { | |
if (str == null) return []; | |
str = String(str); | |
step = ~~step; | |
return step > 0 ? str.match(new RegExp('.{1,' + step + '}', 'g')) : [str]; | |
} | |
function lib$escape_reg_exp$$escapeRegExp(str) { | |
return lib$helpers$make_string$$makeString(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); | |
} | |
function lib$helpers$default_to_whitespace$$defaultToWhiteSpace(characters) { | |
if (characters == null) | |
return '\\s'; | |
else if (characters.source) | |
return characters.source; | |
else | |
return '[' + lib$escape_reg_exp$$escapeRegExp(characters) + ']'; | |
} | |
var lib$trim$$nativeTrim = String.prototype.trim; | |
var lib$trim$$nativeTrimLeft = String.prototype.trimLeft; | |
var lib$trim$$nativeTrimRight = String.prototype.trimRight; | |
function lib$trim$$trim(str, characters){ | |
str = lib$helpers$make_string$$makeString(str); | |
if (!characters && lib$trim$$nativeTrim) return lib$trim$$nativeTrim.call(str); | |
characters = lib$helpers$default_to_whitespace$$defaultToWhiteSpace(characters); | |
return str.replace(new RegExp('^' + characters + '+|' + characters + '+$', 'g'), ''); | |
} | |
function lib$trim$$ltrim(str, characters) { | |
str = lib$helpers$make_string$$makeString(str); | |
if (!characters && lib$trim$$nativeTrimLeft) return lib$trim$$nativeTrimLeft.call(str); | |
characters = lib$helpers$default_to_whitespace$$defaultToWhiteSpace(characters); | |
return str.replace(new RegExp('^' + characters + '+'), ''); | |
} | |
function lib$trim$$rtrim(str, characters) { | |
str = lib$helpers$make_string$$makeString(str); | |
if (!characters && lib$trim$$nativeTrimRight) return lib$trim$$nativeTrimRight.call(str); | |
characters = lib$helpers$default_to_whitespace$$defaultToWhiteSpace(characters); | |
return str.replace(new RegExp(characters + '+$'), ''); | |
} | |
function lib$clean$$clean(str){ | |
return lib$trim$$trim(str).replace(/\s+/g, ' '); | |
} | |
function lib$count$$count(str, substr){ | |
str = lib$helpers$make_string$$makeString(str); | |
substr = lib$helpers$make_string$$makeString(substr); | |
var count = 0, | |
pos = 0, | |
length = substr.length; | |
while (true) { | |
pos = str.indexOf(substr, pos); | |
if (pos === -1) break; | |
count++; | |
pos += length; | |
} | |
return count; | |
} | |
function lib$titleize$$titleize(str) { | |
return lib$helpers$make_string$$makeString(str).toLowerCase().replace(/(?:^|\s|-)\S/g, function(c) { | |
return c.toUpperCase(); | |
}); | |
} | |
function lib$chars$$chars(str) { | |
return lib$helpers$make_string$$makeString(str).split(''); | |
} | |
function lib$swap_case$$swapCase(str) { | |
return lib$helpers$make_string$$makeString(str).replace(/\S/g, function(c) { | |
return c === c.toUpperCase() ? c.toLowerCase() : c.toUpperCase(); | |
}); | |
} | |
var lib$helpers$escape_chars$$escapeChars = { | |
lt: '<', | |
gt: '>', | |
quot: '"', | |
amp: '&', | |
apos: "'" | |
}; | |
var lib$helpers$escape_chars$$reversedEscapeChars = {}; | |
for (var lib$helpers$escape_chars$$key in lib$helpers$escape_chars$$escapeChars) lib$helpers$escape_chars$$reversedEscapeChars[lib$helpers$escape_chars$$escapeChars[lib$helpers$escape_chars$$key]] = lib$helpers$escape_chars$$key; | |
lib$helpers$escape_chars$$reversedEscapeChars["'"] = '#39'; | |
function lib$escape_html$$escapeHTML(str) { | |
return lib$helpers$make_string$$makeString(str).replace(/[&<>"']/g, function(m) { | |
return '&' + lib$helpers$escape_chars$$reversedEscapeChars[m] + ';'; | |
}); | |
} | |
function lib$unescape_html$$unescapeHTML(str) { | |
return lib$helpers$make_string$$makeString(str).replace(/\&([^;]+);/g, function(entity, entityCode) { | |
var match; | |
if (entityCode in lib$helpers$escape_chars$$escapeChars) { | |
return lib$helpers$escape_chars$$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; | |
} | |
}); | |
} | |
function lib$splice$$splice(str, i, howmany, substr) { | |
var arr = lib$chars$$chars(str); | |
arr.splice(~~i, ~~howmany, substr); | |
return arr.join(''); | |
} | |
function lib$insert$$insert(str, i, substr) { | |
return lib$splice$$splice(str, i, 0, substr); | |
} | |
function lib$include$$include(str, needle) { | |
if (needle === '') return true; | |
return lib$helpers$make_string$$makeString(str).indexOf(needle) !== -1; | |
} | |
var lib$join$$nativeSlice = [].slice; | |
function lib$join$$join() { | |
var args = lib$join$$nativeSlice.call(arguments), | |
separator = args.shift(); | |
return args.join(lib$helpers$make_string$$makeString(separator)); | |
} | |
function lib$lines$$lines(str) { | |
if (str == null) return []; | |
return String(str).split('\n'); | |
} | |
function lib$reverse$$reverse(str) { | |
return lib$chars$$chars(str).reverse().join(''); | |
} | |
function lib$helpers$to_positive$$toPositive(number) { | |
return number < 0 ? 0 : (+number || 0); | |
} | |
function lib$starts_with$$startsWith(str, starts, position) { | |
str = lib$helpers$make_string$$makeString(str); | |
starts = '' + starts; | |
position = position == null ? 0 : Math.min(lib$helpers$to_positive$$toPositive(position), str.length); | |
return str.lastIndexOf(starts) == position; | |
} | |
function lib$ends_with$$endsWith(str, ends, position) { | |
str = lib$helpers$make_string$$makeString(str); | |
ends = '' + ends; | |
if (typeof position == 'undefined') { | |
position = str.length - ends.length; | |
} else { | |
position = Math.min(lib$helpers$to_positive$$toPositive(position), str.length) - ends.length; | |
} | |
return position >= 0 && str.indexOf(ends, position) === position; | |
} | |
function lib$succ$$succ(str) { | |
str = lib$helpers$make_string$$makeString(str); | |
return str.slice(0, -1) + String.fromCharCode(str.charCodeAt(str.length - 1) + 1); | |
} | |
function lib$camelize$$camelize(str) { | |
return lib$trim$$trim(str).replace(/[-_\s]+(.)?/g, function(match, c) { | |
return c ? c.toUpperCase() : ""; | |
}); | |
} | |
function lib$underscored$$underscored(str){ | |
return lib$trim$$trim(str).replace(/([a-z\d])([A-Z]+)/g, '$1_$2').replace(/[-\s]+/g, '_').toLowerCase(); | |
} | |
function lib$dasherize$$dasherize(str) { | |
return lib$trim$$trim(str).replace(/([A-Z])/g, '-$1').replace(/[-_\s]+/g, '-').toLowerCase(); | |
} | |
function lib$classify$$classify(str) { | |
return lib$capitalize$$capitalize(lib$camelize$$camelize(String(str).replace(/[\W_]/g, ' ')).replace(/\s/g, '')); | |
} | |
function lib$humanize$$humanize(str) { | |
return lib$capitalize$$capitalize(lib$underscored$$underscored(str).replace(/_id$/, '').replace(/_/g, ' ')); | |
} | |
function lib$truncate$$truncate(str, length, truncateStr) { | |
str = lib$helpers$make_string$$makeString(str); | |
truncateStr = truncateStr || '...'; | |
length = ~~length; | |
return str.length > length ? str.slice(0, length) + truncateStr : str; | |
} | |
function lib$prune$$prune(str, length, pruneStr) { | |
str = lib$helpers$make_string$$makeString(str); | |
length = ~~length; | |
pruneStr = pruneStr != null ? String(pruneStr) : '...'; | |
if (str.length <= length) return str; | |
var tmpl = function(c) { | |
return c.toUpperCase() !== c.toLowerCase() ? 'A' : ' '; | |
}, | |
template = str.slice(0, length + 1).replace(/.(?=\W*\w*$)/g, tmpl); // 'Hello, world' -> 'HellAA AAAAA' | |
if (template.slice(template.length - 2).match(/\w\w/)) | |
template = template.replace(/\s*\S+$/, ''); | |
else | |
template = lib$trim$$rtrim(template.slice(0, template.length - 1)); | |
return (template + pruneStr).length > str.length ? str : str.slice(0, template.length) + pruneStr; | |
} | |
function lib$words$$words(str, delimiter) { | |
if (lib$is_blank$$isBlank(str)) return []; | |
return lib$trim$$trim(str, delimiter).split(delimiter || /\s+/); | |
} | |
function lib$pad$$pad(str, length, padStr, type) { | |
str = lib$helpers$make_string$$makeString(str); | |
length = ~~length; | |
var padlen = 0; | |
if (!padStr) | |
padStr = ' '; | |
else if (padStr.length > 1) | |
padStr = padStr.charAt(0); | |
switch (type) { | |
case 'right': | |
padlen = length - str.length; | |
return str + lib$helpers$str_repeat$$strRepeat(padStr, padlen); | |
case 'both': | |
padlen = length - str.length; | |
return lib$helpers$str_repeat$$strRepeat(padStr, Math.ceil(padlen / 2)) + str + lib$helpers$str_repeat$$strRepeat(padStr, Math.floor(padlen / 2)); | |
default: // 'left' | |
padlen = length - str.length; | |
return lib$helpers$str_repeat$$strRepeat(padStr, padlen) + str; | |
} | |
} | |
function lib$pad$$lpad(str, length, padStr) { | |
return lib$pad$$pad(str, length, padStr); | |
} | |
function lib$pad$$rpad(str, length, padStr) { | |
return lib$pad$$pad(str, length, padStr, 'right'); | |
} | |
function lib$pad$$lrpad(str, length, padStr) { | |
return lib$pad$$pad(str, length, padStr, 'both'); | |
} | |
function lib$helpers$parse_number$$parseNumber(source) { | |
return source * 1 || 0; | |
} | |
function lib$to_number$$toNumber(str, decimals) { | |
if (!str) return 0; | |
str = lib$trim$$trim(str); | |
if (!str.match(/^-?\d+(?:\.\d+)?$/)) return NaN; | |
return lib$helpers$parse_number$$parseNumber(lib$helpers$parse_number$$parseNumber(str).toFixed(~~decimals)); | |
} | |
function lib$number_format$$numberFormat(number, dec, dsep, tsep) { | |
if (isNaN(number) || number == null) return ''; | |
number = number.toFixed(~~dec); | |
tsep = typeof tsep == 'string' ? tsep : ','; | |
var parts = number.split('.'), | |
fnums = parts[0], | |
decimals = parts[1] ? (dsep || '.') + parts[1] : ''; | |
return fnums.replace(/(\d)(?=(?:\d{3})+$)/g, '$1' + tsep) + decimals; | |
} | |
function lib$str_left_right$$strRight(str, sep){ | |
str = lib$helpers$make_string$$makeString(str); sep = lib$helpers$make_string$$makeString(sep); | |
var pos = !sep ? -1 : str.indexOf(sep); | |
return ~pos ? str.slice(pos+sep.length, str.length) : str; | |
} | |
function lib$str_left_right$$strRightBack(str, sep){ | |
str = lib$helpers$make_string$$makeString(str); sep = lib$helpers$make_string$$makeString(sep); | |
var pos = !sep ? -1 : str.lastIndexOf(sep); | |
return ~pos ? str.slice(pos+sep.length, str.length) : str; | |
} | |
function lib$str_left_right$$strLeft(str, sep){ | |
str = lib$helpers$make_string$$makeString(str); sep = lib$helpers$make_string$$makeString(sep); | |
var pos = !sep ? -1 : str.indexOf(sep); | |
return ~pos ? str.slice(0, pos) : str; | |
} | |
function lib$str_left_right$$strLeftBack(str, sep){ | |
str = lib$helpers$make_string$$makeString(str); sep = lib$helpers$make_string$$makeString(sep); | |
var pos = str.lastIndexOf(sep); | |
return ~pos ? str.slice(0, pos) : str; | |
} | |
function lib$slugify$$slugify(str) { | |
var from = "ąàáäâãåæăćčĉęèéëêĝĥìíïîĵłľńňòóöőôõðøśșšŝťțŭùúüűûñÿýçżźž", | |
to = "aaaaaaaaaccceeeeeghiiiijllnnoooooooossssttuuuuuunyyczzz", | |
regex = new RegExp(lib$helpers$default_to_whitespace$$defaultToWhiteSpace(from), 'g'); | |
str = lib$helpers$make_string$$makeString(str).toLowerCase().replace(regex, function(c) { | |
var index = from.indexOf(c); | |
return to.charAt(index) || '-'; | |
}); | |
return lib$trim$$trim(lib$dasherize$$dasherize(str.replace(/[^\w\s-]/g, '-')), '-'); | |
} | |
function lib$surround$$surround(str, wrapper) { | |
return [wrapper, str, wrapper].join(''); | |
} | |
function lib$quote$$quote(str, quoteChar) { | |
return lib$surround$$surround(str, quoteChar || '"'); | |
} | |
function lib$quote$$unquote(str, quoteChar) { | |
quoteChar = quoteChar || '"'; | |
if (str[0] === quoteChar && str[str.length - 1] === quoteChar) | |
return str.slice(1, str.length - 1); | |
else return str; | |
} | |
function lib$exports$$_exports() { | |
var result = {}; | |
for (var prop in this) { | |
if (!this.hasOwnProperty(prop) || prop.match(/^(?:include|contains|reverse)$/)) continue; | |
result[prop] = this[prop]; | |
} | |
return result; | |
} | |
function lib$repeat$$repeat(str, qty, separator) { | |
str = lib$helpers$make_string$$makeString(str); | |
qty = ~~qty; | |
// using faster implementation if separator is not needed; | |
if (separator == null) return lib$helpers$str_repeat$$strRepeat(str, qty); | |
// this one is about 300x slower in Google Chrome | |
for (var repeat = []; qty > 0; repeat[--qty] = str) {} | |
return repeat.join(separator); | |
} | |
function lib$natural_cmp$$naturalCmp(str1, str2) { | |
if (str1 == str2) return 0; | |
if (!str1) return -1; | |
if (!str2) return 1; | |
var cmpRegex = /(\.\d+)|(\d+)|(\D+)/g, | |
tokens1 = String(str1).match(cmpRegex), | |
tokens2 = String(str2).match(cmpRegex), | |
count = Math.min(tokens1.length, tokens2.length); | |
for (var i = 0; i < count; i++) { | |
var a = tokens1[i], | |
b = tokens2[i]; | |
if (a !== b) { | |
var num1 = +a; | |
var num2 = +b; | |
if (num1 === num1 && num2 === num2) { | |
return num1 > num2 ? 1 : -1; | |
} | |
return a < b ? -1 : 1; | |
} | |
} | |
if (tokens1.length != tokens2.length) | |
return tokens1.length - tokens2.length; | |
return str1 < str2 ? -1 : 1; | |
} | |
function lib$to_sentence$$toSentence(array, separator, lastSeparator, serial) { | |
separator = separator || ', '; | |
lastSeparator = lastSeparator || ' and '; | |
var a = array.slice(), | |
lastMember = a.pop(); | |
if (array.length > 2 && serial) lastSeparator = lib$trim$$rtrim(separator) + lastSeparator; | |
return a.length ? a.join(separator) + lastSeparator + lastMember : lastMember; | |
} | |
function lib$to_sentence$$toSentenceSerial(array, sep, lastSep) { | |
return lib$to_sentence$$toSentence(array, sep, lastSep, true); | |
} | |
function lib$levenshtein$$levenshtein(str1, str2) { | |
str1 = lib$helpers$make_string$$makeString(str1); | |
str2 = lib$helpers$make_string$$makeString(str2); | |
var current = [], | |
prev, value; | |
for (var i = 0; i <= str2.length; i++) | |
for (var j = 0; j <= str1.length; j++) { | |
if (i && j) | |
if (str1.charAt(j - 1) === str2.charAt(i - 1)) | |
value = prev; | |
else | |
value = Math.min(current[j], current[j - 1], prev) + 1; | |
else | |
value = i + j; | |
prev = current[j]; | |
current[j] = value; | |
} | |
return current.pop(); | |
} | |
function lib$helpers$bool_match$$boolMatch(s, matchers) { | |
var i, matcher, down = s.toLowerCase(); | |
matchers = [].concat(matchers); | |
for (i = 0; i < matchers.length; i += 1) { | |
matcher = matchers[i]; | |
if (!matcher) continue; | |
if (matcher.test && matcher.test(s)) return true; | |
if (matcher.toLowerCase() === down) return true; | |
} | |
} | |
function lib$to_boolean$$toBoolean(str, trueValues, falseValues) { | |
if (typeof str === "number") str = "" + str; | |
if (typeof str !== "string") return !!str; | |
str = lib$trim$$trim(str); | |
if (lib$helpers$bool_match$$boolMatch(str, trueValues || ["true", "1"])) return true; | |
if (lib$helpers$bool_match$$boolMatch(str, falseValues || ["false", "0"])) return false; | |
} | |
!function(root, String){ | |
'use strict'; | |
// Defining underscore.string | |
var _s = { | |
VERSION: '2.4.0', | |
isBlank: lib$is_blank$$isBlank, | |
stripTags: lib$strip_tags$$stripTags, | |
capitalize : lib$capitalize$$capitalize, | |
decapitalize : lib$decapitalize$$decapitalize, | |
chop: lib$chop$$chop, | |
clean: lib$clean$$clean, | |
count: lib$count$$count, | |
chars: lib$chars$$chars, | |
swapCase: lib$swap_case$$swapCase, | |
escapeHTML: lib$escape_html$$escapeHTML, | |
unescapeHTML: lib$unescape_html$$unescapeHTML, | |
escapeRegExp: lib$escape_reg_exp$$escapeRegExp, | |
splice: lib$splice$$splice, | |
insert: lib$insert$$insert, | |
include: lib$include$$include, | |
join: lib$join$$join, | |
lines: lib$lines$$lines, | |
reverse: lib$reverse$$reverse, | |
startsWith: lib$starts_with$$startsWith, | |
endsWith: lib$ends_with$$endsWith, | |
succ: lib$succ$$succ, | |
titleize: lib$titleize$$titleize, | |
camelize: lib$camelize$$camelize, | |
underscored: lib$underscored$$underscored, | |
dasherize: lib$dasherize$$dasherize, | |
classify: lib$classify$$classify, | |
humanize: lib$humanize$$humanize, | |
trim: lib$trim$$trim, | |
ltrim: lib$trim$$ltrim, | |
rtrim: lib$trim$$rtrim, | |
truncate: lib$truncate$$truncate, | |
prune: lib$prune$$prune, | |
words: lib$words$$words, | |
pad: lib$pad$$pad, | |
lpad: lib$pad$$lpad, | |
rpad: lib$pad$$rpad, | |
lrpad: lib$pad$$lrpad, | |
sprintf: lib$helpers$sprintf$$sprintf, | |
vsprintf: lib$helpers$sprintf$$vsprintf, | |
toNumber: lib$to_number$$toNumber, | |
numberFormat : lib$number_format$$numberFormat, | |
strRight: lib$str_left_right$$strRight, | |
strRightBack: lib$str_left_right$$strRightBack, | |
strLeft: lib$str_left_right$$strLeft, | |
strLeftBack: lib$str_left_right$$strLeftBack, | |
toSentence: lib$to_sentence$$toSentence, | |
toSentenceSerial: lib$to_sentence$$toSentenceSerial, | |
slugify: lib$slugify$$slugify, | |
surround: lib$surround$$surround, | |
quote: lib$quote$$quote, | |
unquote: lib$quote$$unquote, | |
exports: lib$exports$$_exports, | |
repeat: lib$repeat$$repeat, | |
naturalCmp: lib$natural_cmp$$naturalCmp, | |
levenshtein: lib$levenshtein$$levenshtein, | |
toBoolean: lib$to_boolean$$toBoolean | |
}; | |
// Aliases | |
_s.strip = _s.trim; | |
_s.lstrip = _s.ltrim; | |
_s.rstrip = _s.rtrim; | |
_s.center = _s.lrpad; | |
_s.rjust = _s.lpad; | |
_s.ljust = _s.rpad; | |
_s.contains = _s.include; | |
_s.q = _s.quote; | |
_s.toBool = _s.toBoolean; | |
// Exporting | |
// CommonJS module is defined | |
if (typeof exports !== 'undefined') { | |
if (typeof module !== 'undefined' && module.exports) | |
module.exports = _s; | |
exports._s = _s; | |
} | |
// Register as a named module with AMD. | |
if (typeof define === 'function' && define.amd) | |
define('underscore.string', [], function(){ return _s; }); | |
// Integrate with Underscore.js if defined | |
// or create our own underscore object. | |
root._ = root._ || {}; | |
root._.string = root._.str = _s; | |
}(this, String); | |
}).call(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment