View script.js
// @ts-check | |
const treeify = require('treeify'); | |
/** | |
* @param {import('webpack').Stats.ToJsonOutput} stats | |
* @param {string | number} id | |
*/ | |
const getModuleById = (stats, id) => stats.modules.find((module) => module.id === id); |
View foo.ts
// https://gist.github.com/OliverJAsh/5de515ad1f81b88409c13cd548c20893 | |
// https://twitter.com/OliverJAsh/status/1334537098469265413 | |
const { Project } = require('ts-morph'); | |
const project = new Project({ | |
tsConfigFilePath: 'tsconfig.app.no-references.json', | |
}); | |
const PATH_TO_MATCH = '/Users/oliverash/Development/unsplash-web/shared/helpers/booleans.ts'; |
View foo.ts
{ | |
declare const fn: <T>(fn: (t: T) => void, t: T) => void; | |
fn( | |
(t) => { | |
// $ExpectType [number, string] | |
// ❌ | |
// Actual: (string | number)[) | |
t; | |
}, |
View foo.ts
import * as Reader from 'fp-ts/lib/Reader'; | |
import { RouteData } from 'helpers/routes/types'; | |
import { pipe, pipeWith } from 'pipe-ts'; | |
// This will soon be part of fp-ts core | |
// https://github.com/gcanti/fp-ts/issues/904#issuecomment-619346296 | |
const chainW: <Q, A, B>( | |
f: (a: A) => Reader.Reader<Q, B>, | |
) => <R>(ma: Reader.Reader<R, A>) => Reader.Reader<R & Q, B> = Reader.chain as Unrestricted; |
View foo.ts
import { from } from 'ix/iterable'; | |
import { map } from 'ix/iterable/operators'; | |
const compare = (a: string, b: string) => | |
from(a).pipe(map((value, index) => value === b[index])); | |
for (const v of compare('yes', 'yas')) { | |
console.log(v); | |
} | |
// true |
View foo.ts
describe.only('createDataCron', () => { | |
it( | |
'init', | |
marbles(m => { | |
const source$ = m.cold('--a| '); | |
const sourceS = ' ^------'; | |
const ms = m.time(' ------|'); | |
const expected = ' --a| '; | |
const cron = createDataCron(source$, ms); |
View foo.ts
describe.only('createDataCron', () => { | |
it( | |
'init', | |
marbles(m => { | |
const source$ = m.cold('--a| '); | |
const sourceS = ' ^------'; | |
const ms = m.time(' ------|'); | |
const expected = ' --a| '; | |
const cron = createDataCron(source$, ms); |
View foo.ts
describe.only('createDataCron', () => { | |
it( | |
'init', | |
marbles(m => { | |
const source$ = m.cold('--a| '); | |
const sourceS = ' ^------'; | |
const ms = m.time(' ------|'); | |
const expected = ' --a| '; | |
const cron = createDataCron(source$, ms); |
View example.ts
const getName = async function*() { | |
yield 'bob'; | |
yield 'baz'; | |
yield 'bar'; | |
}; | |
const getAge = (name: string) => { | |
const responseJson = fetch('https://httpbin.org/get') | |
.then(response => response.json()) | |
// Let's pretend the API is returning an age for us |
View foo.ts
import { marbles } from 'rxjs-marbles/jest'; | |
import { delayUntil } from '../operators'; | |
describe('delayUntil', () => { | |
it( | |
'if notifier emits nothing and then completes after source emits, emits when notifier completes', | |
marbles(m => { | |
const source$ = m.cold(' --a--(b|)'); | |
const notifier$ = m.cold('----------|'); |
NewerOlder