UNPKG

weird-instanceof

Version:

Call your functions using instanceof operator (drunk programming only)

27 lines (20 loc) 982 B
# Weird Instanceof 🍻 Call your functions using instanceof operator (drunk programming only). <br/> This is based on `Symbol.hasInstance` hook of ES6, so this is not compilable to ES5. <br/> When I understood this is possible, I just had to create this package 😁. ## Installation 💿 `npm i weird-instanceof` for Node.js <br/> `<script src="https://cdn.jsdelivr.net/npm/weird-instanceof@latest/browsers.js"></script>` for Browsers <br/> ## API 🐱‍👤 Well, this works like this: ```js 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! 👾