weird-instanceof
v1.0.0
Published
Call your functions using instanceof operator (drunk programming only)
Downloads
41
Maintainers
Readme
Weird Instanceof 🍻
Call your functions using instanceof operator (drunk programming only).
This is based on Symbol.hasInstance
hook of ES6, so this is not compilable to ES5.
When I understood this is possible, I just had to create this package 😁.
Installation 💿
npm i weird-instanceof
for Node.js
<script src="https://cdn.jsdelivr.net/npm/weird-instanceof@latest/browsers.js"></script>
for Browsers
API 🐱👤
Well, this works like this:
const WeirdInstanceof = require('weird-instanceof'); // Global 'WeirdInstanceof' is defined for browsers
const SuperAmazingCuttingEdgeFunction = WeirdInstanceof(arg => {
console.log(`State-of-art ${arg}`);
return true;
});
1 instanceof SuperAmazingCuttingEdgeFunction; // State-of-art 1; true
`abc` instanceof SuperAmazingCuttingEdgeFunction; // State-of-art 2; true
{} instanceof SuperAmazingCuttingEdgeFunction; // State-of-art {}; true
That's it, thanks! 👾