UNPKG

@ideal-postcodes/address-finder

Version:

Address Finder JS library backed by the Ideal Postcodes UK address search API

32 lines (31 loc) 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.controllers = exports.go = exports.setup = void 0; const controller_1 = require("./controller"); /** * Configure and launch an instance of the Address Finder * * This method will create and return a new AddressFinder instance. It will also add a global reference to the controller at `AddressFinder.controllers` */ const setup = (config) => { const c = new controller_1.Controller(config); exports.controllers.push(c); return c; }; exports.setup = setup; /** * Configure and launch an instance of the Address Finder * * This is equivalent to invoking `setup` except inside a DOMContentLoaded event callback */ const go = (config, d) => new Promise((resolve, _) => { (d || document).addEventListener("DOMContentLoaded", (_) => { const c = (0, exports.setup)(config); return resolve(c); }); }).catch((_) => null); exports.go = go; /** * Cache of Address Finder controllers */ exports.controllers = [];