1.0.0 • Published 5 years ago

weird-instanceof v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

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! 👾