weird-instanceof

1.0.0 • Public • Published

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

Package Sidebar

Install

npm i weird-instanceof

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

3.83 kB

Total Files

5

Last publish

Collaborators

  • jncmark