-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
985 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,25 @@ | ||
// 手动 poliyfill 以最小的代码量兼容IE6(ES3); | ||
// const emptyFn = function(){}; | ||
export const isArray = | ||
Array.isArray || | ||
function(obj) { | ||
Object.prototype.toString.call(obj) == '[object Array]'; | ||
function(obj): obj is Array<any> { | ||
return Object.prototype.toString.call(obj) == '[object Array]'; | ||
}; | ||
export const hasArrayBuffer = typeof ArrayBuffer === 'function'; | ||
export const MyArrayBuffer = hasArrayBuffer ? ArrayBuffer : function() {}; | ||
export const myUint8arrayClass = hasArrayBuffer ? Uint8Array : Array; | ||
export const getUint8Array = hasArrayBuffer | ||
? function(arr: any) { | ||
return new Uint8Array(arr); | ||
} | ||
: function(arr: any) { | ||
return typeof arr === 'number' ? new Array(arr) : arr; | ||
}; | ||
// export const MyArrayBuffer = hasArrayBuffer ? ArrayBuffer : emptyFn; | ||
// export const MyUint8Array = hasArrayBuffer ? Uint8Array : emptyFn; | ||
export const MyLikeUint8array = hasArrayBuffer ? Uint8Array : Array; | ||
// export const myUint8arrayClass = hasArrayBuffer ? Uint8Array : Array; | ||
// export const getUint8Array = hasArrayBuffer | ||
// ? function(arg: any) { | ||
// return new Uint8Array(arg); | ||
// } | ||
// : function(arg: any) { | ||
// return typeof arg === 'number' ? new Array(arg) : arg; | ||
// }; | ||
export const isUint8Array = function(obj: any): obj is Uint8Array { | ||
return hasArrayBuffer && obj instanceof Uint8Array; | ||
}; | ||
export const isArrayBuffer = function(obj: any): obj is ArrayBuffer { | ||
return hasArrayBuffer && obj instanceof ArrayBuffer; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.