sanity check to get the context if input happens to be the canvas; errors if it can't return a context
npm install force-canvas-contextsanity check to get the context if input happens to be the canvas; errors if it can't return a context


Download node at nodejs.org and install it, if you haven't already.
``sh`
npm install force-canvas-context --save
`js
var forceCanvasContext = require('force-canvas-context');
let canvas = document.createElement('canvas')
let context = forceCanvasContext(canvas)
context = forceCanvasContext(canvas.getContext('2d'))
context = forceCanvasContext('not a context or canvas') // Error
`
forceCanvasContext(ctx:context):context`
...
MIT