UNPKG

@ideal-postcodes/address-finder

Version:

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

27 lines (26 loc) 837 B
import { Controller } from "./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` */ export const setup = (config) => { const c = new Controller(config); controllers.push(c); return c; }; /** * Configure and launch an instance of the Address Finder * * This is equivalent to invoking `setup` except inside a DOMContentLoaded event callback */ export const go = (config, d) => new Promise((resolve, _) => { (d || document).addEventListener("DOMContentLoaded", (_) => { const c = setup(config); return resolve(c); }); }).catch((_) => null); /** * Cache of Address Finder controllers */ export const controllers = [];