Utility function to create overloaded functions
- Start in usage.js and follow the imports
- Userland interesting stuff can be found in factories.js
- usage.js for examples of… usages
| function isInTheDOM(element) { | |
| return element.ownerDocument === getRootNode(element); | |
| function getRootNode(element) { | |
| var rootNode = element; | |
| var parentNode; | |
| while (parentNode = rootNode.parentNode) { | |
| rootNode = parentNode; | |
| } |
| function makeCar(brand, model) { | |
| return { | |
| brand, | |
| model, | |
| }; | |
| } | |
| const makeToyota = makeCar.bind(null, 'Toyota'); | |
| const makeVolvo = makeCar.bind(null, 'Volvo'); |
| const foos = ['fubar'] | |
| const foo = undefined | |
| const defaultFoos = ['snafu'] | |
| const fubar = foos ? foos : foo ? [foo] : defaultFoos | |
| console.log(fubar) |
The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.
This means you have the following choices:
import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.await import(…) from CommonJS instead of require(…).