UNPKG

press-ui

Version:

简单、易用的跨端组件库,兼容 Vue2 和 Vue3,同时支持 uni-app和普通 Vue 项目

55 lines (38 loc) 925 B
import { isObject, isPlainObject } from '../utils/validator'; const REGEXP = /{|}|"/g; export function noop() {} export function get(object, path) { const keys = path.split('.'); let result = object; keys.forEach((key) => { result = isObject(result) ? (result[key] || '') : ''; }); return result; } export function keys(obj) { return JSON.stringify(obj) .replace(REGEXP, '') .split(',') .map(item => item.split(':')[0]); } export function pickExclude(obj, keys) { if (!isPlainObject(obj)) { return {}; } return Object.keys(obj).reduce((prev, key) => { if (!keys.includes(key)) { prev[key] = obj[key]; } return prev; }, {}); } export function isEmpty(object) { if (!object) return true; if (Array.isArray(object)) { return !object.length; } if (typeof object === 'object') { return !Object.keys(object).length; } return !object; }