UNPKG

@naverpay/hidash

Version:

improved lodash

2 lines (1 loc) 999 B
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("./isArray.js"),o=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,y=/^\w*$/;function c(r,e){return Array.isArray(r)||typeof r!="string"?!1:y.test(r)||!o.test(r)||e!=null&&r in Object(e)}function a(r){return Array.isArray(r)?r.map(String):typeof r=="string"?r.split("."):[String(r)]}function g(r,e){if(r==null)return!1;const t=c(e,r)?[e]:a(e),l=t.length;let n=r;for(let s=0;s<l;s++){const i=t[s];if(n==null||typeof n!="object"||typeof i!="string"||!Object.prototype.hasOwnProperty.call(n,i))return!1;if(n=n[i],s===t.length-1)return!0}return!0}function f(r,e){if(e==null||Array.isArray(e)&&!e.length)return!1;if(typeof e=="string"){if(!e||e==="."||e==="..")return!1;if(!e.includes("."))return r!=null&&typeof r=="object"&&Object.prototype.hasOwnProperty.call(r,e)}else if(u.isArray(e)&&!e.every(t=>typeof t=="string"))return!1;return g(r,e)}exports.default=f;exports.has=f;