Note:
<example>is meant to denote text replaced by you (including brackets).
// global dependencies
npm install -g knex| /** | |
| * Filters an array of objects with multiple criteria. | |
| * | |
| * @param {Array} array: the array to filter | |
| * @param {Object} filters: an object with the filter criteria as the property names | |
| * @return {Array} | |
| */ | |
| function multiFilter(array, filters) { | |
| const filterKeys = Object.keys(filters); | |
| // filters all elements passing the criteria |
| // check version | |
| node -v || node --version | |
| // list locally installed versions of node | |
| nvm ls | |
| // list remove available versions of node | |
| nvm ls-remote | |
| // install specific version of node |
| type FilterOperator = 'AND' | 'OR'; | |
| type FiltersBy<T> = { | |
| [K in keyof T]?: (value: T[K]) => boolean; | |
| }; | |
| /** | |
| * Factory function that creates a specialized function to filter | |
| * arrays, by validating all filters (AND operator), | |
| * or validating just one of the filters (OR operator). | |
| * @param operator Method to validate all filters: AND, OR |
| // See https://blog.isquaredsoftware.com/presentations/react-redux-ts-intro-2020-12/#/36 for slides | |
| // My basic render function structure: | |
| function RenderLogicExample({ | |
| someBoolean, // 1) Destructure values from `props` object | |
| someList, | |
| }) { | |
| // 2) Declare state values | |
| const [a, setA] = useState(0); | |
| const [b, setB] = useState(0); |
Either you use .babelrc to specify environment specific settings
(plugins or transforms for example) using the env key:
{
"presets": ["es2015", "stage-0", "react"],
"env": {
"development": {
"plugins": [
["transform-object-rest-spread"],
["transform-react-display-name"],| function debounce(callback, wait, immediate = false) { | |
| let timeout = null | |
| return function() { | |
| const callNow = immediate && !timeout | |
| const next = () => callback.apply(this, arguments) | |
| clearTimeout(timeout) | |
| timeout = setTimeout(next, wait) |