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 backoff = (config?: { readonly scale?: number; readonly count?: number; }): readonly number[] => { | |
return [...Array(config?.count ?? 4).keys()].map(item => 2 ** item * (config?.scale ?? 1)); | |
} | |
const backoff$ = (config?: { readonly delay?: number; readonly count?: number; readonly scale?: number;}) => { | |
return from([...Array(config?.count ?? 4).keys()]).pipe( | |
concatMap(next => timer((config?.scale ?? 2) ** next * (config?.delay ?? 500))) | |
) | |
} |
- No loops
- No IF statements
- Functions are a single return
- No side effects
- No assignment in functions
- No arrays
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 { fromEvent, pipe } = Rx; | |
const { scan, throttleTime } = RxOperators; | |
const tick = () => scan(next => next + 1, 0); | |
const throttled = () => throttleTime(500); | |
const paced = () => pipe(throttled(), tick()); | |
fromEvent(document, 'click').pipe(paced()); |
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
export const environment = (...features: ReadonlyArray<Record<string, unknown>>) => ({ | |
redirectTo: { | |
pwa: 'http://localhost:8100', | |
}, | |
...features.reduce((acc, next) => ({ ...acc, ...next}), {}) | |
} as const); | |
// environment(withFoo(), withBar(), ...) |
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 range = ({ min = 0, max = 10, step = 1}): number[] => { | |
return min > max ? [] : [min, ...range({ min: min + 1, max, step})].filter(item => item % step === 0); | |
} |
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 url = 'https://gist.githubusercontent.com/dperuo/7d93a334ce56fe8c746d4c6da92c2ee3/raw'; | |
console.log(`deno run ${url}`); |
Nullam id dolor id nibh1 ultricies vehicula ut id elit. Donec id2 elit non mi porta gravida at eget metus. Aenean lacinia bibendum nulla sed consectetur. Donec ullamcorper nulla non metus auctor fringilla. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.
1 Nullam id dolor id nibh ultricies vehicula ut id elit.
2 Donec sed odio dui.
NewerOlder