UNPKG

intl-proxy

Version:

Provides access to the Browsers Intl Api via a Proxy Object. Designed to be used with the accompanying Elm package.

24 lines (23 loc) 564 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const wrap = (fun) => new Proxy({}, { get(_target, arg) { return fun(arg); }, has(_target, _arg) { return true; }, }); /** * An object enabling access to the Intl API via JSON. * * */ const intl_proxy = wrap((json) => { try { const [api, apiArgs, method, methodArgs] = JSON.parse(json); return new Intl[api](...apiArgs)[method](...methodArgs); } catch (_e) { return undefined; } }); exports.default = intl_proxy;