📦 package
┣ 📂 folder 1
┃ ┗ 📜 file.ts
┃ ┗ 📜 file.js
┃ ┗ 📜 file.css
┃ ┗ 📜 file.html
┣ 📂 folder 2
┃ ┗ 📜 file.mp4
┃ ┗ 📜 file.mp3
This file contains 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 * as React from 'react'; | |
import thunk from 'redux-thunk'; | |
import { render } from '@testing-library/react'; | |
import { Router } from 'react-router'; | |
import { Provider } from 'react-redux'; | |
import configureMockStore from 'redux-mock-store'; | |
// remember to import your history object | |
// store is your redux store |
This file contains 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 { useMemo, useLayoutEffect } from 'react'; | |
export const useScrollIntoView = ( | |
selector: string, | |
options: ScrollIntoViewOptions, | |
): void => { | |
const opts: ScrollIntoViewOptions = useMemo( | |
() => ({ | |
block: 'center', | |
inline: 'center', |
This file contains 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
type ValuesOf<T extends any[]> = T[number]; | |
type IndexedList<T> = Record<string, T>; | |
const exportCSV = <T>(data: Array<IndexedList<ValuesOf<T[]>>>, keys: string[], columns: string[]): string => { | |
let csv = 'data:text/csv;charset=utf-8,'; | |
columns.forEach((column: string) => { | |
csv += `${column},`; | |
}); |
This file contains 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
type Constructor<T> = new (...args: any[]) => T; | |
function OverwriteFetch<T extends Constructor<{}>>(Base: T): Constructor<any> { | |
return class extends Base { | |
constructor(...args: any[]) { | |
super(...[...args, fetch]); | |
} | |
}; | |
} |
This file contains 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
/** | |
* Mock a date which is created with the `new Date()` constructor. | |
* | |
* Usage: | |
* | |
* import { onBeforeEach, onAfterEach } from 'FOLDER/jest-date-mock'; | |
* | |
* describe('', () => { | |
* beforeEach(onBeforeEach); | |
* afterEach(onAfterEach); |
This file contains 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
/** | |
* External dependencies | |
*/ | |
import { auth } from 'react-native-twitter'; | |
import * as firebase from 'firebase'; | |
import Expo, { AuthSession } from 'expo'; | |
/** | |
* Internal dependencies | |
*/ |
This file contains 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
/** | |
* Detailed info about the Hover CSS Media Feature can be found here: | |
* https://developer.mozilla.org/en-US/docs/Web/CSS/@media/hover | |
* | |
* This media query is implemented in almost all modern browsers and works as expected. | |
* The modern browsers include Chrome, Opera, Safari, Edge, Brave, Vivaldi, etc. | |
* Internet Explorer and Firefox do not understand this media feature and therefore will | |
* simply ignore all rules inside the query. | |
* Update: Firefox supports this media feature since version 64. | |
* A workaround can be found below. |
This file contains 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
const { join } = require('path'); | |
const { readdirSync, renameSync } = require('fs'); | |
const [dir, search, replace] = process.argv.slice(2); | |
const match = RegExp(search, 'g'); | |
const files = readdirSync(dir); | |
files | |
.filter(file => file.match(match)) | |
.forEach(file => { | |
const filePath = join(dir, file); |