Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | 1x 1x 1x 1x 22x 22x 1x 1x 7x 7x 7x 7x 7x 1x 1x 5x 5x 5x 5x 1x 1x 1x 1x 1x 1x 1x 3x 3x 3x 3x 1x 1x 1x 1x 1x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 1x 1x 1x 11x 11x 11x 11x 11x 11x 1x 1x 2x 2x 1x 1x 1x 1x 1x 1x 3x 3x 1x 1x 1x 1x 1x 3x 3x 1x 1x 1x 1x 1x 1x 1x 1x 1x 26x 26x 1x 1x 1x 1x 1x 1x 1x 1x 1x 27x 27x 1x 1x 1x 1x 1x 25x 25x 25x 25x 25x 25x 14x 14x 14x 14x 1x 14x 13x 13x 25x 2x 2x 11x 1x 1x 9x 8x 8x 8x 8x 1x 8x 7x 7x 8x 25x 25x 25x 25x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 9x 9x 9x 9x 9x 5x 9x 4x 205x 205x 205x 3x 3x 205x 205x 4x 4x 4x 4x 4x 1x 1x 4x 9x 9x 9x 9x 15x 15x 15x 15x 15x 110x 12x 110x 51x 39x 51x 12x 12x 98x 13x 7x 7x 13x 6x 6x 6x 47x 34x 34x 110x 110x 15x 15x 9x 9x 9x 9x 9x 3x 3x 9x 9x 9x 9x 9x 1x 1x 3x 3x 3x 3x 1x 1x 1x 3x 1x 1x 3x 3x 3x 3x 3x 3x 3x 3x 1x | import * as constants from '../constants.js';
export class Finance {
constructor(pure) {
this.pure = pure;
}
account(length) {
const def = length || 8;
const template = this.pure.helpers.repeatString({ string: '#', num: def });
return this.pure.helpers.replaceSymbolWithNumber({ string: template });
}
accountName() {
const result = this.pure.random.arrayElement(this.pure.registeredModules.finance.accountType);
return [result, 'Account'].join(' ');
}
routingNumber() {
const routingNumber = this.pure.helpers.replaceSymbolWithNumber({ string: '########' });
// Modules 10 straight summation.
let sum = 0;
for (let i = 0; i < routingNumber.length; i += 3) {
sum += Number(routingNumber[i]) * 3;
sum += Number(routingNumber[i + 1]) * 7;
sum += Number(routingNumber[i + 2]) || 0;
}
return routingNumber + (Math.ceil(sum / 10) * 10 - sum);
}
mask(options) {
const opt = options || {};
const { length, parens, ellipsis } = opt;
// set defaults
const def = length === 0 || !length || typeof length === 'undefined' ? 4 : length;
const nParens = parens === null ? true : parens;
const nEllipsis = ellipsis === null ? true : ellipsis;
let template = this.pure.helpers.repeatString({ string: '#', num: def });
// prefix with ellipsis
template = nEllipsis ? ['...', template].join('') : template;
template = nParens ? ['(', template, ')'].join('') : template;
// generate random numbers
template = this.pure.helpers.replaceSymbolWithNumber({ string: template });
return template;
}
// TODO: rename dec param as precision
amount(options) {
const def = options || {};
const { min = 0, max = 1000, dec = 2, symbol = '' } = def;
const randValue = this.pure.random.number({ max, min, precision: dec });
return symbol + randValue.toFixed(dec);
}
transactionType() {
return this.pure.random.arrayElement(this.pure.registeredModules.finance.transactionType);
}
currencyCode() {
return this.pure.random.objectElement(this.pure.registeredModules.finance.currency).code;
}
currencyName() {
return this.pure.random.objectElement(this.pure.registeredModules.finance.currency, 'key');
}
currencySymbol() {
let symbol;
while (!symbol) {
symbol = this.pure.random.objectElement(this.pure.registeredModules.finance.currency).symbol;
}
return symbol;
}
bitcoinAddress() {
const addressLength = this.pure.random.number({ min: 25, max: 34 });
let address = this.pure.random.arrayElement(['1', '3']);
for (let i = 0; i < addressLength - 1; i += 1) {
address += this.pure.random.arrayElement(constants.alphaNumAddress);
}
return address;
}
litecoinAddress() {
const addressLength = this.pure.random.number({ min: 26, max: 33 });
let address = this.pure.random.arrayElement(['L', 'M', '3']);
for (let i = 0; i < addressLength; i += 1) {
address += this.pure.random.arrayElement(constants.alphaNumAddress);
}
return address;
}
creditCardNumber(provider) {
const prov = provider || '';
let format;
let formats;
const localeFormat = this.pure.registeredModules.finance.creditCard;
if (Object.prototype.hasOwnProperty.call(localeFormat, provider)) {
// there chould be multiple formats
formats = localeFormat[prov];
if (typeof formats === 'string') {
format = formats;
} else {
format = this.pure.random.arrayElement(formats);
}
} else if (prov.match(/#/)) {
// The user chose an optional scheme
format = prov;
} else if (typeof localeFormat === 'string') {
// Choose a random provider
format = localeFormat;
} else if (typeof localeFormat === 'object') {
// Credit cards are in a object structure
formats = this.pure.random.objectElement(localeFormat, 'value');
// There chould be multiple formats
if (typeof formats === 'string') {
format = formats;
} else {
format = this.pure.random.arrayElement(formats);
}
}
format = format.replace(/\//g, '');
return this.pure.helpers.replaceCreditCardSymbols({ string: format });
}
creditCardCVV() {
return this.pure.helpers.replaceSymbolWithNumber({ string: '###' });
}
ethereumAddress() {
return `0x${this.pure.random.hexaDecimal(40).toLowerCase()}`;
}
iban(options) {
const def = options || {};
const { formatted = false, country } = def;
let ibanFormat;
if (typeof country === 'undefined') {
ibanFormat = this.pure.random.arrayElement(this.pure.registeredModules.iban.formats);
} else {
const form = format => {
let res;
if (format.country === country.toUpperCase()) {
res = format;
}
return res;
};
const res = this.pure.registeredModules.iban.formats.filter(form);
[ibanFormat] = res;
if (!ibanFormat) {
ibanFormat = this.pure.random.arrayElement(this.pure.registeredModules.iban.formats);
}
}
let s = '';
let count = 0;
for (let b = 0; b < ibanFormat.bban.length; b += 1) {
const bban = ibanFormat.bban[b];
let c = bban.count;
count += bban.count;
while (c > 0) {
if (bban.type === 'a') {
s += this.pure.random.alpha().toUpperCase();
} else if (bban.type === 'c') {
if (this.pure.random.number(100) < 80) {
s += this.pure.random.number(9);
} else {
s += this.pure.random.alpha().toUpperCase();
}
} else if (c >= 3 && this.pure.random.number(100) < 30) {
if (this.pure.random.boolean()) {
s += `00${this.pure.random.number(9)}`;
c -= 2;
} else {
s += `0${this.pure.random.number(9)}`;
c -= 1;
}
} else {
s += this.pure.random.number(9);
}
c -= 1;
}
s = s.substring(0, count);
}
let checksum =
98 - this.pure.helpers.mod97(this.pure.helpers.toDigitString(`${s + ibanFormat.country}00`));
if (checksum < 10) {
checksum = `0${checksum}`;
}
const iban = ibanFormat.country + checksum + s;
return formatted ? iban.match(/.{1,4}/g).join(' ') : iban;
}
bic() {
const prob = this.pure.random.number(100);
let verification = '';
if (prob < 10) {
verification = this.pure.helpers.replaceSymbols(
`?${this.pure.random.arrayElement(constants.upperVowel)}?`
);
} else if (prob < 40) {
verification = this.pure.helpers.replaceSymbols('###');
}
return `${
this.pure.helpers.replaceSymbols('???') +
this.pure.random.arrayElement(constants.upperVowel) +
this.pure.random.arrayElement(this.pure.registeredModules.iban.countryCode) +
this.pure.helpers.replaceSymbols('?')
}1${verification}`;
}
}
|