Debian Codegraph @

dojox/dtl/filter/integers.js

raw symbols SCIP
1 define([
2 "dojo/_base/lang",
3 "../_base"
4 ], function(lang,dd){
5
6 var integers = lang.getObject("filter.integers", true, dd);
7 /*=====
8 integers = {
9 // TODO: summary
10 };
11 =====*/
12
13 lang.mixin(integers, {
14 add: function(value, arg){
15 value = parseInt(value, 10);
16 arg = parseInt(arg, 10);
17 return isNaN(arg) ? value : value + arg;
18 },
19 get_digit: function(value, arg){
20 // summary:
21 // Given a whole number, returns the 1-based requested digit of it
22 // desciprtion:
23 // 1 is the right-most digit, 2 is the second-right-most digit, etc. Returns the
24 // original value for invalid input (if input or argument is not an integer,
25 // or if argument is less than 1). Otherwise, output is always an integer.
26 value = parseInt(value, 10);
27 arg = parseInt(arg, 10) - 1;
28 if(arg >= 0){
29 value += "";
30 if(arg < value.length){
31 value = parseInt(value.charAt(arg), 10);
32 }else{
33 value = 0;
34 }
35 }
36 return (isNaN(value) ? 0 : value);
37 }
38 });
39
40 return integers;
41 });