UNPKG

simujs

Version:

Tanzanian phone number detection library based on public TCRA numbering data (not affiliated with TCRA).

20 lines (19 loc) 603 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.simu = simu; const prefixIndex_1 = require("./internal/prefixIndex"); const normalize_1 = require("./normalize"); function simu(phone) { const national = (0, normalize_1.normalize)(phone); if (!national) { return { ok: false, reason: "INVALID_NUMBER" }; } const match = prefixIndex_1.prefixIndex.find(p => national.startsWith(p.prefix)); if (!match) { return { ok: false, reason: "UNKNOWN_OPERATOR" }; } return { ok: true, operator: match.operator, }; }