UNPKG

@arnabxd/bin-lookup

Version:

Search bin details from various bin database

19 lines (18 loc) 582 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.binLookup = void 0; const sources_1 = require("./sources"); const errors_1 = require("./errors"); const binLookup = async (bin, site = 'bins.ws') => { try { bin = bin.toString(); if (!/^\d+$/.test(bin.toString()) || bin.length < 6) { return errors_1.InvalidBin; } return await sources_1.sources[site](parseInt(bin, 10)); } catch (e) { return (0, errors_1.CustomError)('Something went wrong'); } }; exports.binLookup = binLookup;