UNPKG

get-safe

Version:

safe access to deeply nested properties and functions in JS objects without getting a TypeError

1 lines 1.18 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.getSafe=e():t.getSafe=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,n){"use strict";var r=n(1);t.exports=r},function(t,e,n){"use strict";var r=function(t){return null!==t&&void 0!==t};t.exports=function(t,e){for(var n=arguments.length,o=Array(n>2?n-2:0),u=2;u<n;u++)o[u-2]=arguments[u];var i=t.split("."),f=i.pop(),c=function(t){return"string"==typeof t&&"()"===t.slice(-2)}(f);f=c?f.slice(0,-2):f;var p=i.reduce(function(t,e){return r(t)?t[e]:void 0},e),s=o[0];return r(p)?c?p[f]&&"function"==typeof p[f]?p[f].apply(p,o):void 0:p[f]:c?void 0:s}}])});