| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- /**
- * @fileOverview Utility for F2
- * @author dxq613 @gmail.com
- * @author sima.zhang1990@gmail.com
- */
- import { upperFirst, lowerFirst, isString, isNumber, isBoolean, isFunction, isDate, isArray, isNil, isObject, isPlainObject, isEqual, deepMix, mix, each, uniq, find, substitute } from '@antv/util';
- import * as ArrayUtil from './array';
- function isObjectValueEqual(a, b) {
- // for vue.js
- a = Object.assign({}, a);
- b = Object.assign({}, b);
- var aProps = Object.getOwnPropertyNames(a);
- var bProps = Object.getOwnPropertyNames(b);
- if (aProps.length !== bProps.length) {
- return false;
- }
- for (var i = 0, len = aProps.length; i < len; i++) {
- var propName = aProps[i];
- if (a[propName] !== b[propName]) {
- return false;
- }
- }
- return true;
- }
- function parsePadding(padding) {
- var top;
- var right;
- var bottom;
- var left;
- if (isNumber(padding) || isString(padding)) {
- top = bottom = left = right = padding;
- } else if (isArray(padding)) {
- top = padding[0];
- right = !isNil(padding[1]) ? padding[1] : padding[0];
- bottom = !isNil(padding[2]) ? padding[2] : padding[0];
- left = !isNil(padding[3]) ? padding[3] : right;
- }
- return [top, right, bottom, left];
- }
- function directionEnabled(mode, dir) {
- if (mode === undefined) {
- return true;
- } else if (typeof mode === 'string') {
- return mode.indexOf(dir) !== -1;
- }
- return false;
- }
- function toTimeStamp(value) {
- if (isString(value)) {
- if (value.indexOf('T') > 0) {
- value = new Date(value).getTime();
- } else {
- // new Date('2010/01/10') 和 new Date('2010-01-10') 的差别在于:
- // 如果仅有年月日时,前者是带有时区的: Fri Jan 10 2020 02:40:13 GMT+0800 (中国标准时间)
- // 后者会格式化成 Sun Jan 10 2010 08:00:00 GMT+0800 (中国标准时间)
- value = new Date(value.replace(/-/gi, '/')).getTime();
- }
- }
- if (isDate(value)) {
- value = value.getTime();
- }
- return value;
- }
- export { ArrayUtil as Array };
- export * from './dom';
- export { upperFirst, lowerFirst, isString, isNumber, isBoolean, isFunction, isDate, isArray, isNil, isObject, isPlainObject, isEqual, deepMix, mix, each, uniq, find, isObjectValueEqual, parsePadding, directionEnabled, toTimeStamp, substitute };
|