UNPKG

@nutui/nutui-react

Version:

京东风格的轻量级移动端 React 组件库,支持一套代码生成 H5 和小程序

59 lines (58 loc) 1.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function _export(target, all) { for(var name in all)Object.defineProperty(target, name, { enumerable: true, get: all[name] }); } _export(exports, { clamp: function() { return clamp; }, isFunction: function() { return isFunction; }, isObject: function() { return isObject; }, isPromise: function() { return isPromise; }, preventDefault: function() { return preventDefault; }, upperCaseFirst: function() { return upperCaseFirst; } }); var _type_of = require("@swc/helpers/_/_type_of"); var isObject = function isObject(val) { return val !== null && (typeof val === "undefined" ? "undefined" : (0, _type_of._)(val)) === 'object'; }; var isFunction = function isFunction(val) { return typeof val === 'function'; }; var isPromise = function isPromise(val) { return isObject(val) && isFunction(val.then) && isFunction(val.catch); }; var upperCaseFirst = function upperCaseFirst(str) { str = str.toLowerCase(); str = str.replace(/\b\w+\b/g, function(word) { return word.substring(0, 1).toUpperCase() + word.substring(1); }); return str; }; var clamp = function clamp(num, min, max) { return Math.min(Math.max(num, min), max); }; function preventDefault(event, isStopPropagation) { if (typeof event.cancelable !== 'boolean' || event.cancelable) { event.preventDefault(); } if (isStopPropagation) { event.stopPropagation(); } }