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 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | 1x 1x 1x 1x 1x 1x 1x 1x 22x 22x 1x 1x 57x 57x 57x 57x 57x 57x 1x 1x 133x 133x 133x 133x 2092x 1810x 2092x 16x 280x 266x 266x 2092x 133x 133x 133x 1x 1x 21x 21x 21x 21x 21x 339x 334x 339x 5x 5x 339x 21x 21x 21x 1x 1x 31x 31x 31x 31x 31x 181x 134x 181x 20x 47x 2x 1x 2x 27x 25x 25x 181x 31x 31x 31x 1x 1x 30x 30x 30x 30x 30x 30x 1436x 1436x 1436x 728x 728x 365x 365x 728x 1436x 1436x 30x 30x 30x 30x 30x 30x 30x 30x 30x 30x 30x 30x 30x 30x 30x 30x 30x 30x 30x 30x 1x 1x 111x 111x 111x 111x 1x 1x 39x 39x 39x 39x 39x 39x 39x 39x 39x 39x 39x 39x 8x 8x 8x 8x 8x 1x 1x 1x 1x 8x 8x 8x 8x 8x 8x 8x 8x 39x 39x 39x 39x 39x 11x 11x 11x 11x 11x 11x 11x 39x 39x 39x 39x 39x 39x 11x 11x 11x 11x 11x 1x 1x 1x 1x 11x 11x 11x 11x 11x 11x 39x 39x 39x 1x 1x 7x 7x 7x 61x 61x 61x 61x 61x 7x 7x 7x 1x 1x 55x 55x 55x 55x 1x 1x 57x 57x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 4x 4x 4x 4x 4x 4x 4x 4x 4x 1x 1x 14x 14x 1x 1x 33x 33x 33x 33x 351x 351x 33x 33x 33x 1x 1x 15x 15x 1x | import mustache from 'mustache';
import slugify from 'slugify';
import * as constants from '../constants.js';
mustache.escape = text => text;
export class Helpers {
constructor(pure) {
this.pure = pure;
}
slugify(string, opts) {
const def = string || '';
const opt = opts || {};
opt.remove = opt.remove || /['"~ยด`/]+/g;
return slugify.default(def, opt);
}
replaceSymbolWithNumber(options = {}) {
const { string = '', symbol = '#' } = options;
let str = '';
for (let i = 0; i < string.length; i += 1) {
if (string.charAt(i) === symbol) {
str += this.pure.random.number(9);
} else if (string.charAt(i) === '!') {
str += this.pure.random.number({ min: 2, max: 9 });
} else {
str += string.charAt(i);
}
}
return str;
}
replaceSymbolWithHex(options = {}) {
const { string = '', symbol = '#' } = options;
const hex = constants.hex;
let str = '';
for (let i = 0; i < string.length; i += 1) {
if (string.charAt(i) === symbol) {
str += this.pure.random.arrayElement(hex);
} else {
str += string.charAt(i);
}
}
return str;
}
replaceSymbols(string) {
const def = string || '';
const alpha = constants.upperAlpha;
let str = '';
for (let i = 0; i < def.length; i += 1) {
if (def.charAt(i) === '#') {
str += this.pure.random.number(9);
} else if (def.charAt(i) === '?') {
str += this.pure.random.arrayElement(alpha);
} else if (def.charAt(i) === '*') {
str += this.pure.random.boolean()
? this.pure.random.arrayElement(alpha)
: this.pure.random.number(9);
} else {
str += def.charAt(i);
}
}
return str;
}
replaceCreditCardSymbols(options = {}) {
const { string, symbol = '#' } = options;
// Function calculating the Luhn checksum of a number string
const getCheckBit = number => {
let nNumber = number;
nNumber.reverse();
nNumber = nNumber.map((num, index) => {
let nNum = num;
if (index % 2 === 0) {
nNum *= 2;
if (nNum > 9) {
nNum -= 9;
}
}
return nNum;
});
const sum = nNumber.reduce((prev, curr) => prev + curr);
return sum % 10;
};
let str = string || '#';
// replace [4-9] with a random number in range etc...
str = this.pure.helpers.regexpStyleStringParse(str);
// replace ### with random numbers
str = this.pure.helpers.replaceSymbolWithNumber({ string: str, symbol });
const numberList = str
.replace(/\D/g, '')
.split('')
.map(num => parseInt(num, 10));
const checkNum = getCheckBit(numberList);
return str.replace('L', checkNum);
}
repeatString(options = {}) {
const { string = '', num = 0 } = options;
return string.repeat(num);
}
regexpStyleStringParse(string) {
let def = string || '';
const rangeRepeat = /(.)\{(\d+),(\d+)\}/;
const exactRepeat = /(.)\{(\d+)\}/;
const digitInterval = /\[(\d+)-(\d+)\]/;
let min;
let max;
let tmp;
let repetitions;
// Deal with range repeat char `{min,max}`
let token = def.match(rangeRepeat);
while (token !== null) {
min = parseInt(token[2], 10);
max = parseInt(token[3], 10);
// switch min and max
if (min > max) {
tmp = max;
max = min;
min = tmp;
}
repetitions = this.pure.random.number({ min, max });
def =
def.slice(0, token.index) +
this.pure.helpers.repeatString({ string: token[1], num: repetitions }) +
def.slice(token.index + token[0].length);
token = def.match(rangeRepeat);
}
// Deal with exactly repeat `{num}`
token = def.match(exactRepeat);
while (token !== null) {
repetitions = parseInt(token[2], 10);
def =
def.slice(0, token.index) +
this.pure.helpers.repeatString({ string: token[1], num: repetitions }) +
def.slice(token.index + token[0].length);
token = def.match(exactRepeat);
}
// Deal with random digit from interval `[min-max]`
// TODO: implement for letters e.g. [0-9a-zA-Z] etc.
token = def.match(digitInterval);
while (token !== null) {
// This time we are not capturing the char before `[]`
min = parseInt(token[1], 10);
max = parseInt(token[2], 10);
// switch min and max
if (min > max) {
tmp = max;
max = min;
min = tmp;
}
def =
def.slice(0, token.index) +
this.pure.random.number({ min, max }).toString() +
def.slice(token.index + token[0].length);
token = def.match(digitInterval);
}
return def;
}
shuffle(data) {
const def = data || [];
for (let x, j, i = def.length - 1; i > 0; i -= 1) {
j = this.pure.random.number(i);
x = def[i];
def[i] = def[j];
def[j] = x;
}
return def;
}
mustache(options = {}) {
const { str = '', data } = options;
return mustache.render(str, data);
}
mustacheParse(str = '') {
return mustache.parse(str);
}
createCard() {
return {
name: this.pure.name.findName(),
username: this.pure.internet.userName(),
email: this.pure.internet.email(),
address: {
streetA: this.pure.address.streetName(),
streetB: this.pure.address.streetAddress(),
streetC: this.pure.address.streetAddress(true),
streetD: this.pure.address.secondaryAddress(),
city: this.pure.address.city(),
state: this.pure.address.state(),
country: this.pure.address.country(),
zipcode: this.pure.address.zipCode(),
geo: {
lat: this.pure.address.latitude(),
lng: this.pure.address.longitude()
}
},
phone: this.pure.phone.phoneNumber(),
website: this.pure.internet.domainName(),
company: {
name: this.pure.company.companyName(),
catchPhrase: this.pure.company.catchPhrase(),
bs: this.pure.company.bs()
},
posts: [
{
words: this.pure.lorem.words(),
sentence: this.pure.lorem.sentence(),
sentences: this.pure.lorem.sentences(),
paragraph: this.pure.lorem.paragraph()
},
{
words: this.pure.lorem.words(),
sentence: this.pure.lorem.sentence(),
sentences: this.pure.lorem.sentences(),
paragraph: this.pure.lorem.paragraph()
},
{
words: this.pure.lorem.words(),
sentence: this.pure.lorem.sentence(),
sentences: this.pure.lorem.sentences(),
paragraph: this.pure.lorem.paragraph()
}
],
accountHistory: [
this.pure.helpers.createTransaction(),
this.pure.helpers.createTransaction(),
this.pure.helpers.createTransaction()
]
};
}
contextualCard() {
const name = this.pure.name.firstName();
const userName = this.pure.internet.userName({ firstName: name });
return {
name,
username: userName,
avatar: this.pure.internet.avatar(),
email: this.pure.internet.email({ firstName: userName }),
dob: this.pure.date.past({
years: 50,
refDate: new Date('Sat Sep 20 1992 21:35:02 GMT+0200 (CEST)')
}),
phone: this.pure.phone.phoneNumber(),
address: {
street: this.pure.address.streetName(true),
suite: this.pure.address.secondaryAddress(),
city: this.pure.address.city(),
zipcode: this.pure.address.zipCode(),
geo: {
lat: this.pure.address.latitude(),
lng: this.pure.address.longitude()
}
},
website: this.pure.internet.domainName(),
company: {
name: this.pure.company.companyName(),
catchPhrase: this.pure.company.catchPhrase(),
bs: this.pure.company.bs()
}
};
}
userCard() {
return {
name: this.pure.name.findName(),
username: this.pure.internet.userName(),
email: this.pure.internet.email(),
address: {
street: this.pure.address.streetName(true),
suite: this.pure.address.secondaryAddress(),
city: this.pure.address.city(),
zipcode: this.pure.address.zipCode(),
geo: {
lat: this.pure.address.latitude(),
lng: this.pure.address.longitude()
}
},
phone: this.pure.phone.phoneNumber(),
website: this.pure.internet.domainName(),
company: {
name: this.pure.company.companyName(),
catchPhrase: this.pure.company.catchPhrase(),
bs: this.pure.company.bs()
}
};
}
createTransaction() {
return {
amount: this.pure.finance.amount(),
date: new Date(this.pure.date.past({ years: 20 })),
business: this.pure.company.companyName(),
name: [this.pure.finance.accountName(), this.pure.finance.mask()].join(' '),
type: this.pure.random.arrayElement(this.pure.registeredModules.finance.transactionType),
account: this.pure.finance.account()
};
}
mod97(digitStr) {
return this.pure.helpers.mod({ digitStr, modValue: 97 });
}
mod(options = {}) {
const { digitStr = '1', modValue = 1 } = options;
let m = 0;
for (let i = 0; i < digitStr.length; i += 1) {
m = (m * 10 + (digitStr[i] | 0)) % modValue;
}
return m;
}
toDigitString(str) {
return str.replace(/[A-Z]/gi, match => match.toUpperCase().charCodeAt(0) - 55);
}
}
|