@jaredwray/fumanchu 2.1.0 → 3.0.0
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.
- package/README.md +47 -15
- package/dist/index.d.ts +26 -0
- package/dist/index.js +2073 -0
- package/package.json +14 -13
- package/helpers.js +0 -61
- package/index.d.ts +0 -4
- package/index.js +0 -8
- package/lib/array.js +0 -822
- package/lib/code.js +0 -80
- package/lib/collection.js +0 -67
- package/lib/comparison.js +0 -604
- package/lib/date.js +0 -24
- package/lib/fs.js +0 -75
- package/lib/html.js +0 -218
- package/lib/i18n.js +0 -48
- package/lib/index.js +0 -24
- package/lib/inflection.js +0 -78
- package/lib/logging.js +0 -8
- package/lib/markdown.js +0 -99
- package/lib/match.js +0 -61
- package/lib/math.js +0 -285
- package/lib/md.js +0 -119
- package/lib/misc.js +0 -77
- package/lib/number.js +0 -204
- package/lib/object.js +0 -290
- package/lib/path.js +0 -181
- package/lib/regex.js +0 -50
- package/lib/string.js +0 -769
- package/lib/url.js +0 -132
- package/lib/utils/falsey.js +0 -46
- package/lib/utils/html.js +0 -82
- package/lib/utils/index.js +0 -91
- package/lib/utils/utils.js +0 -42
package/lib/comparison.js
DELETED
|
@@ -1,604 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var has = require('has-value');
|
|
4
|
-
var util = require('handlebars-utils');
|
|
5
|
-
var utils = require('./utils');
|
|
6
|
-
var helpers = module.exports;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Helper that renders the block if **both** of the given values
|
|
10
|
-
* are truthy. If an inverse block is specified it will be rendered
|
|
11
|
-
* when falsy. Works as a block helper, inline helper or
|
|
12
|
-
* subexpression.
|
|
13
|
-
*
|
|
14
|
-
* ```handlebars
|
|
15
|
-
* <!-- {great: true, magnificent: true} -->
|
|
16
|
-
* {{#and great magnificent}}A{{else}}B{{/and}}
|
|
17
|
-
* <!-- results in: 'A' -->
|
|
18
|
-
* ```
|
|
19
|
-
* @param {any} `a`
|
|
20
|
-
* @param {any} `b`
|
|
21
|
-
* @param {Object} `options` Handlebars provided options object
|
|
22
|
-
* @return {String}
|
|
23
|
-
* @block
|
|
24
|
-
* @api public
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
helpers.and = function() {
|
|
28
|
-
var len = arguments.length - 1;
|
|
29
|
-
var options = arguments[len];
|
|
30
|
-
var val = true;
|
|
31
|
-
|
|
32
|
-
for (var i = 0; i < len; i++) {
|
|
33
|
-
if (!arguments[i]) {
|
|
34
|
-
val = false;
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return util.value(val, this, options);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Render a block when a comparison of the first and third
|
|
44
|
-
* arguments returns true. The second argument is
|
|
45
|
-
* the [arithemetic operator][operators] to use. You may also
|
|
46
|
-
* optionally specify an inverse block to render when falsy.
|
|
47
|
-
*
|
|
48
|
-
* @param `a`
|
|
49
|
-
* @param `operator` The operator to use. Operators must be enclosed in quotes: `">"`, `"="`, `"<="`, and so on.
|
|
50
|
-
* @param `b`
|
|
51
|
-
* @param {Object} `options` Handlebars provided options object
|
|
52
|
-
* @return {String} Block, or if specified the inverse block is rendered if falsey.
|
|
53
|
-
* @block
|
|
54
|
-
* @api public
|
|
55
|
-
*/
|
|
56
|
-
|
|
57
|
-
helpers.compare = function(a, operator, b, options) {
|
|
58
|
-
/*eslint eqeqeq: 0*/
|
|
59
|
-
|
|
60
|
-
if (arguments.length < 4) {
|
|
61
|
-
throw new Error('handlebars Helper {{compare}} expects 4 arguments');
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
var result;
|
|
65
|
-
switch (operator) {
|
|
66
|
-
case '==':
|
|
67
|
-
result = a == b;
|
|
68
|
-
break;
|
|
69
|
-
case '===':
|
|
70
|
-
result = a === b;
|
|
71
|
-
break;
|
|
72
|
-
case '!=':
|
|
73
|
-
result = a != b;
|
|
74
|
-
break;
|
|
75
|
-
case '!==':
|
|
76
|
-
result = a !== b;
|
|
77
|
-
break;
|
|
78
|
-
case '<':
|
|
79
|
-
result = a < b;
|
|
80
|
-
break;
|
|
81
|
-
case '>':
|
|
82
|
-
result = a > b;
|
|
83
|
-
break;
|
|
84
|
-
case '<=':
|
|
85
|
-
result = a <= b;
|
|
86
|
-
break;
|
|
87
|
-
case '>=':
|
|
88
|
-
result = a >= b;
|
|
89
|
-
break;
|
|
90
|
-
case 'typeof':
|
|
91
|
-
result = typeof a === b;
|
|
92
|
-
break;
|
|
93
|
-
default: {
|
|
94
|
-
throw new Error('helper {{compare}}: invalid operator: `' + operator + '`');
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return util.value(result, this, options);
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Block helper that renders the block if `collection` has the
|
|
103
|
-
* given `value`, using strict equality (`===`) for comparison,
|
|
104
|
-
* otherwise the inverse block is rendered (if specified). If a
|
|
105
|
-
* `startIndex` is specified and is negative, it is used as the
|
|
106
|
-
* offset from the end of the collection.
|
|
107
|
-
*
|
|
108
|
-
* ```handlebars
|
|
109
|
-
* <!-- array = ['a', 'b', 'c'] -->
|
|
110
|
-
* {{#contains array "d"}}
|
|
111
|
-
* This will not be rendered.
|
|
112
|
-
* {{else}}
|
|
113
|
-
* This will be rendered.
|
|
114
|
-
* {{/contains}}
|
|
115
|
-
* ```
|
|
116
|
-
* @param {Array|Object|String} `collection` The collection to iterate over.
|
|
117
|
-
* @param {any} `value` The value to check for.
|
|
118
|
-
* @param {Number} `[startIndex=0]` Optionally define the starting index.
|
|
119
|
-
* @param {Object} `options` Handlebars provided options object.
|
|
120
|
-
* @block
|
|
121
|
-
* @api public
|
|
122
|
-
*/
|
|
123
|
-
|
|
124
|
-
helpers.contains = function(collection, value, startIndex, options) {
|
|
125
|
-
if (typeof startIndex === 'object') {
|
|
126
|
-
options = startIndex;
|
|
127
|
-
startIndex = undefined;
|
|
128
|
-
}
|
|
129
|
-
var val = utils.contains(collection, value, startIndex);
|
|
130
|
-
return util.value(val, this, options);
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Returns the first value that is not undefined, otherwise the "default" value is returned.
|
|
135
|
-
*
|
|
136
|
-
* @param {any} `value`
|
|
137
|
-
* @param {any} `defaultValue`
|
|
138
|
-
* @return {String}
|
|
139
|
-
* @alias .or
|
|
140
|
-
* @api public
|
|
141
|
-
*/
|
|
142
|
-
|
|
143
|
-
helpers.default = function() {
|
|
144
|
-
for (var i = 0; i < arguments.length - 1; i++) {
|
|
145
|
-
if (arguments[i] != null) return arguments[i];
|
|
146
|
-
}
|
|
147
|
-
return '';
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Block helper that renders a block if `a` is **equal to** `b`.
|
|
152
|
-
* If an inverse block is specified it will be rendered when falsy.
|
|
153
|
-
* You may optionally use the `compare=""` hash argument for the
|
|
154
|
-
* second value.
|
|
155
|
-
*
|
|
156
|
-
* @param {String} `a`
|
|
157
|
-
* @param {String} `b`
|
|
158
|
-
* @param {Object} `options` Handlebars provided options object
|
|
159
|
-
* @return {String} Block, or inverse block if specified and falsey.
|
|
160
|
-
* @alias is
|
|
161
|
-
* @block
|
|
162
|
-
* @api public
|
|
163
|
-
*/
|
|
164
|
-
|
|
165
|
-
helpers.eq = function(a, b, options) {
|
|
166
|
-
if (arguments.length === 2) {
|
|
167
|
-
options = b;
|
|
168
|
-
b = options.hash.compare;
|
|
169
|
-
}
|
|
170
|
-
return util.value(a === b, this, options);
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Block helper that renders a block if `a` is **greater than** `b`.
|
|
175
|
-
*
|
|
176
|
-
* If an inverse block is specified it will be rendered when falsy.
|
|
177
|
-
* You may optionally use the `compare=""` hash argument for the
|
|
178
|
-
* second value.
|
|
179
|
-
*
|
|
180
|
-
* @param {String} `a`
|
|
181
|
-
* @param {String} `b`
|
|
182
|
-
* @param {Object} `options` Handlebars provided options object
|
|
183
|
-
* @return {String} Block, or inverse block if specified and falsey.
|
|
184
|
-
* @block
|
|
185
|
-
* @api public
|
|
186
|
-
*/
|
|
187
|
-
|
|
188
|
-
helpers.gt = function(a, b, options) {
|
|
189
|
-
if (arguments.length === 2) {
|
|
190
|
-
options = b;
|
|
191
|
-
b = options.hash.compare;
|
|
192
|
-
}
|
|
193
|
-
return util.value(a > b, this, options);
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Block helper that renders a block if `a` is **greater than or
|
|
198
|
-
* equal to** `b`.
|
|
199
|
-
*
|
|
200
|
-
* If an inverse block is specified it will be rendered when falsy.
|
|
201
|
-
* You may optionally use the `compare=""` hash argument for the
|
|
202
|
-
* second value.
|
|
203
|
-
*
|
|
204
|
-
* @param {String} `a`
|
|
205
|
-
* @param {String} `b`
|
|
206
|
-
* @param {Object} `options` Handlebars provided options object
|
|
207
|
-
* @return {String} Block, or inverse block if specified and falsey.
|
|
208
|
-
* @block
|
|
209
|
-
* @api public
|
|
210
|
-
*/
|
|
211
|
-
|
|
212
|
-
helpers.gte = function(a, b, options) {
|
|
213
|
-
if (arguments.length === 2) {
|
|
214
|
-
options = b;
|
|
215
|
-
b = options.hash.compare;
|
|
216
|
-
}
|
|
217
|
-
return util.value(a >= b, this, options);
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Block helper that renders a block if `value` has `pattern`.
|
|
222
|
-
* If an inverse block is specified it will be rendered when falsy.
|
|
223
|
-
*
|
|
224
|
-
* @param {any} `val` The value to check.
|
|
225
|
-
* @param {any} `pattern` The pattern to check for.
|
|
226
|
-
* @param {Object} `options` Handlebars provided options object
|
|
227
|
-
* @return {String}
|
|
228
|
-
* @block
|
|
229
|
-
* @api public
|
|
230
|
-
*/
|
|
231
|
-
|
|
232
|
-
helpers.has = function(value, pattern, options) {
|
|
233
|
-
if (util.isOptions(value)) {
|
|
234
|
-
options = value;
|
|
235
|
-
pattern = null;
|
|
236
|
-
value = null;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
if (util.isOptions(pattern)) {
|
|
240
|
-
options = pattern;
|
|
241
|
-
pattern = null;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
if (value === null) {
|
|
245
|
-
return util.value(false, this, options);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
if (arguments.length === 2) {
|
|
249
|
-
return util.value(has(this, value), this, options);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
if ((Array.isArray(value) || util.isString(value)) && util.isString(pattern)) {
|
|
253
|
-
if (value.indexOf(pattern) > -1) {
|
|
254
|
-
return util.fn(true, this, options);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
if (util.isObject(value) && util.isString(pattern) && pattern in value) {
|
|
258
|
-
return util.fn(true, this, options);
|
|
259
|
-
}
|
|
260
|
-
return util.inverse(false, this, options);
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Returns true if the given `value` is falsey. Uses the [falsey][]
|
|
265
|
-
* library for comparisons. Please see that library for more information
|
|
266
|
-
* or to report bugs with this helper.
|
|
267
|
-
*
|
|
268
|
-
* @param {any} `val`
|
|
269
|
-
* @param {Options} `options`
|
|
270
|
-
* @return {Boolean}
|
|
271
|
-
* @api public
|
|
272
|
-
*/
|
|
273
|
-
|
|
274
|
-
helpers.isFalsey = function(val, options) {
|
|
275
|
-
return util.value(utils.falsey(val), this, options);
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Returns true if the given `value` is truthy. Uses the [falsey][]
|
|
280
|
-
* library for comparisons. Please see that library for more information
|
|
281
|
-
* or to report bugs with this helper.
|
|
282
|
-
*
|
|
283
|
-
* @param {any} `val`
|
|
284
|
-
* @param {Options} `options`
|
|
285
|
-
* @return {Boolean}
|
|
286
|
-
* @api public
|
|
287
|
-
*/
|
|
288
|
-
|
|
289
|
-
helpers.isTruthy = function(val, options) {
|
|
290
|
-
return util.value(!utils.falsey(val), this, options);
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* Return true if the given value is an even number.
|
|
295
|
-
*
|
|
296
|
-
* ```handlebars
|
|
297
|
-
* {{#ifEven value}}
|
|
298
|
-
* render A
|
|
299
|
-
* {{else}}
|
|
300
|
-
* render B
|
|
301
|
-
* {{/ifEven}}
|
|
302
|
-
* ```
|
|
303
|
-
* @param {Number} `number`
|
|
304
|
-
* @param {Object} `options` Handlebars provided options object
|
|
305
|
-
* @return {String} Block, or inverse block if specified and falsey.
|
|
306
|
-
* @block
|
|
307
|
-
* @api public
|
|
308
|
-
*/
|
|
309
|
-
|
|
310
|
-
helpers.ifEven = function(num, options) {
|
|
311
|
-
return util.value(utils.isEven(num), this, options);
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* Conditionally renders a block if the remainder is zero when
|
|
316
|
-
* `a` operand is divided by `b`. If an inverse block is specified
|
|
317
|
-
* it will be rendered when the remainder is **not zero**.
|
|
318
|
-
*
|
|
319
|
-
* @param {Number}
|
|
320
|
-
* @param {Number}
|
|
321
|
-
* @param {Object} `options` Handlebars provided options object
|
|
322
|
-
* @return {String} Block, or inverse block if specified and falsey.
|
|
323
|
-
* @block
|
|
324
|
-
* @api public
|
|
325
|
-
*/
|
|
326
|
-
|
|
327
|
-
helpers.ifNth = function(a, b, options) {
|
|
328
|
-
var isNth = utils.isNumber(a) && utils.isNumber(b) && b % a === 0;
|
|
329
|
-
return util.value(isNth, this, options);
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Block helper that renders a block if `value` is **an odd number**.
|
|
334
|
-
* If an inverse block is specified it will be rendered when falsy.
|
|
335
|
-
*
|
|
336
|
-
* ```handlebars
|
|
337
|
-
* {{#ifOdd value}}
|
|
338
|
-
* render A
|
|
339
|
-
* {{else}}
|
|
340
|
-
* render B
|
|
341
|
-
* {{/ifOdd}}
|
|
342
|
-
* ```
|
|
343
|
-
* @param {Object} `value`
|
|
344
|
-
* @param {Object} `options` Handlebars provided options object
|
|
345
|
-
* @return {String} Block, or inverse block if specified and falsey.
|
|
346
|
-
* @block
|
|
347
|
-
* @api public
|
|
348
|
-
*/
|
|
349
|
-
|
|
350
|
-
helpers.ifOdd = function(val, options) {
|
|
351
|
-
return util.value(!utils.isEven(val), this, options);
|
|
352
|
-
};
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* Block helper that renders a block if `a` is **equal to** `b`.
|
|
356
|
-
* If an inverse block is specified it will be rendered when falsy.
|
|
357
|
-
* Similar to [eq](#eq) but does not do strict equality.
|
|
358
|
-
*
|
|
359
|
-
* @param {any} `a`
|
|
360
|
-
* @param {any} `b`
|
|
361
|
-
* @param {Object} `options` Handlebars provided options object
|
|
362
|
-
* @return {String}
|
|
363
|
-
* @block
|
|
364
|
-
* @api public
|
|
365
|
-
*/
|
|
366
|
-
|
|
367
|
-
helpers.is = function(a, b, options) {
|
|
368
|
-
if (arguments.length === 2) {
|
|
369
|
-
options = b;
|
|
370
|
-
b = options.hash.compare;
|
|
371
|
-
}
|
|
372
|
-
return util.value(a == b, this, options);
|
|
373
|
-
};
|
|
374
|
-
|
|
375
|
-
/**
|
|
376
|
-
* Block helper that renders a block if `a` is **not equal to** `b`.
|
|
377
|
-
* If an inverse block is specified it will be rendered when falsy.
|
|
378
|
-
* Similar to [unlessEq](#unlesseq) but does not use strict equality for
|
|
379
|
-
* comparisons.
|
|
380
|
-
*
|
|
381
|
-
* @param {String} `a`
|
|
382
|
-
* @param {String} `b`
|
|
383
|
-
* @param {Object} `options` Handlebars provided options object
|
|
384
|
-
* @return {String}
|
|
385
|
-
* @block
|
|
386
|
-
* @api public
|
|
387
|
-
*/
|
|
388
|
-
|
|
389
|
-
helpers.isnt = function(a, b, options) {
|
|
390
|
-
if (arguments.length === 2) {
|
|
391
|
-
options = b;
|
|
392
|
-
b = options.hash.compare;
|
|
393
|
-
}
|
|
394
|
-
return util.value(a != b, this, options);
|
|
395
|
-
};
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* Block helper that renders a block if `a` is **less than** `b`.
|
|
399
|
-
*
|
|
400
|
-
* If an inverse block is specified it will be rendered when falsy.
|
|
401
|
-
* You may optionally use the `compare=""` hash argument for the
|
|
402
|
-
* second value.
|
|
403
|
-
*
|
|
404
|
-
* @param {Object} `context`
|
|
405
|
-
* @param {Object} `options` Handlebars provided options object
|
|
406
|
-
* @return {String} Block, or inverse block if specified and falsey.
|
|
407
|
-
* @block
|
|
408
|
-
* @api public
|
|
409
|
-
*/
|
|
410
|
-
|
|
411
|
-
helpers.lt = function(a, b, options) {
|
|
412
|
-
if (arguments.length === 2) {
|
|
413
|
-
options = b;
|
|
414
|
-
b = options.hash.compare;
|
|
415
|
-
}
|
|
416
|
-
return util.value(a < b, this, options);
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* Block helper that renders a block if `a` is **less than or
|
|
421
|
-
* equal to** `b`.
|
|
422
|
-
*
|
|
423
|
-
* If an inverse block is specified it will be rendered when falsy.
|
|
424
|
-
* You may optionally use the `compare=""` hash argument for the
|
|
425
|
-
* second value.
|
|
426
|
-
*
|
|
427
|
-
* @param {Sring} `a`
|
|
428
|
-
* @param {Sring} `b`
|
|
429
|
-
* @param {Object} `options` Handlebars provided options object
|
|
430
|
-
* @return {String} Block, or inverse block if specified and falsey.
|
|
431
|
-
* @block
|
|
432
|
-
* @api public
|
|
433
|
-
*/
|
|
434
|
-
|
|
435
|
-
helpers.lte = function(a, b, options) {
|
|
436
|
-
if (arguments.length === 2) {
|
|
437
|
-
options = b;
|
|
438
|
-
b = options.hash.compare;
|
|
439
|
-
}
|
|
440
|
-
return util.value(a <= b, this, options);
|
|
441
|
-
};
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
* Block helper that renders a block if **neither of** the given values
|
|
445
|
-
* are truthy. If an inverse block is specified it will be rendered
|
|
446
|
-
* when falsy.
|
|
447
|
-
*
|
|
448
|
-
* @param {any} `a`
|
|
449
|
-
* @param {any} `b`
|
|
450
|
-
* @param `options` Handlebars options object
|
|
451
|
-
* @return {String} Block, or inverse block if specified and falsey.
|
|
452
|
-
* @block
|
|
453
|
-
* @api public
|
|
454
|
-
*/
|
|
455
|
-
|
|
456
|
-
helpers.neither = function(a, b, options) {
|
|
457
|
-
return util.value(!a && !b, this, options);
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
/**
|
|
461
|
-
* Returns true if `val` is falsey. Works as a block or inline helper.
|
|
462
|
-
*
|
|
463
|
-
* @param {String} `val`
|
|
464
|
-
* @param {Object} `options` Handlebars provided options object
|
|
465
|
-
* @return {String}
|
|
466
|
-
* @block
|
|
467
|
-
* @api public
|
|
468
|
-
*/
|
|
469
|
-
|
|
470
|
-
helpers.not = function(val, options) {
|
|
471
|
-
return util.value(!val, this, options);
|
|
472
|
-
};
|
|
473
|
-
|
|
474
|
-
/**
|
|
475
|
-
* Block helper that renders a block if **any of** the given values
|
|
476
|
-
* is truthy. If an inverse block is specified it will be rendered
|
|
477
|
-
* when falsy.
|
|
478
|
-
*
|
|
479
|
-
* ```handlebars
|
|
480
|
-
* {{#or a b c}}
|
|
481
|
-
* If any value is true this will be rendered.
|
|
482
|
-
* {{/or}}
|
|
483
|
-
* ```
|
|
484
|
-
*
|
|
485
|
-
* @param {...any} `arguments` Variable number of arguments
|
|
486
|
-
* @param {Object} `options` Handlebars options object
|
|
487
|
-
* @return {String} Block, or inverse block if specified and falsey.
|
|
488
|
-
* @block
|
|
489
|
-
* @api public
|
|
490
|
-
*/
|
|
491
|
-
|
|
492
|
-
helpers.or = function(/* any, any, ..., options */) {
|
|
493
|
-
var len = arguments.length - 1;
|
|
494
|
-
var options = arguments[len];
|
|
495
|
-
var val = false;
|
|
496
|
-
|
|
497
|
-
for (var i = 0; i < len; i++) {
|
|
498
|
-
if (arguments[i]) {
|
|
499
|
-
val = true;
|
|
500
|
-
break;
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
return util.value(val, this, options);
|
|
504
|
-
};
|
|
505
|
-
|
|
506
|
-
/**
|
|
507
|
-
* Block helper that always renders the inverse block **unless `a` is
|
|
508
|
-
* is equal to `b`**.
|
|
509
|
-
*
|
|
510
|
-
* @param {String} `a`
|
|
511
|
-
* @param {String} `b`
|
|
512
|
-
* @param {Object} `options` Handlebars provided options object
|
|
513
|
-
* @return {String} Inverse block by default, or block if falsey.
|
|
514
|
-
* @block
|
|
515
|
-
* @api public
|
|
516
|
-
*/
|
|
517
|
-
|
|
518
|
-
helpers.unlessEq = function(a, b, options) {
|
|
519
|
-
if (util.isOptions(b)) {
|
|
520
|
-
options = b;
|
|
521
|
-
b = options.hash.compare;
|
|
522
|
-
}
|
|
523
|
-
return util.value(a !== b, this, options);
|
|
524
|
-
};
|
|
525
|
-
|
|
526
|
-
/**
|
|
527
|
-
* Block helper that always renders the inverse block **unless `a` is
|
|
528
|
-
* is greater than `b`**.
|
|
529
|
-
*
|
|
530
|
-
* @param {Object} `a` The default value
|
|
531
|
-
* @param {Object} `b` The value to compare
|
|
532
|
-
* @param {Object} `options` Handlebars provided options object
|
|
533
|
-
* @return {String} Inverse block by default, or block if falsey.
|
|
534
|
-
* @block
|
|
535
|
-
* @api public
|
|
536
|
-
*/
|
|
537
|
-
|
|
538
|
-
helpers.unlessGt = function(a, b, options) {
|
|
539
|
-
if (util.isOptions(b)) {
|
|
540
|
-
options = b;
|
|
541
|
-
b = options.hash.compare;
|
|
542
|
-
}
|
|
543
|
-
return util.value(a <= b, this, options);
|
|
544
|
-
};
|
|
545
|
-
|
|
546
|
-
/**
|
|
547
|
-
* Block helper that always renders the inverse block **unless `a` is
|
|
548
|
-
* is less than `b`**.
|
|
549
|
-
*
|
|
550
|
-
* @param {Object} `a` The default value
|
|
551
|
-
* @param {Object} `b` The value to compare
|
|
552
|
-
* @param {Object} `options` Handlebars provided options object
|
|
553
|
-
* @return {String} Block, or inverse block if specified and falsey.
|
|
554
|
-
* @block
|
|
555
|
-
* @api public
|
|
556
|
-
*/
|
|
557
|
-
|
|
558
|
-
helpers.unlessLt = function(a, b, options) {
|
|
559
|
-
if (util.isOptions(b)) {
|
|
560
|
-
options = b;
|
|
561
|
-
b = options.hash.compare;
|
|
562
|
-
}
|
|
563
|
-
return util.value(a >= b, this, options);
|
|
564
|
-
};
|
|
565
|
-
|
|
566
|
-
/**
|
|
567
|
-
* Block helper that always renders the inverse block **unless `a` is
|
|
568
|
-
* is greater than or equal to `b`**.
|
|
569
|
-
*
|
|
570
|
-
* @param {any} `a`
|
|
571
|
-
* @param {any} `b`
|
|
572
|
-
* @param {Object} `options` Handlebars provided options object
|
|
573
|
-
* @return {String} Block, or inverse block if specified and falsey.
|
|
574
|
-
* @block
|
|
575
|
-
* @api public
|
|
576
|
-
*/
|
|
577
|
-
|
|
578
|
-
helpers.unlessGteq = function(a, b, options) {
|
|
579
|
-
if (util.isOptions(b)) {
|
|
580
|
-
options = b;
|
|
581
|
-
b = options.hash.compare;
|
|
582
|
-
}
|
|
583
|
-
return util.value(a < b, this, options);
|
|
584
|
-
};
|
|
585
|
-
|
|
586
|
-
/**
|
|
587
|
-
* Block helper that always renders the inverse block **unless `a` is
|
|
588
|
-
* is less than or equal to `b`**.
|
|
589
|
-
*
|
|
590
|
-
* @param {any} `a`
|
|
591
|
-
* @param {any} `b`
|
|
592
|
-
* @param {Object} `options` Handlebars provided options object
|
|
593
|
-
* @return {String} Block, or inverse block if specified and falsey.
|
|
594
|
-
* @block
|
|
595
|
-
* @api public
|
|
596
|
-
*/
|
|
597
|
-
|
|
598
|
-
helpers.unlessLteq = function(a, b, options) {
|
|
599
|
-
if (util.isOptions(b)) {
|
|
600
|
-
options = b;
|
|
601
|
-
b = options.hash.compare;
|
|
602
|
-
}
|
|
603
|
-
return util.value(a > b, this, options);
|
|
604
|
-
};
|
package/lib/date.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var helpers = module.exports;
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Get the current year.
|
|
6
|
-
*
|
|
7
|
-
* ```handlebars
|
|
8
|
-
* {{year}}
|
|
9
|
-
* <!-- 2017 -->
|
|
10
|
-
* ```
|
|
11
|
-
* @exposes year as year
|
|
12
|
-
* @api public
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
helpers.year = require('year');
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Use [moment][] as a helper. See [helper-date][] for more details.
|
|
19
|
-
*
|
|
20
|
-
* @exposes helper-date as moment
|
|
21
|
-
* @api public
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
helpers.moment = helpers.date = require('helper-date');
|
package/lib/fs.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var fs = require('fs');
|
|
4
|
-
var path = require('path');
|
|
5
|
-
var util = require('handlebars-utils');
|
|
6
|
-
var utils = require('./utils');
|
|
7
|
-
var number = require('./number');
|
|
8
|
-
var helpers = module.exports;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Helper `fileSize` is deprecated. Use `helper.prettyBytes` instead.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
helpers.fileSize = number.bytes;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Read a file from the file system. This is useful in composing
|
|
18
|
-
* "include"-style helpers using sub-expressions.
|
|
19
|
-
*
|
|
20
|
-
* ```handlebars
|
|
21
|
-
* {{read "a/b/c.js"}}
|
|
22
|
-
* {{someHelper (read "a/b/c.md")}}
|
|
23
|
-
* ```
|
|
24
|
-
* @param {String} `filepath`
|
|
25
|
-
* @return {String}
|
|
26
|
-
* @api public
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
helpers.read = function(filepath, options) {
|
|
30
|
-
return fs.readFileSync(filepath, 'utf8');
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Return an array of files from the given
|
|
35
|
-
* directory.
|
|
36
|
-
*
|
|
37
|
-
* @param {String} `directory`
|
|
38
|
-
* @return {Array}
|
|
39
|
-
* @api public
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
helpers.readdir = function(dir, filter) {
|
|
43
|
-
var files = fs.readdirSync(dir);
|
|
44
|
-
files = files.map(function(fp) {
|
|
45
|
-
return path.join(dir, fp);
|
|
46
|
-
});
|
|
47
|
-
if (util.isOptions(filter)) {
|
|
48
|
-
return files;
|
|
49
|
-
}
|
|
50
|
-
if (typeof filter === 'function') {
|
|
51
|
-
return filter(files);
|
|
52
|
-
}
|
|
53
|
-
if (utils.typeOf(filter) === 'regexp') {
|
|
54
|
-
return files.filter(function(fp) {
|
|
55
|
-
return filter.test(fp);
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
if (utils.isGlob(filter)) {
|
|
59
|
-
const isMatch = utils.mm.matcher(filter);
|
|
60
|
-
const result = [];
|
|
61
|
-
for(let i = 0; i < files.length; i++) {
|
|
62
|
-
if (isMatch(files[i])) {
|
|
63
|
-
result.push(files[i]);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return result;
|
|
67
|
-
}
|
|
68
|
-
if (['isFile', 'isDirectory'].indexOf(filter) !== -1) {
|
|
69
|
-
return files.filter(function(fp) {
|
|
70
|
-
var stat = fs.statSync(fp);
|
|
71
|
-
return stat[filter]();
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
return files;
|
|
75
|
-
};
|