1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 |
16x
16x
16x
16x
16x
16x
16x
16x
16x
32x
29x
29x
29x
1x
1x
1x
14x
7x
7x
1x
6x
7x
7x
1x
1x
14x
1x
12x
16x
16x
16x
16x | 'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.asciiLetters = exports.digits = exports.asciiLowerCase = exports.asciiUpperCase = undefined;
exports.pull = pull;
exports.luhnChecksum = luhnChecksum;
exports.uniform = uniform;
var _fs = require('fs');
var _fs2 = _interopRequireDefault(_fs);
var _path = require('path');
var _path2 = _interopRequireDefault(_path);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function pull(file, locale) {
try {
var localeFilePath = _path2.default.join(__dirname, 'locales', locale, file);
return JSON.parse(_fs2.default.readFileSync(localeFilePath, 'utf-8'));
} catch (e) {
throw new Error(locale + ' is unsupported');
}
}
function luhnChecksum(num) {
var arr = [];
num = num.toString().replace(/\D\-|\s|\/|\*/g, '');
for (var i = 0; i < num.length; i++) {
if (i % 2 === 0) {
var m = parseInt(num[i]) * 2;
if (m > 9) {
arr.push(m - 9);
} else {
arr.push(m);
}
} else {
var n = parseInt(num[i]);
arr.push(n);
}
}
var sum = 0;
arr.map(function (item) {
return sum += item;
});
return sum % 10;
}
function uniform(a, b, fixed) {
return (Math.random() * (b - a) + a).toFixed(fixed) * 1;
}
var asciiUpperCase = exports.asciiUpperCase = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
var asciiLowerCase = exports.asciiLowerCase = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
var digits = exports.digits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
var asciiLetters = exports.asciiLetters = [].concat(asciiUpperCase, asciiLowerCase); |