is-webgl-context
Advanced tools
Comparing version 1.0.0 to 1.1.0
27
index.js
@@ -1,10 +0,17 @@ | ||
module.exports = function(ctx) { | ||
if (!ctx) return false | ||
var gl = ctx | ||
//compatibility with Chrome WebGL Inspector Addon | ||
if (typeof ctx.rawgl !== 'undefined') | ||
gl = ctx.rawgl | ||
if (typeof WebGLRenderingContext !== 'undefined' && gl instanceof WebGLRenderingContext) | ||
return true | ||
return false | ||
} | ||
/*globals WebGL2RenderingContext,WebGLRenderingContext*/ | ||
module.exports = function isWebGLContext (ctx) { | ||
if (!ctx) return false | ||
var gl = ctx | ||
// compatibility with Chrome WebGL Inspector Addon | ||
if (typeof ctx.rawgl !== 'undefined') { | ||
gl = ctx.rawgl | ||
} | ||
if ((typeof WebGLRenderingContext !== 'undefined' | ||
&& gl instanceof WebGLRenderingContext) || | ||
(typeof WebGL2RenderingContext !== 'undefined' | ||
&& gl instanceof WebGL2RenderingContext)) { | ||
return true | ||
} | ||
return false | ||
} |
{ | ||
"name": "is-webgl-context", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "whether the given object is a WebGL context", | ||
@@ -14,2 +14,6 @@ "main": "index.js", | ||
"devDependencies": { | ||
"browserify": "^8.1.0", | ||
"faucet": "0.0.1", | ||
"smokestack": "^3.1.0", | ||
"tap-closer": "^1.0.0", | ||
"tape": "^3.0.0", | ||
@@ -19,3 +23,3 @@ "webgl-context": "^1.2.1" | ||
"scripts": { | ||
"test": "node test.js" | ||
"test": "browserify test.js | tap-closer | smokestack | tap-spec " | ||
}, | ||
@@ -22,0 +26,0 @@ "keywords": [ |
@@ -5,4 +5,6 @@ # is-webgl-context | ||
Test whether the given object is a WebGL context. This is useful to handle edge-cases, such as when [Chrome WebGL Inspector](https://chrome.google.com/webstore/detail/webgl-inspector/ogkcjmbhnfmlnielkjhedpcjomeaghda?hl=en) wraps WebGLRenderingContext in a different type. | ||
Test whether the given object is a WebGL or WebGL2 context. This is useful to handle edge-cases, such as when [Chrome WebGL Inspector](https://chrome.google.com/webstore/detail/webgl-inspector/ogkcjmbhnfmlnielkjhedpcjomeaghda?hl=en) wraps WebGLRenderingContext in a different type. | ||
Runs in Node and the browser. | ||
```js | ||
@@ -20,3 +22,3 @@ var isGL = require('is-webgl-context') | ||
Returns true if the object is an instance of WebGLRenderingContext, handling edge cases for WebGL debuggers/inspectors. | ||
Returns true if the object is an instance of WebGL[2]RenderingContext, handling edge cases for WebGL debuggers/inspectors. | ||
@@ -23,0 +25,0 @@ ## License |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
3506
16
26
0
6