Blame view

node_modules/is-typedarray/index.js 1016 Bytes
ce4c83ff   wxy   初始提交
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
  module.exports      = isTypedArray
  isTypedArray.strict = isStrictTypedArray
  isTypedArray.loose  = isLooseTypedArray
  
  var toString = Object.prototype.toString
  var names = {
      '[object Int8Array]': true
    , '[object Int16Array]': true
    , '[object Int32Array]': true
    , '[object Uint8Array]': true
    , '[object Uint8ClampedArray]': true
    , '[object Uint16Array]': true
    , '[object Uint32Array]': true
    , '[object Float32Array]': true
    , '[object Float64Array]': true
  }
  
  function isTypedArray(arr) {
    return (
         isStrictTypedArray(arr)
      || isLooseTypedArray(arr)
    )
  }
  
  function isStrictTypedArray(arr) {
    return (
         arr instanceof Int8Array
      || arr instanceof Int16Array
      || arr instanceof Int32Array
      || arr instanceof Uint8Array
      || arr instanceof Uint8ClampedArray
      || arr instanceof Uint16Array
      || arr instanceof Uint32Array
      || arr instanceof Float32Array
      || arr instanceof Float64Array
    )
  }
  
  function isLooseTypedArray(arr) {
    return names[toString.call(arr)]
  }