@minionorg/share
Version:
2 lines (1 loc) • 992 B
JavaScript
(function(r,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(r=typeof globalThis<"u"?globalThis:r||self,i(r.index={}))})(this,function(r){"use strict";function i(e){return e.charAt(0).toUpperCase()+e.slice(1)}function l(e){if(!e)throw new SyntaxError("type is must");return function(t){return Object.prototype.toString.call(t)===`[object ${i(e)}]`}}function c(e,t="."){if(!e)return!1;const s=e.trim().split(t);for(const o of s)if(!o||/\s/.test(o))return!1;return!0}function d(e,t,s=void 0,o="."){if(!l("String")(t))throw new TypeError(`${t} is not string type`);if(!c(t,o))throw new Error(`Invalid: ${t}`);const y=t.trim().split(o);let n=e;for(const f of y)if(Array.isArray(n)&&/^\d+$/.test(f)){const u=parseInt(f,10);if(u<n.length)n=n[u];else return s}else if(typeof n=="object"&&f in n)n=n[f];else return s;return n}r.default=d,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});