Browse Source

feat: 新增promise判断方法

es6
iapyang 2 years ago
parent
commit
766d499b0f
  1. 4
      src/core/2.base.js
  2. 6
      typescript/core/base.ts

4
src/core/2.base.js

@ -524,6 +524,10 @@
isWindow: function (obj) { isWindow: function (obj) {
return obj != null && obj == obj.window; return obj != null && obj == obj.window;
},
isPromise: function(obj) {
return !!obj && (BI.isObject(obj) || BI.isFunction(obj)) && BI.isFunction(obj.then);
} }
}); });

6
typescript/core/base.ts

@ -376,6 +376,12 @@ export interface _base {
getDate: (...args: (number | string)[]) => Date; getDate: (...args: (number | string)[]) => Date;
getTime: (...args: any[]) => number; getTime: (...args: any[]) => number;
/**
* promise
* @param obj
*/
isPromise: (obj: any) => obj is Promise<any>;
} }
type merge = { type merge = {

Loading…
Cancel
Save