window-getters
Version:
Safe Window Getters
1 lines • 2 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("windowGetters",[],e):"object"==typeof exports?exports.windowGetters=e():t.windowGetters=e()}(this,(function(){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(o,r,function(e){return t[e]}.bind(null,r));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";function o(t){let e=void 0;return"undefined"!=typeof window&&void 0!==window[t]&&(e=window[t]),e}function r(t){const e=o(t);if(!e)throw new Error(t+" is not defined in Window");return e}Object.defineProperty(e,"__esModule",{value:!0}),e.getFromWindow=o,e.getFromWindowOrThrow=r,e.getDocumentOrThrow=function(){return r("document")},e.getDocument=function(){return o("document")},e.getNavigatorOrThrow=function(){return r("navigator")},e.getNavigator=function(){return o("navigator")},e.getLocationOrThrow=function(){return r("location")},e.getLocation=function(){return o("location")},e.getCryptoOrThrow=function(){return r("crypto")},e.getCrypto=function(){return o("crypto")},e.getLocalStorageOrThrow=function(){return r("localStorage")},e.getLocalStorage=function(){return o("localStorage")}}])}));