- WebStorm, Rider
- Partial support, not enough intelli hints
- Toggle on TypeScript language service
- VSCode
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
// String utils | |
// | |
// resources: | |
// -- mout, https://github.com/mout/mout/tree/master/src/string | |
/** | |
* "Safer" String.toLowerCase() | |
*/ | |
function lowerCase(str) { | |
return str.toLowerCase(); |
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 endpointToPromiseMap = { | |
[ApiEndpoint.FetchAllGoals]: fetchUserGoals, | |
[ApiEndpoint.CurrentUser]: currentUser, | |
}; | |
type PromiseValue<T extends Promise<any>> = T extends Promise<infer U> | |
? U | |
: never; | |
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types |
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
/* | |
* These are some types I found useful during some tricky TypeScript programming. | |
* Many of them are not too common or intuitive to come up with, this is why I'm writing them down here for future lookup. | |
* | |
* Note: Be careful when copy-pasting, some of these types depend on others. | |
*/ | |
/** | |
* Various utilities for working with classes |
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
#List traversal | |
range(start, stop, hop) | |
range(n) # [0,1,...,n-1] | |
range(1,n) # [1,...,n-1] | |
range(1,n,2) # [1,3,5,...,n-1] if n is even, or [1,3,5,...,n-2] if n is odd | |
range(n,-1,-1) # [n,n-1,n-2,...,0] | |
range(len(arr)) # Provides indices of an array arr | |
range(len(arr)-1,-1,-1) # Provides indices of arr backwards | |
# List slicing |
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
var os = require("os"); | |
//Create function to get CPU information | |
function cpuAverage() { | |
//Initialise sum of idle and time of cores and fetch CPU info | |
var totalIdle = 0, totalTick = 0; | |
var cpus = os.cpus(); | |
//Loop through CPU cores |
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 startDate = | |
location.state && location.state.startDate ? location.state.startDate : today | |
const prevStartRef = useRef(startDate) | |
let transitionDirection | |
if (prevStartRef.current !== startDate) { | |
transitionDirection = startDate < prevStartRef.current ? "earlier" : "later" | |
prevStartRef.current = startDate | |
} |
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
{ | |
"name": "webpack-sass", | |
"version": "1.0.0", | |
"scripts": { | |
"start": "webpack-dev-server --open --mode development", | |
"build": "webpack -p" | |
}, | |
"devDependencies": { | |
"babel-core": "^6.26.0", | |
"babel-loader": "^7.1.4", |
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 React from 'react' | |
import { StyleSheet, Text, View, TouchableWithoutFeedback } from 'react-native' | |
import { Spring, animated } from 'react-spring/dist/native' | |
const styles = { | |
flex: 1, | |
margin: 0, | |
borderRadius: 35, | |
backgroundColor: 'red', | |
alignItems: 'center', |
NewerOlder