js_stack 1.10.0 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +6 -6
- data/js_stack.gemspec +0 -1
- data/lib/js_stack/version.rb +1 -1
- data/lib/js_stack.rb +0 -1
- data/vendor/assets/javascripts/js_stack/base/backbone/1.2.3.js +1894 -0
- data/vendor/assets/javascripts/js_stack/base/backbone.js +1 -1
- data/vendor/assets/javascripts/js_stack/base/marionette/{2.4.1.js → 2.4.3.js} +265 -138
- data/vendor/assets/javascripts/js_stack/base/marionette.js +1 -1
- data/vendor/assets/javascripts/js_stack/plugins/backbone/stickit/{0.9.0.js → 0.9.2.js} +1 -1
- data/vendor/assets/javascripts/js_stack/plugins/backbone.stickit.js +1 -1
- data/vendor/assets/javascripts/js_stack/plugins/moment/2.10.6.js +3195 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/af.js +72 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/ar-ma.js +58 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/ar-sa.js +102 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/ar-tn.js +56 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/ar.js +135 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/az.js +103 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/be.js +146 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/bg.js +89 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/bn.js +112 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/bo.js +109 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/br.js +106 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/bs.js +140 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/ca.js +78 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/cs.js +156 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/cv.js +62 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/cy.js +78 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/da.js +59 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/de-at.js +75 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/de.js +74 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/el.js +93 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/en-au.js +65 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/en-ca.js +62 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/en-gb.js +66 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/eo.js +72 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/es.js +78 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/et.js +79 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/eu.js +63 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/fa.js +104 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/fi.js +106 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/fo.js +59 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/fr-ca.js +57 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/fr.js +61 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/fy.js +70 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/gl.js +74 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/he.js +81 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/hi.js +122 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/hr.js +139 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/hu.js +108 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/hy-am.js +110 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/id.js +82 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/is.js +126 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/it.js +69 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/ja.js +64 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/jv.js +82 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/ka.js +102 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/km.js +57 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/ko.js +67 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/lb.js +133 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/lt.js +124 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/lv.js +95 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/me.js +108 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/mk.js +89 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/ml.js +70 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/mr.js +120 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/ms-my.js +81 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/ms.js +81 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/my.js +92 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/nb.js +60 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/ne.js +122 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/nl.js +70 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/nn.js +59 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/pl.js +104 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/pt-br.js +59 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/pt.js +63 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/ro.js +73 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/ru.js +163 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/si.js +64 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/sk.js +157 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/sl.js +159 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/sq.js +68 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/sr-cyrl.js +107 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/sr.js +107 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/sv.js +66 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/ta.js +94 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/th.js +64 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/tl-ph.js +61 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/tr.js +89 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/tzl.js +84 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/tzm-latn.js +57 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/tzm.js +57 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/uk.js +152 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/uz.js +57 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/vi.js +65 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/zh-cn.js +126 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment/locale/zh-tw.js +100 -0
- data/vendor/assets/javascripts/js_stack/plugins/moment.js +1 -1
- data/vendor/assets/javascripts/js_stack/plugins/underscore/string/3.2.2.js +1186 -0
- data/vendor/assets/javascripts/js_stack/plugins/underscore.string.js +1 -1
- metadata +93 -20
@@ -0,0 +1,1186 @@
|
|
1
|
+
/* underscore.string 3.2.2 | MIT licensed | http://epeli.github.com/underscore.string/ */
|
2
|
+
|
3
|
+
!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.s=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
|
4
|
+
var trim = _dereq_('./trim');
|
5
|
+
var decap = _dereq_('./decapitalize');
|
6
|
+
|
7
|
+
module.exports = function camelize(str, decapitalize) {
|
8
|
+
str = trim(str).replace(/[-_\s]+(.)?/g, function(match, c) {
|
9
|
+
return c ? c.toUpperCase() : "";
|
10
|
+
});
|
11
|
+
|
12
|
+
if (decapitalize === true) {
|
13
|
+
return decap(str);
|
14
|
+
} else {
|
15
|
+
return str;
|
16
|
+
}
|
17
|
+
};
|
18
|
+
|
19
|
+
},{"./decapitalize":10,"./trim":62}],2:[function(_dereq_,module,exports){
|
20
|
+
var makeString = _dereq_('./helper/makeString');
|
21
|
+
|
22
|
+
module.exports = function capitalize(str, lowercaseRest) {
|
23
|
+
str = makeString(str);
|
24
|
+
var remainingChars = !lowercaseRest ? str.slice(1) : str.slice(1).toLowerCase();
|
25
|
+
|
26
|
+
return str.charAt(0).toUpperCase() + remainingChars;
|
27
|
+
};
|
28
|
+
|
29
|
+
},{"./helper/makeString":21}],3:[function(_dereq_,module,exports){
|
30
|
+
var makeString = _dereq_('./helper/makeString');
|
31
|
+
|
32
|
+
module.exports = function chars(str) {
|
33
|
+
return makeString(str).split('');
|
34
|
+
};
|
35
|
+
|
36
|
+
},{"./helper/makeString":21}],4:[function(_dereq_,module,exports){
|
37
|
+
module.exports = function chop(str, step) {
|
38
|
+
if (str == null) return [];
|
39
|
+
str = String(str);
|
40
|
+
step = ~~step;
|
41
|
+
return step > 0 ? str.match(new RegExp('.{1,' + step + '}', 'g')) : [str];
|
42
|
+
};
|
43
|
+
|
44
|
+
},{}],5:[function(_dereq_,module,exports){
|
45
|
+
var capitalize = _dereq_('./capitalize');
|
46
|
+
var camelize = _dereq_('./camelize');
|
47
|
+
var makeString = _dereq_('./helper/makeString');
|
48
|
+
|
49
|
+
module.exports = function classify(str) {
|
50
|
+
str = makeString(str);
|
51
|
+
return capitalize(camelize(str.replace(/[\W_]/g, ' ')).replace(/\s/g, ''));
|
52
|
+
};
|
53
|
+
|
54
|
+
},{"./camelize":1,"./capitalize":2,"./helper/makeString":21}],6:[function(_dereq_,module,exports){
|
55
|
+
var trim = _dereq_('./trim');
|
56
|
+
|
57
|
+
module.exports = function clean(str) {
|
58
|
+
return trim(str).replace(/\s\s+/g, ' ');
|
59
|
+
};
|
60
|
+
|
61
|
+
},{"./trim":62}],7:[function(_dereq_,module,exports){
|
62
|
+
|
63
|
+
var makeString = _dereq_('./helper/makeString');
|
64
|
+
|
65
|
+
var from = "ąàáäâãåæăćčĉęèéëêĝĥìíïîĵłľńňòóöőôõðøśșšŝťțŭùúüűûñÿýçżźž",
|
66
|
+
to = "aaaaaaaaaccceeeeeghiiiijllnnoooooooossssttuuuuuunyyczzz";
|
67
|
+
|
68
|
+
from += from.toUpperCase();
|
69
|
+
to += to.toUpperCase();
|
70
|
+
|
71
|
+
to = to.split("");
|
72
|
+
|
73
|
+
// for tokens requireing multitoken output
|
74
|
+
from += "ß";
|
75
|
+
to.push('ss');
|
76
|
+
|
77
|
+
|
78
|
+
module.exports = function cleanDiacritics(str) {
|
79
|
+
return makeString(str).replace(/.{1}/g, function(c){
|
80
|
+
var index = from.indexOf(c);
|
81
|
+
return index === -1 ? c : to[index];
|
82
|
+
});
|
83
|
+
};
|
84
|
+
|
85
|
+
},{"./helper/makeString":21}],8:[function(_dereq_,module,exports){
|
86
|
+
var makeString = _dereq_('./helper/makeString');
|
87
|
+
|
88
|
+
module.exports = function(str, substr) {
|
89
|
+
str = makeString(str);
|
90
|
+
substr = makeString(substr);
|
91
|
+
|
92
|
+
if (str.length === 0 || substr.length === 0) return 0;
|
93
|
+
|
94
|
+
return str.split(substr).length - 1;
|
95
|
+
};
|
96
|
+
|
97
|
+
},{"./helper/makeString":21}],9:[function(_dereq_,module,exports){
|
98
|
+
var trim = _dereq_('./trim');
|
99
|
+
|
100
|
+
module.exports = function dasherize(str) {
|
101
|
+
return trim(str).replace(/([A-Z])/g, '-$1').replace(/[-_\s]+/g, '-').toLowerCase();
|
102
|
+
};
|
103
|
+
|
104
|
+
},{"./trim":62}],10:[function(_dereq_,module,exports){
|
105
|
+
var makeString = _dereq_('./helper/makeString');
|
106
|
+
|
107
|
+
module.exports = function decapitalize(str) {
|
108
|
+
str = makeString(str);
|
109
|
+
return str.charAt(0).toLowerCase() + str.slice(1);
|
110
|
+
};
|
111
|
+
|
112
|
+
},{"./helper/makeString":21}],11:[function(_dereq_,module,exports){
|
113
|
+
var makeString = _dereq_('./helper/makeString');
|
114
|
+
|
115
|
+
function getIndent(str) {
|
116
|
+
var matches = str.match(/^[\s\\t]*/gm);
|
117
|
+
var indent = matches[0].length;
|
118
|
+
|
119
|
+
for (var i = 1; i < matches.length; i++) {
|
120
|
+
indent = Math.min(matches[i].length, indent);
|
121
|
+
}
|
122
|
+
|
123
|
+
return indent;
|
124
|
+
}
|
125
|
+
|
126
|
+
module.exports = function dedent(str, pattern) {
|
127
|
+
str = makeString(str);
|
128
|
+
var indent = getIndent(str);
|
129
|
+
var reg;
|
130
|
+
|
131
|
+
if (indent === 0) return str;
|
132
|
+
|
133
|
+
if (typeof pattern === 'string') {
|
134
|
+
reg = new RegExp('^' + pattern, 'gm');
|
135
|
+
} else {
|
136
|
+
reg = new RegExp('^[ \\t]{' + indent + '}', 'gm');
|
137
|
+
}
|
138
|
+
|
139
|
+
return str.replace(reg, '');
|
140
|
+
};
|
141
|
+
|
142
|
+
},{"./helper/makeString":21}],12:[function(_dereq_,module,exports){
|
143
|
+
var makeString = _dereq_('./helper/makeString');
|
144
|
+
var toPositive = _dereq_('./helper/toPositive');
|
145
|
+
|
146
|
+
module.exports = function endsWith(str, ends, position) {
|
147
|
+
str = makeString(str);
|
148
|
+
ends = '' + ends;
|
149
|
+
if (typeof position == 'undefined') {
|
150
|
+
position = str.length - ends.length;
|
151
|
+
} else {
|
152
|
+
position = Math.min(toPositive(position), str.length) - ends.length;
|
153
|
+
}
|
154
|
+
return position >= 0 && str.indexOf(ends, position) === position;
|
155
|
+
};
|
156
|
+
|
157
|
+
},{"./helper/makeString":21,"./helper/toPositive":23}],13:[function(_dereq_,module,exports){
|
158
|
+
var makeString = _dereq_('./helper/makeString');
|
159
|
+
var escapeChars = _dereq_('./helper/escapeChars');
|
160
|
+
var reversedEscapeChars = {};
|
161
|
+
|
162
|
+
var regexString = "[";
|
163
|
+
for(var key in escapeChars) {
|
164
|
+
regexString += key;
|
165
|
+
}
|
166
|
+
regexString += "]";
|
167
|
+
|
168
|
+
var regex = new RegExp( regexString, 'g');
|
169
|
+
|
170
|
+
module.exports = function escapeHTML(str) {
|
171
|
+
|
172
|
+
return makeString(str).replace(regex, function(m) {
|
173
|
+
return '&' + escapeChars[m] + ';';
|
174
|
+
});
|
175
|
+
};
|
176
|
+
|
177
|
+
},{"./helper/escapeChars":18,"./helper/makeString":21}],14:[function(_dereq_,module,exports){
|
178
|
+
module.exports = function() {
|
179
|
+
var result = {};
|
180
|
+
|
181
|
+
for (var prop in this) {
|
182
|
+
if (!this.hasOwnProperty(prop) || prop.match(/^(?:include|contains|reverse|join)$/)) continue;
|
183
|
+
result[prop] = this[prop];
|
184
|
+
}
|
185
|
+
|
186
|
+
return result;
|
187
|
+
};
|
188
|
+
|
189
|
+
},{}],15:[function(_dereq_,module,exports){
|
190
|
+
// Underscore.string
|
191
|
+
// (c) 2010 Esa-Matti Suuronen <esa-matti aet suuronen dot org>
|
192
|
+
// Underscore.string is freely distributable under the terms of the MIT license.
|
193
|
+
// Documentation: https://github.com/epeli/underscore.string
|
194
|
+
// Some code is borrowed from MooTools and Alexandru Marasteanu.
|
195
|
+
// Version '3.2.2'
|
196
|
+
|
197
|
+
'use strict';
|
198
|
+
|
199
|
+
function s(value) {
|
200
|
+
/* jshint validthis: true */
|
201
|
+
if (!(this instanceof s)) return new s(value);
|
202
|
+
this._wrapped = value;
|
203
|
+
}
|
204
|
+
|
205
|
+
s.VERSION = '3.2.2';
|
206
|
+
|
207
|
+
s.isBlank = _dereq_('./isBlank');
|
208
|
+
s.stripTags = _dereq_('./stripTags');
|
209
|
+
s.capitalize = _dereq_('./capitalize');
|
210
|
+
s.decapitalize = _dereq_('./decapitalize');
|
211
|
+
s.chop = _dereq_('./chop');
|
212
|
+
s.trim = _dereq_('./trim');
|
213
|
+
s.clean = _dereq_('./clean');
|
214
|
+
s.cleanDiacritics = _dereq_('./cleanDiacritics');
|
215
|
+
s.count = _dereq_('./count');
|
216
|
+
s.chars = _dereq_('./chars');
|
217
|
+
s.swapCase = _dereq_('./swapCase');
|
218
|
+
s.escapeHTML = _dereq_('./escapeHTML');
|
219
|
+
s.unescapeHTML = _dereq_('./unescapeHTML');
|
220
|
+
s.splice = _dereq_('./splice');
|
221
|
+
s.insert = _dereq_('./insert');
|
222
|
+
s.replaceAll = _dereq_('./replaceAll');
|
223
|
+
s.include = _dereq_('./include');
|
224
|
+
s.join = _dereq_('./join');
|
225
|
+
s.lines = _dereq_('./lines');
|
226
|
+
s.dedent = _dereq_('./dedent');
|
227
|
+
s.reverse = _dereq_('./reverse');
|
228
|
+
s.startsWith = _dereq_('./startsWith');
|
229
|
+
s.endsWith = _dereq_('./endsWith');
|
230
|
+
s.pred = _dereq_('./pred');
|
231
|
+
s.succ = _dereq_('./succ');
|
232
|
+
s.titleize = _dereq_('./titleize');
|
233
|
+
s.camelize = _dereq_('./camelize');
|
234
|
+
s.underscored = _dereq_('./underscored');
|
235
|
+
s.dasherize = _dereq_('./dasherize');
|
236
|
+
s.classify = _dereq_('./classify');
|
237
|
+
s.humanize = _dereq_('./humanize');
|
238
|
+
s.ltrim = _dereq_('./ltrim');
|
239
|
+
s.rtrim = _dereq_('./rtrim');
|
240
|
+
s.truncate = _dereq_('./truncate');
|
241
|
+
s.prune = _dereq_('./prune');
|
242
|
+
s.words = _dereq_('./words');
|
243
|
+
s.pad = _dereq_('./pad');
|
244
|
+
s.lpad = _dereq_('./lpad');
|
245
|
+
s.rpad = _dereq_('./rpad');
|
246
|
+
s.lrpad = _dereq_('./lrpad');
|
247
|
+
s.sprintf = _dereq_('./sprintf');
|
248
|
+
s.vsprintf = _dereq_('./vsprintf');
|
249
|
+
s.toNumber = _dereq_('./toNumber');
|
250
|
+
s.numberFormat = _dereq_('./numberFormat');
|
251
|
+
s.strRight = _dereq_('./strRight');
|
252
|
+
s.strRightBack = _dereq_('./strRightBack');
|
253
|
+
s.strLeft = _dereq_('./strLeft');
|
254
|
+
s.strLeftBack = _dereq_('./strLeftBack');
|
255
|
+
s.toSentence = _dereq_('./toSentence');
|
256
|
+
s.toSentenceSerial = _dereq_('./toSentenceSerial');
|
257
|
+
s.slugify = _dereq_('./slugify');
|
258
|
+
s.surround = _dereq_('./surround');
|
259
|
+
s.quote = _dereq_('./quote');
|
260
|
+
s.unquote = _dereq_('./unquote');
|
261
|
+
s.repeat = _dereq_('./repeat');
|
262
|
+
s.naturalCmp = _dereq_('./naturalCmp');
|
263
|
+
s.levenshtein = _dereq_('./levenshtein');
|
264
|
+
s.toBoolean = _dereq_('./toBoolean');
|
265
|
+
s.exports = _dereq_('./exports');
|
266
|
+
s.escapeRegExp = _dereq_('./helper/escapeRegExp');
|
267
|
+
s.wrap = _dereq_('./wrap');
|
268
|
+
|
269
|
+
// Aliases
|
270
|
+
s.strip = s.trim;
|
271
|
+
s.lstrip = s.ltrim;
|
272
|
+
s.rstrip = s.rtrim;
|
273
|
+
s.center = s.lrpad;
|
274
|
+
s.rjust = s.lpad;
|
275
|
+
s.ljust = s.rpad;
|
276
|
+
s.contains = s.include;
|
277
|
+
s.q = s.quote;
|
278
|
+
s.toBool = s.toBoolean;
|
279
|
+
s.camelcase = s.camelize;
|
280
|
+
|
281
|
+
|
282
|
+
// Implement chaining
|
283
|
+
s.prototype = {
|
284
|
+
value: function value() {
|
285
|
+
return this._wrapped;
|
286
|
+
}
|
287
|
+
};
|
288
|
+
|
289
|
+
function fn2method(key, fn) {
|
290
|
+
if (typeof fn !== "function") return;
|
291
|
+
s.prototype[key] = function() {
|
292
|
+
var args = [this._wrapped].concat(Array.prototype.slice.call(arguments));
|
293
|
+
var res = fn.apply(null, args);
|
294
|
+
// if the result is non-string stop the chain and return the value
|
295
|
+
return typeof res === 'string' ? new s(res) : res;
|
296
|
+
};
|
297
|
+
}
|
298
|
+
|
299
|
+
// Copy functions to instance methods for chaining
|
300
|
+
for (var key in s) fn2method(key, s[key]);
|
301
|
+
|
302
|
+
fn2method("tap", function tap(string, fn) {
|
303
|
+
return fn(string);
|
304
|
+
});
|
305
|
+
|
306
|
+
function prototype2method(methodName) {
|
307
|
+
fn2method(methodName, function(context) {
|
308
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
309
|
+
return String.prototype[methodName].apply(context, args);
|
310
|
+
});
|
311
|
+
}
|
312
|
+
|
313
|
+
var prototypeMethods = [
|
314
|
+
"toUpperCase",
|
315
|
+
"toLowerCase",
|
316
|
+
"split",
|
317
|
+
"replace",
|
318
|
+
"slice",
|
319
|
+
"substring",
|
320
|
+
"substr",
|
321
|
+
"concat"
|
322
|
+
];
|
323
|
+
|
324
|
+
for (var key in prototypeMethods) prototype2method(prototypeMethods[key]);
|
325
|
+
|
326
|
+
|
327
|
+
module.exports = s;
|
328
|
+
|
329
|
+
},{"./camelize":1,"./capitalize":2,"./chars":3,"./chop":4,"./classify":5,"./clean":6,"./cleanDiacritics":7,"./count":8,"./dasherize":9,"./decapitalize":10,"./dedent":11,"./endsWith":12,"./escapeHTML":13,"./exports":14,"./helper/escapeRegExp":19,"./humanize":24,"./include":25,"./insert":26,"./isBlank":27,"./join":28,"./levenshtein":29,"./lines":30,"./lpad":31,"./lrpad":32,"./ltrim":33,"./naturalCmp":34,"./numberFormat":35,"./pad":36,"./pred":37,"./prune":38,"./quote":39,"./repeat":40,"./replaceAll":41,"./reverse":42,"./rpad":43,"./rtrim":44,"./slugify":45,"./splice":46,"./sprintf":47,"./startsWith":48,"./strLeft":49,"./strLeftBack":50,"./strRight":51,"./strRightBack":52,"./stripTags":53,"./succ":54,"./surround":55,"./swapCase":56,"./titleize":57,"./toBoolean":58,"./toNumber":59,"./toSentence":60,"./toSentenceSerial":61,"./trim":62,"./truncate":63,"./underscored":64,"./unescapeHTML":65,"./unquote":66,"./vsprintf":67,"./words":68,"./wrap":69}],16:[function(_dereq_,module,exports){
|
330
|
+
var makeString = _dereq_('./makeString');
|
331
|
+
|
332
|
+
module.exports = function adjacent(str, direction) {
|
333
|
+
str = makeString(str);
|
334
|
+
if (str.length === 0) {
|
335
|
+
return '';
|
336
|
+
}
|
337
|
+
return str.slice(0, -1) + String.fromCharCode(str.charCodeAt(str.length - 1) + direction);
|
338
|
+
};
|
339
|
+
|
340
|
+
},{"./makeString":21}],17:[function(_dereq_,module,exports){
|
341
|
+
var escapeRegExp = _dereq_('./escapeRegExp');
|
342
|
+
|
343
|
+
module.exports = function defaultToWhiteSpace(characters) {
|
344
|
+
if (characters == null)
|
345
|
+
return '\\s';
|
346
|
+
else if (characters.source)
|
347
|
+
return characters.source;
|
348
|
+
else
|
349
|
+
return '[' + escapeRegExp(characters) + ']';
|
350
|
+
};
|
351
|
+
|
352
|
+
},{"./escapeRegExp":19}],18:[function(_dereq_,module,exports){
|
353
|
+
/* We're explicitly defining the list of entities we want to escape.
|
354
|
+
nbsp is an HTML entity, but we don't want to escape all space characters in a string, hence its omission in this map.
|
355
|
+
|
356
|
+
*/
|
357
|
+
var escapeChars = {
|
358
|
+
'¢' : 'cent',
|
359
|
+
'£' : 'pound',
|
360
|
+
'¥' : 'yen',
|
361
|
+
'€': 'euro',
|
362
|
+
'©' :'copy',
|
363
|
+
'®' : 'reg',
|
364
|
+
'<' : 'lt',
|
365
|
+
'>' : 'gt',
|
366
|
+
'"' : 'quot',
|
367
|
+
'&' : 'amp',
|
368
|
+
"'": '#39'
|
369
|
+
};
|
370
|
+
|
371
|
+
module.exports = escapeChars;
|
372
|
+
|
373
|
+
},{}],19:[function(_dereq_,module,exports){
|
374
|
+
var makeString = _dereq_('./makeString');
|
375
|
+
|
376
|
+
module.exports = function escapeRegExp(str) {
|
377
|
+
return makeString(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
|
378
|
+
};
|
379
|
+
|
380
|
+
},{"./makeString":21}],20:[function(_dereq_,module,exports){
|
381
|
+
/*
|
382
|
+
We're explicitly defining the list of entities that might see in escape HTML strings
|
383
|
+
*/
|
384
|
+
var htmlEntities = {
|
385
|
+
nbsp: ' ',
|
386
|
+
cent: '¢',
|
387
|
+
pound: '£',
|
388
|
+
yen: '¥',
|
389
|
+
euro: '€',
|
390
|
+
copy: '©',
|
391
|
+
reg: '®',
|
392
|
+
lt: '<',
|
393
|
+
gt: '>',
|
394
|
+
quot: '"',
|
395
|
+
amp: '&',
|
396
|
+
apos: "'"
|
397
|
+
};
|
398
|
+
|
399
|
+
module.exports = htmlEntities;
|
400
|
+
|
401
|
+
},{}],21:[function(_dereq_,module,exports){
|
402
|
+
/**
|
403
|
+
* Ensure some object is a coerced to a string
|
404
|
+
**/
|
405
|
+
module.exports = function makeString(object) {
|
406
|
+
if (object == null) return '';
|
407
|
+
return '' + object;
|
408
|
+
};
|
409
|
+
|
410
|
+
},{}],22:[function(_dereq_,module,exports){
|
411
|
+
module.exports = function strRepeat(str, qty){
|
412
|
+
if (qty < 1) return '';
|
413
|
+
var result = '';
|
414
|
+
while (qty > 0) {
|
415
|
+
if (qty & 1) result += str;
|
416
|
+
qty >>= 1, str += str;
|
417
|
+
}
|
418
|
+
return result;
|
419
|
+
};
|
420
|
+
|
421
|
+
},{}],23:[function(_dereq_,module,exports){
|
422
|
+
module.exports = function toPositive(number) {
|
423
|
+
return number < 0 ? 0 : (+number || 0);
|
424
|
+
};
|
425
|
+
|
426
|
+
},{}],24:[function(_dereq_,module,exports){
|
427
|
+
var capitalize = _dereq_('./capitalize');
|
428
|
+
var underscored = _dereq_('./underscored');
|
429
|
+
var trim = _dereq_('./trim');
|
430
|
+
|
431
|
+
module.exports = function humanize(str) {
|
432
|
+
return capitalize(trim(underscored(str).replace(/_id$/, '').replace(/_/g, ' ')));
|
433
|
+
};
|
434
|
+
|
435
|
+
},{"./capitalize":2,"./trim":62,"./underscored":64}],25:[function(_dereq_,module,exports){
|
436
|
+
var makeString = _dereq_('./helper/makeString');
|
437
|
+
|
438
|
+
module.exports = function include(str, needle) {
|
439
|
+
if (needle === '') return true;
|
440
|
+
return makeString(str).indexOf(needle) !== -1;
|
441
|
+
};
|
442
|
+
|
443
|
+
},{"./helper/makeString":21}],26:[function(_dereq_,module,exports){
|
444
|
+
var splice = _dereq_('./splice');
|
445
|
+
|
446
|
+
module.exports = function insert(str, i, substr) {
|
447
|
+
return splice(str, i, 0, substr);
|
448
|
+
};
|
449
|
+
|
450
|
+
},{"./splice":46}],27:[function(_dereq_,module,exports){
|
451
|
+
var makeString = _dereq_('./helper/makeString');
|
452
|
+
|
453
|
+
module.exports = function isBlank(str) {
|
454
|
+
return (/^\s*$/).test(makeString(str));
|
455
|
+
};
|
456
|
+
|
457
|
+
},{"./helper/makeString":21}],28:[function(_dereq_,module,exports){
|
458
|
+
var makeString = _dereq_('./helper/makeString');
|
459
|
+
var slice = [].slice;
|
460
|
+
|
461
|
+
module.exports = function join() {
|
462
|
+
var args = slice.call(arguments),
|
463
|
+
separator = args.shift();
|
464
|
+
|
465
|
+
return args.join(makeString(separator));
|
466
|
+
};
|
467
|
+
|
468
|
+
},{"./helper/makeString":21}],29:[function(_dereq_,module,exports){
|
469
|
+
var makeString = _dereq_('./helper/makeString');
|
470
|
+
|
471
|
+
/**
|
472
|
+
* Based on the implementation here: https://github.com/hiddentao/fast-levenshtein
|
473
|
+
*/
|
474
|
+
module.exports = function levenshtein(str1, str2) {
|
475
|
+
'use strict';
|
476
|
+
str1 = makeString(str1);
|
477
|
+
str2 = makeString(str2);
|
478
|
+
|
479
|
+
// Short cut cases
|
480
|
+
if (str1 === str2) return 0;
|
481
|
+
if (!str1 || !str2) return Math.max(str1.length, str2.length);
|
482
|
+
|
483
|
+
// two rows
|
484
|
+
var prevRow = new Array(str2.length + 1);
|
485
|
+
|
486
|
+
// initialise previous row
|
487
|
+
for (var i = 0; i < prevRow.length; ++i) {
|
488
|
+
prevRow[i] = i;
|
489
|
+
}
|
490
|
+
|
491
|
+
// calculate current row distance from previous row
|
492
|
+
for (i = 0; i < str1.length; ++i) {
|
493
|
+
var nextCol = i + 1;
|
494
|
+
|
495
|
+
for (var j = 0; j < str2.length; ++j) {
|
496
|
+
var curCol = nextCol;
|
497
|
+
|
498
|
+
// substution
|
499
|
+
nextCol = prevRow[j] + ( (str1.charAt(i) === str2.charAt(j)) ? 0 : 1 );
|
500
|
+
// insertion
|
501
|
+
var tmp = curCol + 1;
|
502
|
+
if (nextCol > tmp) {
|
503
|
+
nextCol = tmp;
|
504
|
+
}
|
505
|
+
// deletion
|
506
|
+
tmp = prevRow[j + 1] + 1;
|
507
|
+
if (nextCol > tmp) {
|
508
|
+
nextCol = tmp;
|
509
|
+
}
|
510
|
+
|
511
|
+
// copy current col value into previous (in preparation for next iteration)
|
512
|
+
prevRow[j] = curCol;
|
513
|
+
}
|
514
|
+
|
515
|
+
// copy last col value into previous (in preparation for next iteration)
|
516
|
+
prevRow[j] = nextCol;
|
517
|
+
}
|
518
|
+
|
519
|
+
return nextCol;
|
520
|
+
};
|
521
|
+
|
522
|
+
},{"./helper/makeString":21}],30:[function(_dereq_,module,exports){
|
523
|
+
module.exports = function lines(str) {
|
524
|
+
if (str == null) return [];
|
525
|
+
return String(str).split(/\r\n?|\n/);
|
526
|
+
};
|
527
|
+
|
528
|
+
},{}],31:[function(_dereq_,module,exports){
|
529
|
+
var pad = _dereq_('./pad');
|
530
|
+
|
531
|
+
module.exports = function lpad(str, length, padStr) {
|
532
|
+
return pad(str, length, padStr);
|
533
|
+
};
|
534
|
+
|
535
|
+
},{"./pad":36}],32:[function(_dereq_,module,exports){
|
536
|
+
var pad = _dereq_('./pad');
|
537
|
+
|
538
|
+
module.exports = function lrpad(str, length, padStr) {
|
539
|
+
return pad(str, length, padStr, 'both');
|
540
|
+
};
|
541
|
+
|
542
|
+
},{"./pad":36}],33:[function(_dereq_,module,exports){
|
543
|
+
var makeString = _dereq_('./helper/makeString');
|
544
|
+
var defaultToWhiteSpace = _dereq_('./helper/defaultToWhiteSpace');
|
545
|
+
var nativeTrimLeft = String.prototype.trimLeft;
|
546
|
+
|
547
|
+
module.exports = function ltrim(str, characters) {
|
548
|
+
str = makeString(str);
|
549
|
+
if (!characters && nativeTrimLeft) return nativeTrimLeft.call(str);
|
550
|
+
characters = defaultToWhiteSpace(characters);
|
551
|
+
return str.replace(new RegExp('^' + characters + '+'), '');
|
552
|
+
};
|
553
|
+
|
554
|
+
},{"./helper/defaultToWhiteSpace":17,"./helper/makeString":21}],34:[function(_dereq_,module,exports){
|
555
|
+
module.exports = function naturalCmp(str1, str2) {
|
556
|
+
if (str1 == str2) return 0;
|
557
|
+
if (!str1) return -1;
|
558
|
+
if (!str2) return 1;
|
559
|
+
|
560
|
+
var cmpRegex = /(\.\d+|\d+|\D+)/g,
|
561
|
+
tokens1 = String(str1).match(cmpRegex),
|
562
|
+
tokens2 = String(str2).match(cmpRegex),
|
563
|
+
count = Math.min(tokens1.length, tokens2.length);
|
564
|
+
|
565
|
+
for (var i = 0; i < count; i++) {
|
566
|
+
var a = tokens1[i],
|
567
|
+
b = tokens2[i];
|
568
|
+
|
569
|
+
if (a !== b) {
|
570
|
+
var num1 = +a;
|
571
|
+
var num2 = +b;
|
572
|
+
if (num1 === num1 && num2 === num2) {
|
573
|
+
return num1 > num2 ? 1 : -1;
|
574
|
+
}
|
575
|
+
return a < b ? -1 : 1;
|
576
|
+
}
|
577
|
+
}
|
578
|
+
|
579
|
+
if (tokens1.length != tokens2.length)
|
580
|
+
return tokens1.length - tokens2.length;
|
581
|
+
|
582
|
+
return str1 < str2 ? -1 : 1;
|
583
|
+
};
|
584
|
+
|
585
|
+
},{}],35:[function(_dereq_,module,exports){
|
586
|
+
module.exports = function numberFormat(number, dec, dsep, tsep) {
|
587
|
+
if (isNaN(number) || number == null) return '';
|
588
|
+
|
589
|
+
number = number.toFixed(~~dec);
|
590
|
+
tsep = typeof tsep == 'string' ? tsep : ',';
|
591
|
+
|
592
|
+
var parts = number.split('.'),
|
593
|
+
fnums = parts[0],
|
594
|
+
decimals = parts[1] ? (dsep || '.') + parts[1] : '';
|
595
|
+
|
596
|
+
return fnums.replace(/(\d)(?=(?:\d{3})+$)/g, '$1' + tsep) + decimals;
|
597
|
+
};
|
598
|
+
|
599
|
+
},{}],36:[function(_dereq_,module,exports){
|
600
|
+
var makeString = _dereq_('./helper/makeString');
|
601
|
+
var strRepeat = _dereq_('./helper/strRepeat');
|
602
|
+
|
603
|
+
module.exports = function pad(str, length, padStr, type) {
|
604
|
+
str = makeString(str);
|
605
|
+
length = ~~length;
|
606
|
+
|
607
|
+
var padlen = 0;
|
608
|
+
|
609
|
+
if (!padStr)
|
610
|
+
padStr = ' ';
|
611
|
+
else if (padStr.length > 1)
|
612
|
+
padStr = padStr.charAt(0);
|
613
|
+
|
614
|
+
switch (type) {
|
615
|
+
case 'right':
|
616
|
+
padlen = length - str.length;
|
617
|
+
return str + strRepeat(padStr, padlen);
|
618
|
+
case 'both':
|
619
|
+
padlen = length - str.length;
|
620
|
+
return strRepeat(padStr, Math.ceil(padlen / 2)) + str + strRepeat(padStr, Math.floor(padlen / 2));
|
621
|
+
default: // 'left'
|
622
|
+
padlen = length - str.length;
|
623
|
+
return strRepeat(padStr, padlen) + str;
|
624
|
+
}
|
625
|
+
};
|
626
|
+
|
627
|
+
},{"./helper/makeString":21,"./helper/strRepeat":22}],37:[function(_dereq_,module,exports){
|
628
|
+
var adjacent = _dereq_('./helper/adjacent');
|
629
|
+
|
630
|
+
module.exports = function succ(str) {
|
631
|
+
return adjacent(str, -1);
|
632
|
+
};
|
633
|
+
|
634
|
+
},{"./helper/adjacent":16}],38:[function(_dereq_,module,exports){
|
635
|
+
/**
|
636
|
+
* _s.prune: a more elegant version of truncate
|
637
|
+
* prune extra chars, never leaving a half-chopped word.
|
638
|
+
* @author github.com/rwz
|
639
|
+
*/
|
640
|
+
var makeString = _dereq_('./helper/makeString');
|
641
|
+
var rtrim = _dereq_('./rtrim');
|
642
|
+
|
643
|
+
module.exports = function prune(str, length, pruneStr) {
|
644
|
+
str = makeString(str);
|
645
|
+
length = ~~length;
|
646
|
+
pruneStr = pruneStr != null ? String(pruneStr) : '...';
|
647
|
+
|
648
|
+
if (str.length <= length) return str;
|
649
|
+
|
650
|
+
var tmpl = function(c) {
|
651
|
+
return c.toUpperCase() !== c.toLowerCase() ? 'A' : ' ';
|
652
|
+
},
|
653
|
+
template = str.slice(0, length + 1).replace(/.(?=\W*\w*$)/g, tmpl); // 'Hello, world' -> 'HellAA AAAAA'
|
654
|
+
|
655
|
+
if (template.slice(template.length - 2).match(/\w\w/))
|
656
|
+
template = template.replace(/\s*\S+$/, '');
|
657
|
+
else
|
658
|
+
template = rtrim(template.slice(0, template.length - 1));
|
659
|
+
|
660
|
+
return (template + pruneStr).length > str.length ? str : str.slice(0, template.length) + pruneStr;
|
661
|
+
};
|
662
|
+
|
663
|
+
},{"./helper/makeString":21,"./rtrim":44}],39:[function(_dereq_,module,exports){
|
664
|
+
var surround = _dereq_('./surround');
|
665
|
+
|
666
|
+
module.exports = function quote(str, quoteChar) {
|
667
|
+
return surround(str, quoteChar || '"');
|
668
|
+
};
|
669
|
+
|
670
|
+
},{"./surround":55}],40:[function(_dereq_,module,exports){
|
671
|
+
var makeString = _dereq_('./helper/makeString');
|
672
|
+
var strRepeat = _dereq_('./helper/strRepeat');
|
673
|
+
|
674
|
+
module.exports = function repeat(str, qty, separator) {
|
675
|
+
str = makeString(str);
|
676
|
+
|
677
|
+
qty = ~~qty;
|
678
|
+
|
679
|
+
// using faster implementation if separator is not needed;
|
680
|
+
if (separator == null) return strRepeat(str, qty);
|
681
|
+
|
682
|
+
// this one is about 300x slower in Google Chrome
|
683
|
+
for (var repeat = []; qty > 0; repeat[--qty] = str) {}
|
684
|
+
return repeat.join(separator);
|
685
|
+
};
|
686
|
+
|
687
|
+
},{"./helper/makeString":21,"./helper/strRepeat":22}],41:[function(_dereq_,module,exports){
|
688
|
+
var makeString = _dereq_('./helper/makeString');
|
689
|
+
|
690
|
+
module.exports = function replaceAll(str, find, replace, ignorecase) {
|
691
|
+
var flags = (ignorecase === true)?'gi':'g';
|
692
|
+
var reg = new RegExp(find, flags);
|
693
|
+
|
694
|
+
return makeString(str).replace(reg, replace);
|
695
|
+
};
|
696
|
+
|
697
|
+
},{"./helper/makeString":21}],42:[function(_dereq_,module,exports){
|
698
|
+
var chars = _dereq_('./chars');
|
699
|
+
|
700
|
+
module.exports = function reverse(str) {
|
701
|
+
return chars(str).reverse().join('');
|
702
|
+
};
|
703
|
+
|
704
|
+
},{"./chars":3}],43:[function(_dereq_,module,exports){
|
705
|
+
var pad = _dereq_('./pad');
|
706
|
+
|
707
|
+
module.exports = function rpad(str, length, padStr) {
|
708
|
+
return pad(str, length, padStr, 'right');
|
709
|
+
};
|
710
|
+
|
711
|
+
},{"./pad":36}],44:[function(_dereq_,module,exports){
|
712
|
+
var makeString = _dereq_('./helper/makeString');
|
713
|
+
var defaultToWhiteSpace = _dereq_('./helper/defaultToWhiteSpace');
|
714
|
+
var nativeTrimRight = String.prototype.trimRight;
|
715
|
+
|
716
|
+
module.exports = function rtrim(str, characters) {
|
717
|
+
str = makeString(str);
|
718
|
+
if (!characters && nativeTrimRight) return nativeTrimRight.call(str);
|
719
|
+
characters = defaultToWhiteSpace(characters);
|
720
|
+
return str.replace(new RegExp(characters + '+$'), '');
|
721
|
+
};
|
722
|
+
|
723
|
+
},{"./helper/defaultToWhiteSpace":17,"./helper/makeString":21}],45:[function(_dereq_,module,exports){
|
724
|
+
var makeString = _dereq_('./helper/makeString');
|
725
|
+
var defaultToWhiteSpace = _dereq_('./helper/defaultToWhiteSpace');
|
726
|
+
var trim = _dereq_('./trim');
|
727
|
+
var dasherize = _dereq_('./dasherize');
|
728
|
+
var cleanDiacritics = _dereq_("./cleanDiacritics");
|
729
|
+
|
730
|
+
module.exports = function slugify(str) {
|
731
|
+
return trim(dasherize(cleanDiacritics(str).replace(/[^\w\s-]/g, '-').toLowerCase()), '-');
|
732
|
+
};
|
733
|
+
|
734
|
+
},{"./cleanDiacritics":7,"./dasherize":9,"./helper/defaultToWhiteSpace":17,"./helper/makeString":21,"./trim":62}],46:[function(_dereq_,module,exports){
|
735
|
+
var chars = _dereq_('./chars');
|
736
|
+
|
737
|
+
module.exports = function splice(str, i, howmany, substr) {
|
738
|
+
var arr = chars(str);
|
739
|
+
arr.splice(~~i, ~~howmany, substr);
|
740
|
+
return arr.join('');
|
741
|
+
};
|
742
|
+
|
743
|
+
},{"./chars":3}],47:[function(_dereq_,module,exports){
|
744
|
+
// sprintf() for JavaScript 0.7-beta1
|
745
|
+
// http://www.diveintojavascript.com/projects/javascript-sprintf
|
746
|
+
//
|
747
|
+
// Copyright (c) Alexandru Marasteanu <alexaholic [at) gmail (dot] com>
|
748
|
+
// All rights reserved.
|
749
|
+
var strRepeat = _dereq_('./helper/strRepeat');
|
750
|
+
var toString = Object.prototype.toString;
|
751
|
+
var sprintf = (function() {
|
752
|
+
function get_type(variable) {
|
753
|
+
return toString.call(variable).slice(8, -1).toLowerCase();
|
754
|
+
}
|
755
|
+
|
756
|
+
var str_repeat = strRepeat;
|
757
|
+
|
758
|
+
var str_format = function() {
|
759
|
+
if (!str_format.cache.hasOwnProperty(arguments[0])) {
|
760
|
+
str_format.cache[arguments[0]] = str_format.parse(arguments[0]);
|
761
|
+
}
|
762
|
+
return str_format.format.call(null, str_format.cache[arguments[0]], arguments);
|
763
|
+
};
|
764
|
+
|
765
|
+
str_format.format = function(parse_tree, argv) {
|
766
|
+
var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length;
|
767
|
+
for (i = 0; i < tree_length; i++) {
|
768
|
+
node_type = get_type(parse_tree[i]);
|
769
|
+
if (node_type === 'string') {
|
770
|
+
output.push(parse_tree[i]);
|
771
|
+
}
|
772
|
+
else if (node_type === 'array') {
|
773
|
+
match = parse_tree[i]; // convenience purposes only
|
774
|
+
if (match[2]) { // keyword argument
|
775
|
+
arg = argv[cursor];
|
776
|
+
for (k = 0; k < match[2].length; k++) {
|
777
|
+
if (!arg.hasOwnProperty(match[2][k])) {
|
778
|
+
throw new Error(sprintf('[_.sprintf] property "%s" does not exist', match[2][k]));
|
779
|
+
}
|
780
|
+
arg = arg[match[2][k]];
|
781
|
+
}
|
782
|
+
} else if (match[1]) { // positional argument (explicit)
|
783
|
+
arg = argv[match[1]];
|
784
|
+
}
|
785
|
+
else { // positional argument (implicit)
|
786
|
+
arg = argv[cursor++];
|
787
|
+
}
|
788
|
+
|
789
|
+
if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) {
|
790
|
+
throw new Error(sprintf('[_.sprintf] expecting number but found %s', get_type(arg)));
|
791
|
+
}
|
792
|
+
switch (match[8]) {
|
793
|
+
case 'b': arg = arg.toString(2); break;
|
794
|
+
case 'c': arg = String.fromCharCode(arg); break;
|
795
|
+
case 'd': arg = parseInt(arg, 10); break;
|
796
|
+
case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break;
|
797
|
+
case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break;
|
798
|
+
case 'o': arg = arg.toString(8); break;
|
799
|
+
case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break;
|
800
|
+
case 'u': arg = Math.abs(arg); break;
|
801
|
+
case 'x': arg = arg.toString(16); break;
|
802
|
+
case 'X': arg = arg.toString(16).toUpperCase(); break;
|
803
|
+
}
|
804
|
+
arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg);
|
805
|
+
pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' ';
|
806
|
+
pad_length = match[6] - String(arg).length;
|
807
|
+
pad = match[6] ? str_repeat(pad_character, pad_length) : '';
|
808
|
+
output.push(match[5] ? arg + pad : pad + arg);
|
809
|
+
}
|
810
|
+
}
|
811
|
+
return output.join('');
|
812
|
+
};
|
813
|
+
|
814
|
+
str_format.cache = {};
|
815
|
+
|
816
|
+
str_format.parse = function(fmt) {
|
817
|
+
var _fmt = fmt, match = [], parse_tree = [], arg_names = 0;
|
818
|
+
while (_fmt) {
|
819
|
+
if ((match = /^[^\x25]+/.exec(_fmt)) !== null) {
|
820
|
+
parse_tree.push(match[0]);
|
821
|
+
}
|
822
|
+
else if ((match = /^\x25{2}/.exec(_fmt)) !== null) {
|
823
|
+
parse_tree.push('%');
|
824
|
+
}
|
825
|
+
else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) {
|
826
|
+
if (match[2]) {
|
827
|
+
arg_names |= 1;
|
828
|
+
var field_list = [], replacement_field = match[2], field_match = [];
|
829
|
+
if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
|
830
|
+
field_list.push(field_match[1]);
|
831
|
+
while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
|
832
|
+
if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
|
833
|
+
field_list.push(field_match[1]);
|
834
|
+
}
|
835
|
+
else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) {
|
836
|
+
field_list.push(field_match[1]);
|
837
|
+
}
|
838
|
+
else {
|
839
|
+
throw new Error('[_.sprintf] huh?');
|
840
|
+
}
|
841
|
+
}
|
842
|
+
}
|
843
|
+
else {
|
844
|
+
throw new Error('[_.sprintf] huh?');
|
845
|
+
}
|
846
|
+
match[2] = field_list;
|
847
|
+
}
|
848
|
+
else {
|
849
|
+
arg_names |= 2;
|
850
|
+
}
|
851
|
+
if (arg_names === 3) {
|
852
|
+
throw new Error('[_.sprintf] mixing positional and named placeholders is not (yet) supported');
|
853
|
+
}
|
854
|
+
parse_tree.push(match);
|
855
|
+
}
|
856
|
+
else {
|
857
|
+
throw new Error('[_.sprintf] huh?');
|
858
|
+
}
|
859
|
+
_fmt = _fmt.substring(match[0].length);
|
860
|
+
}
|
861
|
+
return parse_tree;
|
862
|
+
};
|
863
|
+
|
864
|
+
return str_format;
|
865
|
+
})();
|
866
|
+
|
867
|
+
module.exports = sprintf;
|
868
|
+
|
869
|
+
},{"./helper/strRepeat":22}],48:[function(_dereq_,module,exports){
|
870
|
+
var makeString = _dereq_('./helper/makeString');
|
871
|
+
var toPositive = _dereq_('./helper/toPositive');
|
872
|
+
|
873
|
+
module.exports = function startsWith(str, starts, position) {
|
874
|
+
str = makeString(str);
|
875
|
+
starts = '' + starts;
|
876
|
+
position = position == null ? 0 : Math.min(toPositive(position), str.length);
|
877
|
+
return str.lastIndexOf(starts, position) === position;
|
878
|
+
};
|
879
|
+
|
880
|
+
},{"./helper/makeString":21,"./helper/toPositive":23}],49:[function(_dereq_,module,exports){
|
881
|
+
var makeString = _dereq_('./helper/makeString');
|
882
|
+
|
883
|
+
module.exports = function strLeft(str, sep) {
|
884
|
+
str = makeString(str);
|
885
|
+
sep = makeString(sep);
|
886
|
+
var pos = !sep ? -1 : str.indexOf(sep);
|
887
|
+
return~ pos ? str.slice(0, pos) : str;
|
888
|
+
};
|
889
|
+
|
890
|
+
},{"./helper/makeString":21}],50:[function(_dereq_,module,exports){
|
891
|
+
var makeString = _dereq_('./helper/makeString');
|
892
|
+
|
893
|
+
module.exports = function strLeftBack(str, sep) {
|
894
|
+
str = makeString(str);
|
895
|
+
sep = makeString(sep);
|
896
|
+
var pos = str.lastIndexOf(sep);
|
897
|
+
return~ pos ? str.slice(0, pos) : str;
|
898
|
+
};
|
899
|
+
|
900
|
+
},{"./helper/makeString":21}],51:[function(_dereq_,module,exports){
|
901
|
+
var makeString = _dereq_('./helper/makeString');
|
902
|
+
|
903
|
+
module.exports = function strRight(str, sep) {
|
904
|
+
str = makeString(str);
|
905
|
+
sep = makeString(sep);
|
906
|
+
var pos = !sep ? -1 : str.indexOf(sep);
|
907
|
+
return~ pos ? str.slice(pos + sep.length, str.length) : str;
|
908
|
+
};
|
909
|
+
|
910
|
+
},{"./helper/makeString":21}],52:[function(_dereq_,module,exports){
|
911
|
+
var makeString = _dereq_('./helper/makeString');
|
912
|
+
|
913
|
+
module.exports = function strRightBack(str, sep) {
|
914
|
+
str = makeString(str);
|
915
|
+
sep = makeString(sep);
|
916
|
+
var pos = !sep ? -1 : str.lastIndexOf(sep);
|
917
|
+
return~ pos ? str.slice(pos + sep.length, str.length) : str;
|
918
|
+
};
|
919
|
+
|
920
|
+
},{"./helper/makeString":21}],53:[function(_dereq_,module,exports){
|
921
|
+
var makeString = _dereq_('./helper/makeString');
|
922
|
+
|
923
|
+
module.exports = function stripTags(str) {
|
924
|
+
return makeString(str).replace(/<\/?[^>]+>/g, '');
|
925
|
+
};
|
926
|
+
|
927
|
+
},{"./helper/makeString":21}],54:[function(_dereq_,module,exports){
|
928
|
+
var adjacent = _dereq_('./helper/adjacent');
|
929
|
+
|
930
|
+
module.exports = function succ(str) {
|
931
|
+
return adjacent(str, 1);
|
932
|
+
};
|
933
|
+
|
934
|
+
},{"./helper/adjacent":16}],55:[function(_dereq_,module,exports){
|
935
|
+
module.exports = function surround(str, wrapper) {
|
936
|
+
return [wrapper, str, wrapper].join('');
|
937
|
+
};
|
938
|
+
|
939
|
+
},{}],56:[function(_dereq_,module,exports){
|
940
|
+
var makeString = _dereq_('./helper/makeString');
|
941
|
+
|
942
|
+
module.exports = function swapCase(str) {
|
943
|
+
return makeString(str).replace(/\S/g, function(c) {
|
944
|
+
return c === c.toUpperCase() ? c.toLowerCase() : c.toUpperCase();
|
945
|
+
});
|
946
|
+
};
|
947
|
+
|
948
|
+
},{"./helper/makeString":21}],57:[function(_dereq_,module,exports){
|
949
|
+
var makeString = _dereq_('./helper/makeString');
|
950
|
+
|
951
|
+
module.exports = function titleize(str) {
|
952
|
+
return makeString(str).toLowerCase().replace(/(?:^|\s|-)\S/g, function(c) {
|
953
|
+
return c.toUpperCase();
|
954
|
+
});
|
955
|
+
};
|
956
|
+
|
957
|
+
},{"./helper/makeString":21}],58:[function(_dereq_,module,exports){
|
958
|
+
var trim = _dereq_('./trim');
|
959
|
+
|
960
|
+
function boolMatch(s, matchers) {
|
961
|
+
var i, matcher, down = s.toLowerCase();
|
962
|
+
matchers = [].concat(matchers);
|
963
|
+
for (i = 0; i < matchers.length; i += 1) {
|
964
|
+
matcher = matchers[i];
|
965
|
+
if (!matcher) continue;
|
966
|
+
if (matcher.test && matcher.test(s)) return true;
|
967
|
+
if (matcher.toLowerCase() === down) return true;
|
968
|
+
}
|
969
|
+
}
|
970
|
+
|
971
|
+
module.exports = function toBoolean(str, trueValues, falseValues) {
|
972
|
+
if (typeof str === "number") str = "" + str;
|
973
|
+
if (typeof str !== "string") return !!str;
|
974
|
+
str = trim(str);
|
975
|
+
if (boolMatch(str, trueValues || ["true", "1"])) return true;
|
976
|
+
if (boolMatch(str, falseValues || ["false", "0"])) return false;
|
977
|
+
};
|
978
|
+
|
979
|
+
},{"./trim":62}],59:[function(_dereq_,module,exports){
|
980
|
+
var trim = _dereq_('./trim');
|
981
|
+
|
982
|
+
module.exports = function toNumber(num, precision) {
|
983
|
+
if (num == null) return 0;
|
984
|
+
var factor = Math.pow(10, isFinite(precision) ? precision : 0);
|
985
|
+
return Math.round(num * factor) / factor;
|
986
|
+
};
|
987
|
+
|
988
|
+
},{"./trim":62}],60:[function(_dereq_,module,exports){
|
989
|
+
var rtrim = _dereq_('./rtrim');
|
990
|
+
|
991
|
+
module.exports = function toSentence(array, separator, lastSeparator, serial) {
|
992
|
+
separator = separator || ', ';
|
993
|
+
lastSeparator = lastSeparator || ' and ';
|
994
|
+
var a = array.slice(),
|
995
|
+
lastMember = a.pop();
|
996
|
+
|
997
|
+
if (array.length > 2 && serial) lastSeparator = rtrim(separator) + lastSeparator;
|
998
|
+
|
999
|
+
return a.length ? a.join(separator) + lastSeparator + lastMember : lastMember;
|
1000
|
+
};
|
1001
|
+
|
1002
|
+
},{"./rtrim":44}],61:[function(_dereq_,module,exports){
|
1003
|
+
var toSentence = _dereq_('./toSentence');
|
1004
|
+
|
1005
|
+
module.exports = function toSentenceSerial(array, sep, lastSep) {
|
1006
|
+
return toSentence(array, sep, lastSep, true);
|
1007
|
+
};
|
1008
|
+
|
1009
|
+
},{"./toSentence":60}],62:[function(_dereq_,module,exports){
|
1010
|
+
var makeString = _dereq_('./helper/makeString');
|
1011
|
+
var defaultToWhiteSpace = _dereq_('./helper/defaultToWhiteSpace');
|
1012
|
+
var nativeTrim = String.prototype.trim;
|
1013
|
+
|
1014
|
+
module.exports = function trim(str, characters) {
|
1015
|
+
str = makeString(str);
|
1016
|
+
if (!characters && nativeTrim) return nativeTrim.call(str);
|
1017
|
+
characters = defaultToWhiteSpace(characters);
|
1018
|
+
return str.replace(new RegExp('^' + characters + '+|' + characters + '+$', 'g'), '');
|
1019
|
+
};
|
1020
|
+
|
1021
|
+
},{"./helper/defaultToWhiteSpace":17,"./helper/makeString":21}],63:[function(_dereq_,module,exports){
|
1022
|
+
var makeString = _dereq_('./helper/makeString');
|
1023
|
+
|
1024
|
+
module.exports = function truncate(str, length, truncateStr) {
|
1025
|
+
str = makeString(str);
|
1026
|
+
truncateStr = truncateStr || '...';
|
1027
|
+
length = ~~length;
|
1028
|
+
return str.length > length ? str.slice(0, length) + truncateStr : str;
|
1029
|
+
};
|
1030
|
+
|
1031
|
+
},{"./helper/makeString":21}],64:[function(_dereq_,module,exports){
|
1032
|
+
var trim = _dereq_('./trim');
|
1033
|
+
|
1034
|
+
module.exports = function underscored(str) {
|
1035
|
+
return trim(str).replace(/([a-z\d])([A-Z]+)/g, '$1_$2').replace(/[-\s]+/g, '_').toLowerCase();
|
1036
|
+
};
|
1037
|
+
|
1038
|
+
},{"./trim":62}],65:[function(_dereq_,module,exports){
|
1039
|
+
var makeString = _dereq_('./helper/makeString');
|
1040
|
+
var htmlEntities = _dereq_('./helper/htmlEntities');
|
1041
|
+
|
1042
|
+
module.exports = function unescapeHTML(str) {
|
1043
|
+
return makeString(str).replace(/\&([^;]+);/g, function(entity, entityCode) {
|
1044
|
+
var match;
|
1045
|
+
|
1046
|
+
if (entityCode in htmlEntities) {
|
1047
|
+
return htmlEntities[entityCode];
|
1048
|
+
} else if (match = entityCode.match(/^#x([\da-fA-F]+)$/)) {
|
1049
|
+
return String.fromCharCode(parseInt(match[1], 16));
|
1050
|
+
} else if (match = entityCode.match(/^#(\d+)$/)) {
|
1051
|
+
return String.fromCharCode(~~match[1]);
|
1052
|
+
} else {
|
1053
|
+
return entity;
|
1054
|
+
}
|
1055
|
+
});
|
1056
|
+
};
|
1057
|
+
|
1058
|
+
},{"./helper/htmlEntities":20,"./helper/makeString":21}],66:[function(_dereq_,module,exports){
|
1059
|
+
module.exports = function unquote(str, quoteChar) {
|
1060
|
+
quoteChar = quoteChar || '"';
|
1061
|
+
if (str[0] === quoteChar && str[str.length - 1] === quoteChar)
|
1062
|
+
return str.slice(1, str.length - 1);
|
1063
|
+
else return str;
|
1064
|
+
};
|
1065
|
+
|
1066
|
+
},{}],67:[function(_dereq_,module,exports){
|
1067
|
+
var sprintf = _dereq_('./sprintf');
|
1068
|
+
|
1069
|
+
module.exports = function vsprintf(fmt, argv) {
|
1070
|
+
argv.unshift(fmt);
|
1071
|
+
return sprintf.apply(null, argv);
|
1072
|
+
};
|
1073
|
+
|
1074
|
+
},{"./sprintf":47}],68:[function(_dereq_,module,exports){
|
1075
|
+
var isBlank = _dereq_('./isBlank');
|
1076
|
+
var trim = _dereq_('./trim');
|
1077
|
+
|
1078
|
+
module.exports = function words(str, delimiter) {
|
1079
|
+
if (isBlank(str)) return [];
|
1080
|
+
return trim(str, delimiter).split(delimiter || /\s+/);
|
1081
|
+
};
|
1082
|
+
|
1083
|
+
},{"./isBlank":27,"./trim":62}],69:[function(_dereq_,module,exports){
|
1084
|
+
// Wrap
|
1085
|
+
// wraps a string by a certain width
|
1086
|
+
|
1087
|
+
makeString = _dereq_('./helper/makeString');
|
1088
|
+
|
1089
|
+
module.exports = function wrap(str, options){
|
1090
|
+
str = makeString(str);
|
1091
|
+
|
1092
|
+
options = options || {};
|
1093
|
+
|
1094
|
+
width = options.width || 75;
|
1095
|
+
seperator = options.seperator || '\n';
|
1096
|
+
cut = options.cut || false;
|
1097
|
+
preserveSpaces = options.preserveSpaces || false;
|
1098
|
+
trailingSpaces = options.trailingSpaces || false;
|
1099
|
+
|
1100
|
+
if(width <= 0){
|
1101
|
+
return str;
|
1102
|
+
}
|
1103
|
+
|
1104
|
+
else if(!cut){
|
1105
|
+
|
1106
|
+
words = str.split(" ");
|
1107
|
+
result = "";
|
1108
|
+
current_column = 0;
|
1109
|
+
|
1110
|
+
while(words.length > 0){
|
1111
|
+
|
1112
|
+
// if adding a space and the next word would cause this line to be longer than width...
|
1113
|
+
if(1 + words[0].length + current_column > width){
|
1114
|
+
//start a new line if this line is not already empty
|
1115
|
+
if(current_column > 0){
|
1116
|
+
// add a space at the end of the line is preserveSpaces is true
|
1117
|
+
if (preserveSpaces){
|
1118
|
+
result += ' ';
|
1119
|
+
current_column++;
|
1120
|
+
}
|
1121
|
+
// fill the rest of the line with spaces if trailingSpaces option is true
|
1122
|
+
else if(trailingSpaces){
|
1123
|
+
while(current_column < width){
|
1124
|
+
result += ' ';
|
1125
|
+
current_column++;
|
1126
|
+
}
|
1127
|
+
}
|
1128
|
+
//start new line
|
1129
|
+
result += seperator;
|
1130
|
+
current_column = 0;
|
1131
|
+
}
|
1132
|
+
}
|
1133
|
+
|
1134
|
+
// if not at the begining of the line, add a space in front of the word
|
1135
|
+
if(current_column > 0){
|
1136
|
+
result += " ";
|
1137
|
+
current_column++;
|
1138
|
+
}
|
1139
|
+
|
1140
|
+
// tack on the next word, update current column, a pop words array
|
1141
|
+
result += words[0];
|
1142
|
+
current_column += words[0].length;
|
1143
|
+
words.shift();
|
1144
|
+
|
1145
|
+
}
|
1146
|
+
|
1147
|
+
// fill the rest of the line with spaces if trailingSpaces option is true
|
1148
|
+
if(trailingSpaces){
|
1149
|
+
while(current_column < width){
|
1150
|
+
result += ' ';
|
1151
|
+
current_column++;
|
1152
|
+
}
|
1153
|
+
}
|
1154
|
+
|
1155
|
+
return result;
|
1156
|
+
|
1157
|
+
}
|
1158
|
+
|
1159
|
+
else {
|
1160
|
+
|
1161
|
+
index = 0;
|
1162
|
+
result = "";
|
1163
|
+
|
1164
|
+
// walk through each character and add seperators where appropriate
|
1165
|
+
while(index < str.length){
|
1166
|
+
if(index % width == 0 && index > 0){
|
1167
|
+
result += seperator;
|
1168
|
+
}
|
1169
|
+
result += str.charAt(index);
|
1170
|
+
index++;
|
1171
|
+
}
|
1172
|
+
|
1173
|
+
// fill the rest of the line with spaces if trailingSpaces option is true
|
1174
|
+
if(trailingSpaces){
|
1175
|
+
while(index % width > 0){
|
1176
|
+
result += ' ';
|
1177
|
+
index++;
|
1178
|
+
}
|
1179
|
+
}
|
1180
|
+
|
1181
|
+
return result;
|
1182
|
+
}
|
1183
|
+
};
|
1184
|
+
},{"./helper/makeString":21}]},{},[15])
|
1185
|
+
(15)
|
1186
|
+
});
|