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 | 1x 1x 22x 22x 1x 1x 4x 4x 4x 4x 8x 8x 8x 8x 76x 76x 8x 8x 8x 8x 2x 2x 8x 8x 4x 4x 4x 4x 4x 4x 1x 1x 4x 4x 4x 1x 1x 3x 3x 3x 3x 6x 6x 6x 6x 75x 75x 75x 6x 6x 6x 6x 3x 3x 3x 3x 3x 3x 3x 1x 1x 3x 3x 3x 1x 1x 5x 5x 5x 5x 5x 5x 40x 40x 5x 5x 5x 5x 5x 1x 5x 1x 1x 5x 5x 5x 5x 1x 1x 5x 5x 5x 1x | export class Document {
constructor(pure) {
this.pure = pure;
}
brazilianCitizenNumber(options) {
const def = options || {};
const { format = false } = def;
let doc = this.pure.helpers.replaceSymbolWithNumber({ string: '#########' });
const dv = str => {
let sum = 0;
const mult = str.length + 2;
for (let i = 1; i <= str.length; i += 1) {
sum += parseInt(str[i - 1], 10) * (mult - i);
}
let digit = this.pure.helpers.mod({ digitStr: `${sum * 10}`, modValue: 11 });
if (digit === 10 || digit === 11) {
digit = 0;
}
return digit;
};
doc += dv(doc);
doc += dv(doc);
if (format === true) {
doc = doc.replace(/^(\d{3})(\d{3})(\d{3})(\d{2})/, '$1.$2.$3-$4');
}
return doc;
}
brazilianCompanyNumber(options) {
const def = options || {};
const { format = false } = def;
let doc = this.pure.helpers.replaceSymbolWithNumber({ string: '########' });
const mod = str => {
let sum = 0;
let pos = str.length - 7;
for (let i = 1; i <= str.length; i += 1) {
sum += parseInt(str[i - 1], 10) * pos;
pos = pos <= 2 ? 9 : (pos -= 1);
}
const modResult = parseInt(this.pure.helpers.mod({ digitStr: `${sum}`, modValue: 11 }), 10);
return modResult < 2 ? 0 : 11 - modResult;
};
doc += '0001';
doc += mod(doc);
doc += mod(doc);
if (format === true) {
doc = doc.replace(/^(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/, '$1.$2.$3/$4-$5');
}
return doc;
}
brazilianId(options) {
const def = options || {};
const { format = false } = def;
let doc = this.pure.helpers.replaceSymbolWithNumber({ string: '########' });
let sum = 0;
for (let i = 0; i < doc.length; i += 1) {
sum += doc[i] * (i + 2);
}
const modResult = parseInt(this.pure.helpers.mod({ digitStr: `${sum}`, modValue: 11 }), 10);
let verificationNum = 11 - modResult;
if (verificationNum === 11) {
verificationNum = 0;
} else if (verificationNum === 10) {
verificationNum = 'X';
}
doc = `${doc}${verificationNum}`;
if (format === true) {
doc = doc.replace(/^(\d{2})(\d{3})(\d{3})(\d?\w{1})/, '$1.$2.$3-$4');
}
return doc;
}
}
|