twgl.js 5.0.1 → 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @license twgl.js 5.0.1 Copyright (c) 2015, Gregg Tavares All Rights Reserved.
2
+ * @license twgl.js 5.0.2 Copyright (c) 2015, Gregg Tavares All Rights Reserved.
3
3
  * Available via the MIT license.
4
4
  * see: http://github.com/greggman/twgl.js for details
5
5
  */
@@ -1585,24 +1585,45 @@ function warn() {
1585
1585
  (_console2 = console).warn.apply(_console2, arguments);
1586
1586
  }
1587
1587
 
1588
+ var isTypeWeakMaps = new Map();
1589
+
1590
+ function isType(object, type) {
1591
+ var weakMap = isTypeWeakMaps.get(type);
1592
+
1593
+ if (!weakMap) {
1594
+ weakMap = new WeakMap();
1595
+ isTypeWeakMaps.set(type, weakMap);
1596
+ }
1597
+
1598
+ var isOfType = weakMap.get(object);
1599
+
1600
+ if (isOfType === undefined) {
1601
+ var s = Object.prototype.toString.call(object);
1602
+ isOfType = s.substring(8, s.length - 1) === type;
1603
+ weakMap.set(object, isOfType);
1604
+ }
1605
+
1606
+ return isOfType;
1607
+ }
1608
+
1588
1609
  function isBuffer(gl, t) {
1589
- return typeof WebGLBuffer !== 'undefined' && t instanceof WebGLBuffer;
1610
+ return typeof WebGLBuffer !== 'undefined' && isType(t, 'WebGLBuffer');
1590
1611
  }
1591
1612
 
1592
1613
  function isRenderbuffer(gl, t) {
1593
- return typeof WebGLRenderbuffer !== 'undefined' && t instanceof WebGLRenderbuffer;
1614
+ return typeof WebGLRenderbuffer !== 'undefined' && isType(t, 'WebGLRenderbuffer');
1594
1615
  }
1595
1616
 
1596
1617
  function isShader(gl, t) {
1597
- return typeof WebGLShader !== 'undefined' && t instanceof WebGLShader;
1618
+ return typeof WebGLShader !== 'undefined' && isType(t, 'WebGLShader');
1598
1619
  }
1599
1620
 
1600
1621
  function isTexture(gl, t) {
1601
- return typeof WebGLTexture !== 'undefined' && t instanceof WebGLTexture;
1622
+ return typeof WebGLTexture !== 'undefined' && isType(t, 'WebGLTexture');
1602
1623
  }
1603
1624
 
1604
1625
  function isSampler(gl, t) {
1605
- return typeof WebGLSampler !== 'undefined' && t instanceof WebGLSampler;
1626
+ return typeof WebGLSampler !== 'undefined' && isType(t, 'WebGLSampler');
1606
1627
  }
1607
1628
 
1608
1629
  /***/ }),
@@ -1,4 +1,4 @@
1
- /* @license twgl.js 5.0.1 Copyright (c) 2015, Gregg Tavares All Rights Reserved.
1
+ /* @license twgl.js 5.0.2 Copyright (c) 2015, Gregg Tavares All Rights Reserved.
2
2
  Available via the MIT license.
3
3
  see: http://github.com/greggman/twgl.js for details */
4
4
  /*
@@ -1949,24 +1949,41 @@ function warn(...args) {
1949
1949
  console.warn(...args);
1950
1950
  }
1951
1951
 
1952
+ const isTypeWeakMaps = new Map();
1953
+
1954
+ function isType(object, type) {
1955
+ let weakMap = isTypeWeakMaps.get(type);
1956
+ if (!weakMap) {
1957
+ weakMap = new WeakMap();
1958
+ isTypeWeakMaps.set(type, weakMap);
1959
+ }
1960
+ let isOfType = weakMap.get(object);
1961
+ if (isOfType === undefined) {
1962
+ const s = Object.prototype.toString.call(object);
1963
+ isOfType = s.substring(8, s.length - 1) === type;
1964
+ weakMap.set(object, isOfType);
1965
+ }
1966
+ return isOfType;
1967
+ }
1968
+
1952
1969
  function isBuffer(gl, t) {
1953
- return typeof WebGLBuffer !== 'undefined' && t instanceof WebGLBuffer;
1970
+ return typeof WebGLBuffer !== 'undefined' && isType(t, 'WebGLBuffer');
1954
1971
  }
1955
1972
 
1956
1973
  function isRenderbuffer(gl, t) {
1957
- return typeof WebGLRenderbuffer !== 'undefined' && t instanceof WebGLRenderbuffer;
1974
+ return typeof WebGLRenderbuffer !== 'undefined' && isType(t, 'WebGLRenderbuffer');
1958
1975
  }
1959
1976
 
1960
1977
  function isShader(gl, t) {
1961
- return typeof WebGLShader !== 'undefined' && t instanceof WebGLShader;
1978
+ return typeof WebGLShader !== 'undefined' && isType(t, 'WebGLShader');
1962
1979
  }
1963
1980
 
1964
1981
  function isTexture(gl, t) {
1965
- return typeof WebGLTexture !== 'undefined' && t instanceof WebGLTexture;
1982
+ return typeof WebGLTexture !== 'undefined' && isType(t, 'WebGLTexture');
1966
1983
  }
1967
1984
 
1968
1985
  function isSampler(gl, t) {
1969
- return typeof WebGLSampler !== 'undefined' && t instanceof WebGLSampler;
1986
+ return typeof WebGLSampler !== 'undefined' && isType(t, 'WebGLSampler');
1970
1987
  }
1971
1988
 
1972
1989
  /*
package/dist/5.x/twgl.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @license twgl.js 5.0.1 Copyright (c) 2015, Gregg Tavares All Rights Reserved.
2
+ * @license twgl.js 5.0.2 Copyright (c) 2015, Gregg Tavares All Rights Reserved.
3
3
  * Available via the MIT license.
4
4
  * see: http://github.com/greggman/twgl.js for details
5
5
  */
@@ -1585,24 +1585,45 @@ function warn() {
1585
1585
  (_console2 = console).warn.apply(_console2, arguments);
1586
1586
  }
1587
1587
 
1588
+ var isTypeWeakMaps = new Map();
1589
+
1590
+ function isType(object, type) {
1591
+ var weakMap = isTypeWeakMaps.get(type);
1592
+
1593
+ if (!weakMap) {
1594
+ weakMap = new WeakMap();
1595
+ isTypeWeakMaps.set(type, weakMap);
1596
+ }
1597
+
1598
+ var isOfType = weakMap.get(object);
1599
+
1600
+ if (isOfType === undefined) {
1601
+ var s = Object.prototype.toString.call(object);
1602
+ isOfType = s.substring(8, s.length - 1) === type;
1603
+ weakMap.set(object, isOfType);
1604
+ }
1605
+
1606
+ return isOfType;
1607
+ }
1608
+
1588
1609
  function isBuffer(gl, t) {
1589
- return typeof WebGLBuffer !== 'undefined' && t instanceof WebGLBuffer;
1610
+ return typeof WebGLBuffer !== 'undefined' && isType(t, 'WebGLBuffer');
1590
1611
  }
1591
1612
 
1592
1613
  function isRenderbuffer(gl, t) {
1593
- return typeof WebGLRenderbuffer !== 'undefined' && t instanceof WebGLRenderbuffer;
1614
+ return typeof WebGLRenderbuffer !== 'undefined' && isType(t, 'WebGLRenderbuffer');
1594
1615
  }
1595
1616
 
1596
1617
  function isShader(gl, t) {
1597
- return typeof WebGLShader !== 'undefined' && t instanceof WebGLShader;
1618
+ return typeof WebGLShader !== 'undefined' && isType(t, 'WebGLShader');
1598
1619
  }
1599
1620
 
1600
1621
  function isTexture(gl, t) {
1601
- return typeof WebGLTexture !== 'undefined' && t instanceof WebGLTexture;
1622
+ return typeof WebGLTexture !== 'undefined' && isType(t, 'WebGLTexture');
1602
1623
  }
1603
1624
 
1604
1625
  function isSampler(gl, t) {
1605
- return typeof WebGLSampler !== 'undefined' && t instanceof WebGLSampler;
1626
+ return typeof WebGLSampler !== 'undefined' && isType(t, 'WebGLSampler');
1606
1627
  }
1607
1628
 
1608
1629
  /***/ }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "twgl.js",
3
- "version": "5.0.1",
3
+ "version": "5.0.2",
4
4
  "description": "A Tiny WebGL helper library",
5
5
  "main": "dist/5.x/twgl-full.js",
6
6
  "types": "dist/5.x/twgl-full.d.ts",