The package linked to from here is now pure ESM. It cannot be require()'d from CommonJS.
This means you have the following choices:
- Use ESM yourself. (preferred)
Useimport foo from 'foo'instead ofconst foo = require('foo')to import the package. You also need to put"type": "module"in your package.json and more. Follow the below guide. - If the package is used in an async context, you could use
await import(…)from CommonJS instead ofrequire(…). - Stay on the existing version of the package until you can move to ESM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ########################### // | |
| // # Variadic functions in C # // | |
| // ########################### // | |
| /** | |
| * Variadic functions are functions that can take a variable number of arguments. | |
| * It's like spread op. all arguments in function signature in JavaScript. | |
| */ | |
| // ################################################################################# // |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * ['1', '7', '11'].map(parseInt) doesn’t work as intended because map passes | |
| * three arguments into parseInt() on each iteration. The second argument | |
| * index is passed into parseInt as a radix parameter. So, each string in the array | |
| * is parsed using a different radix. '7' is parsed as radix 1, which is NaN, | |
| * '11' is parsed as radix 2, which is 3. '1' is parsed as the default radix 10, | |
| * because its index 0 is falsy. | |
| * | |
| * And so, the following code will work as intended; | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // implementation of querystring parse. | |
| const queryStringDotParse = (str = '') => | |
| str.split('&').reduce((parsedObject, param) => { | |
| if (param === '') return parsedObject | |
| const [key, value] = param.split('=') | |
| parsedObject[key] = decodeURIComponent(value) | |
| return parsedObject | |
| }, {}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @title useCombineReducers Hook | |
| * @description Custom hook to combine all useReducer hooks for one global state container with | |
| * one dispatch function. Use at top-level and pass dispatch function (and state) down | |
| * via React's Context API with Provider and Consumer/useContext. | |
| */ | |
| // --------------------------- Source Code --------------------------- // | |
| /** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useState } from 'react' | |
| function Input({ setTodos, todos }) { | |
| // define the local state | |
| const [todo, setTodo] = React.useState('') | |
| // define the onChange handler | |
| const handleChange = (event) => setTodo(event.target.value) | |
| // define the addTodo handler | |
| const addTodo = () => { | |
| // check that exist todo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ************************************************ | |
| // I was thinking about publish this package to | |
| // npm, but I saw that's not necessary to do | |
| // that, especially we have many wonderful pckgs | |
| // that do the same thing. | |
| // Like: Axios / GOT / Fetch implementations .. | |
| // So, i want to share this code with community. | |
| // ************************************************ | |
| import * as path from 'path'; |
NewerOlder