Skip to content

Commit

Permalink
Release v2.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilafian committed Oct 1, 2023
1 parent 164faf5 commit 6d8cf45
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 24 deletions.
4 changes: 2 additions & 2 deletions dist/clabe.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! clabe-validator v2.1.7 ~~ https://github.com/center-key/clabe-validator ~~ MIT License
//! clabe-validator v2.1.8 ~~ https://github.com/center-key/clabe-validator ~~ MIT License

export type ClabeBank = {
tag?: string;
Expand All @@ -7,7 +7,7 @@ export type ClabeBank = {
export type ClabeBanksMap = {
[bankCode: number]: ClabeBank;
};
export type ClabeCityInfo = [number, string, ClabeMxState?];
export type ClabeCityInfo = [code: number, name: string, state?: ClabeMxState];
export type ClabeCitiesMap = {
[cityCode: number]: ClabeCityInfo[];
};
Expand Down
11 changes: 5 additions & 6 deletions dist/clabe.dev.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
//! clabe-validator v2.1.7 ~~ https://github.com/center-key/clabe-validator ~~ MIT License
//! clabe-validator v2.1.8 ~~ https://github.com/center-key/clabe-validator ~~ MIT License

const clabe = {
version: '2.1.7',
version: '2.1.8',
computeChecksum(clabeNum17) {
const x = (i) => [3, 7, 1][i % 3];
const add = (sum, digit, i) => sum + (Number(digit) * x(i)) % 10;
const compute = () => (10 - (clabeNum17.split('').slice(0, 17).reduce(add, 0) % 10)) % 10;
return /^[0-9]{17,18}$/.test(clabeNum17) ? compute() : null;
},
validate(clabeNum) {
var _a;
const errorMap = {
length: 'Must be exactly 18 digits long',
characters: 'Must be only numeric digits (no letters)',
Expand All @@ -27,7 +26,7 @@ const clabe = {
clabe.citiesMap[city[0]].push(city) : clabe.citiesMap[city[0]] = [city];
if (!clabe.citiesMap[clabe.cities[0][0]])
clabe.cities.forEach(addCity);
const bank = clabe.banksMap[Number(bankCode)] || {};
const bank = clabe.banksMap[Number(bankCode)] ?? {};
const cities = clabe.citiesMap[Number(cityCode)];
const realChecksum = clabe.computeChecksum(clabeNum);
const getValidationInfo = () => clabeNum.length !== 18 ? { invalid: 'length', data: '' } :
Expand All @@ -37,7 +36,7 @@ const clabe = {
!cities ? { invalid: 'city', data: cityCode } : null;
const validation = getValidationInfo();
const cityState = (city) => city[2] ? city[1] + ' ' + city[2] : city[1];
const numCities = (_a = cities === null || cities === void 0 ? void 0 : cities.length) !== null && _a !== void 0 ? _a : 0;
const numCities = cities?.length ?? 0;
return {
ok: !validation,
formatOk: !validation || ['bank', 'city'].includes(validation.invalid),
Expand Down Expand Up @@ -155,7 +154,7 @@ const clabe = {
634: { tag: 'FINCOMUN', name: 'Fincomún, Servicios Financieros Comunitarios' },
636: { tag: 'HDI SEGUROS', name: 'HDI Seguros' },
637: { tag: 'ORDER', name: 'OrderExpress Casa de Cambio' },
638: { tag: 'AKALA', name: 'Akala, Sociedad Financiera Popular' },
638: { tag: 'NU MEXICO', name: 'Nu México Financiera (Nubank)' },
640: { tag: 'CB JPMORGAN', name: 'J.P. Morgan Casa de Bolsa' },
642: { tag: 'REFORMA', name: 'Operadora de Recursos Reforma' },
646: { tag: 'STP', name: 'Sistema de Transferencias y Pagos STP, SOFOM E.N.R.' },
Expand Down
11 changes: 5 additions & 6 deletions dist/clabe.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
//! clabe-validator v2.1.7 ~~ https://github.com/center-key/clabe-validator ~~ MIT License
//! clabe-validator v2.1.8 ~~ https://github.com/center-key/clabe-validator ~~ MIT License

const clabe = {
version: '2.1.7',
version: '2.1.8',
computeChecksum(clabeNum17) {
const x = (i) => [3, 7, 1][i % 3];
const add = (sum, digit, i) => sum + (Number(digit) * x(i)) % 10;
const compute = () => (10 - (clabeNum17.split('').slice(0, 17).reduce(add, 0) % 10)) % 10;
return /^[0-9]{17,18}$/.test(clabeNum17) ? compute() : null;
},
validate(clabeNum) {
var _a;
const errorMap = {
length: 'Must be exactly 18 digits long',
characters: 'Must be only numeric digits (no letters)',
Expand All @@ -27,7 +26,7 @@ const clabe = {
clabe.citiesMap[city[0]].push(city) : clabe.citiesMap[city[0]] = [city];
if (!clabe.citiesMap[clabe.cities[0][0]])
clabe.cities.forEach(addCity);
const bank = clabe.banksMap[Number(bankCode)] || {};
const bank = clabe.banksMap[Number(bankCode)] ?? {};
const cities = clabe.citiesMap[Number(cityCode)];
const realChecksum = clabe.computeChecksum(clabeNum);
const getValidationInfo = () => clabeNum.length !== 18 ? { invalid: 'length', data: '' } :
Expand All @@ -37,7 +36,7 @@ const clabe = {
!cities ? { invalid: 'city', data: cityCode } : null;
const validation = getValidationInfo();
const cityState = (city) => city[2] ? city[1] + ' ' + city[2] : city[1];
const numCities = (_a = cities === null || cities === void 0 ? void 0 : cities.length) !== null && _a !== void 0 ? _a : 0;
const numCities = cities?.length ?? 0;
return {
ok: !validation,
formatOk: !validation || ['bank', 'city'].includes(validation.invalid),
Expand Down Expand Up @@ -155,7 +154,7 @@ const clabe = {
634: { tag: 'FINCOMUN', name: 'Fincomún, Servicios Financieros Comunitarios' },
636: { tag: 'HDI SEGUROS', name: 'HDI Seguros' },
637: { tag: 'ORDER', name: 'OrderExpress Casa de Cambio' },
638: { tag: 'AKALA', name: 'Akala, Sociedad Financiera Popular' },
638: { tag: 'NU MEXICO', name: 'Nu México Financiera (Nubank)' },
640: { tag: 'CB JPMORGAN', name: 'J.P. Morgan Casa de Bolsa' },
642: { tag: 'REFORMA', name: 'Operadora de Recursos Reforma' },
646: { tag: 'STP', name: 'Sistema de Transferencias y Pagos STP, SOFOM E.N.R.' },
Expand Down
4 changes: 2 additions & 2 deletions dist/clabe.min.js

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions dist/clabe.umd.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! clabe-validator v2.1.7 ~~ https://github.com/center-key/clabe-validator ~~ MIT License
//! clabe-validator v2.1.8 ~~ https://github.com/center-key/clabe-validator ~~ MIT License

(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
Expand All @@ -13,15 +13,14 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.clabe = void 0;
const clabe = {
version: '2.1.7',
version: '2.1.8',
computeChecksum(clabeNum17) {
const x = (i) => [3, 7, 1][i % 3];
const add = (sum, digit, i) => sum + (Number(digit) * x(i)) % 10;
const compute = () => (10 - (clabeNum17.split('').slice(0, 17).reduce(add, 0) % 10)) % 10;
return /^[0-9]{17,18}$/.test(clabeNum17) ? compute() : null;
},
validate(clabeNum) {
var _a;
const errorMap = {
length: 'Must be exactly 18 digits long',
characters: 'Must be only numeric digits (no letters)',
Expand All @@ -39,7 +38,7 @@
clabe.citiesMap[city[0]].push(city) : clabe.citiesMap[city[0]] = [city];
if (!clabe.citiesMap[clabe.cities[0][0]])
clabe.cities.forEach(addCity);
const bank = clabe.banksMap[Number(bankCode)] || {};
const bank = clabe.banksMap[Number(bankCode)] ?? {};
const cities = clabe.citiesMap[Number(cityCode)];
const realChecksum = clabe.computeChecksum(clabeNum);
const getValidationInfo = () => clabeNum.length !== 18 ? { invalid: 'length', data: '' } :
Expand All @@ -49,7 +48,7 @@
!cities ? { invalid: 'city', data: cityCode } : null;
const validation = getValidationInfo();
const cityState = (city) => city[2] ? city[1] + ' ' + city[2] : city[1];
const numCities = (_a = cities === null || cities === void 0 ? void 0 : cities.length) !== null && _a !== void 0 ? _a : 0;
const numCities = cities?.length ?? 0;
return {
ok: !validation,
formatOk: !validation || ['bank', 'city'].includes(validation.invalid),
Expand Down Expand Up @@ -167,7 +166,7 @@
634: { tag: 'FINCOMUN', name: 'Fincomún, Servicios Financieros Comunitarios' },
636: { tag: 'HDI SEGUROS', name: 'HDI Seguros' },
637: { tag: 'ORDER', name: 'OrderExpress Casa de Cambio' },
638: { tag: 'AKALA', name: 'Akala, Sociedad Financiera Popular' },
638: { tag: 'NU MEXICO', name: 'Nu México Financiera (Nubank)' },
640: { tag: 'CB JPMORGAN', name: 'J.P. Morgan Casa de Bolsa' },
642: { tag: 'REFORMA', name: 'Operadora de Recursos Reforma' },
646: { tag: 'STP', name: 'Sistema de Transferencias y Pagos STP, SOFOM E.N.R.' },
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clabe-validator",
"version": "2.1.7",
"version": "2.1.8",
"description": "Analyze or create a CLABE number for a Mexican bank account (written in functional TypeScript)",
"license": "MIT",
"type": "module",
Expand Down Expand Up @@ -94,7 +94,7 @@
},
"devDependencies": {
"@fortawesome/fontawesome-free": "~6.4",
"@types/node": "~20.6",
"@types/node": "~20.8",
"@typescript-eslint/eslint-plugin": "~6.7",
"@typescript-eslint/parser": "~6.7",
"add-dist-header": "~1.3",
Expand Down

0 comments on commit 6d8cf45

Please sign in to comment.