Skip to content

Commit eb960c4

Browse files
committed
reverse arguments
- reverse the arguments passed to util.value, util.fn, and util.inverse - fixes #279
1 parent 4c778e1 commit eb960c4

File tree

3 files changed

+33
-34
lines changed

3 files changed

+33
-34
lines changed

lib/array.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ helpers.forEach = function(array, options) {
222222
*/
223223

224224
helpers.inArray = function(array, value, options) {
225-
return util.value(util.indexOf(array, value) > -1, options, this);
225+
return util.value(util.indexOf(array, value) > -1, this, options);
226226
};
227227

228228
/**
@@ -321,7 +321,7 @@ helpers.equalsLength = function(value, length, options) {
321321
len = value.length;
322322
}
323323

324-
return util.value(len === length, options, this);
324+
return util.value(len === length, this, options);
325325
};
326326

327327
/**

lib/collection.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ var helpers = module.exports;
2222
helpers.isEmpty = function(collection, options) {
2323
if (!util.isOptions(options)) {
2424
options = collection;
25-
return util.fn(true, options, this);
25+
return util.fn(true, this, options);
2626
}
2727

2828
if (Array.isArray(collection) && !collection.length) {
29-
return util.fn(true, options, this);
29+
return util.fn(true, this, options);
3030
}
3131

3232
var keys = Object.keys(collection);
3333
var isEmpty = typeof collection === 'object' && !keys.length;
34-
return util.value(isEmpty, options, this);
34+
return util.value(isEmpty, this, options);
3535
};
3636

3737
/**

lib/comparison.js

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ helpers.and = function() {
3030
}
3131
}
3232

33-
return util.value(val, options, this);
33+
return util.value(val, this, options);
3434
};
3535

3636
/**
@@ -89,7 +89,7 @@ helpers.compare = function(a, operator, b, options) {
8989
}
9090
}
9191

92-
return util.value(result, options, this);
92+
return util.value(result, this, options);
9393
};
9494

9595
/**
@@ -121,7 +121,7 @@ helpers.contains = function(collection, value, startIndex, options) {
121121
startIndex = undefined;
122122
}
123123
var val = utils.contains(collection, value, startIndex);
124-
return util.value(val, options, this);
124+
return util.value(val, this, options);
125125
};
126126

127127
/**
@@ -161,7 +161,7 @@ helpers.eq = function(a, b, options) {
161161
options = b;
162162
b = options.hash.compare;
163163
}
164-
return util.value(a === b, options, this);
164+
return util.value(a === b, this, options);
165165
};
166166

167167
/**
@@ -184,7 +184,7 @@ helpers.gt = function(a, b, options) {
184184
options = b;
185185
b = options.hash.compare;
186186
}
187-
return util.value(a > b, options, this);
187+
return util.value(a > b, this, options);
188188
};
189189

190190
/**
@@ -208,7 +208,7 @@ helpers.gte = function(a, b, options) {
208208
options = b;
209209
b = options.hash.compare;
210210
}
211-
return util.value(a >= b, options, this);
211+
return util.value(a >= b, this, options);
212212
};
213213

214214
/**
@@ -236,23 +236,22 @@ helpers.has = function(value, pattern, options) {
236236
}
237237

238238
if (value === null) {
239-
return util.value(false, options, this);
239+
return util.value(false, this, options);
240240
}
241241

242242
if (arguments.length === 2) {
243-
return util.value(has(this, value), options, this);
244-
// return util.inverse(false, pattern, this);
243+
return util.value(has(this, value), this, options);
245244
}
246245

247246
if ((Array.isArray(value) || util.isString(value)) && util.isString(pattern)) {
248247
if (value.indexOf(pattern) > -1) {
249-
return util.fn(true, options, this);
248+
return util.fn(true, this, options);
250249
}
251250
}
252251
if (util.isObject(value) && util.isString(pattern) && pattern in value) {
253-
return util.fn(true, options, this);
252+
return util.fn(true, this, options);
254253
}
255-
return util.inverse(false, options, this);
254+
return util.inverse(false, this, options);
256255
};
257256

258257
/**
@@ -267,7 +266,7 @@ helpers.has = function(value, pattern, options) {
267266
*/
268267

269268
helpers.isFalsey = function(val, options) {
270-
return util.value(utils.falsey(val), options, this);
269+
return util.value(utils.falsey(val), this, options);
271270
};
272271

273272
/**
@@ -282,7 +281,7 @@ helpers.isFalsey = function(val, options) {
282281
*/
283282

284283
helpers.isTruthy = function(val, options) {
285-
return util.value(!utils.falsey(val), options, this);
284+
return util.value(!utils.falsey(val), this, options);
286285
};
287286

288287
/**
@@ -303,7 +302,7 @@ helpers.isTruthy = function(val, options) {
303302
*/
304303

305304
helpers.ifEven = function(num, options) {
306-
return util.value(utils.isEven(num), options, this);
305+
return util.value(utils.isEven(num), this, options);
307306
};
308307

309308
/**
@@ -321,7 +320,7 @@ helpers.ifEven = function(num, options) {
321320

322321
helpers.ifNth = function(a, b, options) {
323322
var isNth = utils.isNumber(a) && utils.isNumber(b) && b % a === 0;
324-
return util.value(isNth, options, this);
323+
return util.value(isNth, this, options);
325324
};
326325

327326
/**
@@ -343,7 +342,7 @@ helpers.ifNth = function(a, b, options) {
343342
*/
344343

345344
helpers.ifOdd = function(val, options) {
346-
return util.value(!utils.isEven(val), options, this);
345+
return util.value(!utils.isEven(val), this, options);
347346
};
348347

349348
/**
@@ -364,7 +363,7 @@ helpers.is = function(a, b, options) {
364363
options = b;
365364
b = options.hash.compare;
366365
}
367-
return util.value(a == b, options, this);
366+
return util.value(a == b, this, options);
368367
};
369368

370369
/**
@@ -386,7 +385,7 @@ helpers.isnt = function(a, b, options) {
386385
options = b;
387386
b = options.hash.compare;
388387
}
389-
return util.value(a != b, options, this);
388+
return util.value(a != b, this, options);
390389
};
391390

392391
/**
@@ -408,7 +407,7 @@ helpers.lt = function(a, b, options) {
408407
options = b;
409408
b = options.hash.compare;
410409
}
411-
return util.value(a < b, options, this);
410+
return util.value(a < b, this, options);
412411
};
413412

414413
/**
@@ -432,7 +431,7 @@ helpers.lte = function(a, b, options) {
432431
options = b;
433432
b = options.hash.compare;
434433
}
435-
return util.value(a <= b, options, this);
434+
return util.value(a <= b, this, options);
436435
};
437436

438437
/**
@@ -449,7 +448,7 @@ helpers.lte = function(a, b, options) {
449448
*/
450449

451450
helpers.neither = function(a, b, options) {
452-
return util.value(!a && !b, options, this);
451+
return util.value(!a && !b, this, options);
453452
};
454453

455454
/**
@@ -463,7 +462,7 @@ helpers.neither = function(a, b, options) {
463462
*/
464463

465464
helpers.not = function(val, options) {
466-
return util.value(!val, options, this);
465+
return util.value(!val, this, options);
467466
};
468467

469468
/**
@@ -495,7 +494,7 @@ helpers.or = function(/* any, any, ..., options */) {
495494
break;
496495
}
497496
}
498-
return util.value(val, options, this);
497+
return util.value(val, this, options);
499498
};
500499

501500
/**
@@ -515,7 +514,7 @@ helpers.unlessEq = function(a, b, options) {
515514
options = b;
516515
b = options.hash.compare;
517516
}
518-
return util.value(a !== b, options, this);
517+
return util.value(a !== b, this, options);
519518
};
520519

521520
/**
@@ -535,7 +534,7 @@ helpers.unlessGt = function(a, b, options) {
535534
options = b;
536535
b = options.hash.compare;
537536
}
538-
return util.value(a <= b, options, this);
537+
return util.value(a <= b, this, options);
539538
};
540539

541540
/**
@@ -555,7 +554,7 @@ helpers.unlessLt = function(a, b, options) {
555554
options = b;
556555
b = options.hash.compare;
557556
}
558-
return util.value(a >= b, options, this);
557+
return util.value(a >= b, this, options);
559558
};
560559

561560
/**
@@ -575,7 +574,7 @@ helpers.unlessGteq = function(a, b, options) {
575574
options = b;
576575
b = options.hash.compare;
577576
}
578-
return util.value(a < b, options, this);
577+
return util.value(a < b, this, options);
579578
};
580579

581580
/**
@@ -595,5 +594,5 @@ helpers.unlessLteq = function(a, b, options) {
595594
options = b;
596595
b = options.hash.compare;
597596
}
598-
return util.value(a > b, options, this);
597+
return util.value(a > b, this, options);
599598
};

0 commit comments

Comments
 (0)