UNPKG

mux-lib

Version:
55 lines (48 loc) 2.34 kB
/*! * mux-lib.js v0.0.5-alpha.12 * (c) 2018-2019 空鱼 * Released under the MIT License. */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('is-plain-object'), require('invariant'), require('warning')) : typeof define === 'function' && define.amd ? define(['exports', 'is-plain-object', 'invariant', 'warning'], factory) : (global = global || self, factory(global['mux-lib'] = global['mux-lib'] || {}, global.isPlainObject, global.invariant, global.warning)); }(this, (function (exports, isPlainObject, invariant, warning) { 'use strict'; isPlainObject = isPlainObject && isPlainObject.hasOwnProperty('default') ? isPlainObject['default'] : isPlainObject; invariant = invariant && invariant.hasOwnProperty('default') ? invariant['default'] : invariant; warning = warning && warning.hasOwnProperty('default') ? warning['default'] : warning; const isArray = Array.isArray; const isFunction = o => typeof o === "function"; const isBoolean = o => typeof o === "boolean"; const isEmptyObject = o => JSON.stringify(o) === "{}"; const isString = o => typeof o === "string"; const checkFunctionType = o => Object.prototype.toString.call(o).replace(/\[object\s(.*)\]/, (all, matched) => matched); const isGeneratorFunction = o => checkFunctionType(o) === "GeneratorFunction"; const isAsyncFunction = o => checkFunctionType(o) === "AsyncFunction"; // 常用的方法 const returnSelf = arg => arg; const noop = () => {}; const hasOwnProperty = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key); const mapToObj = o => { let a = {}; o.forEach((v, k) => { a[k] = v; }); return a; }; exports.isPlainObject = isPlainObject; exports.invariant = invariant; exports.warning = warning; exports.checkFunctionType = checkFunctionType; exports.hasOwnProperty = hasOwnProperty; exports.isArray = isArray; exports.isAsyncFunction = isAsyncFunction; exports.isBoolean = isBoolean; exports.isEmptyObject = isEmptyObject; exports.isFunction = isFunction; exports.isGeneratorFunction = isGeneratorFunction; exports.isString = isString; exports.mapToObj = mapToObj; exports.noop = noop; exports.returnSelf = returnSelf; Object.defineProperty(exports, '__esModule', { value: true }); })));