Skip to content

Instantly share code, notes, and snippets.

View JamieMason's full-sized avatar

Jamie Mason JamieMason

View GitHub Profile
JamieMason / pipe.ts
Created May 9, 2024 14:08
TypeScript pipe function
* Takes a value and passes it through a sequence of functions in left-to-right order.
* A Function that takes an initial value of any type (`unknown`), followed by any number of functions as arguments. It
* returns the result of passing the initial value through each of the functions, one by one, in the order that they
* were passed in. It provides a way to easily chain together multiple functions in a pipeline, where the output of each
* function becomes the input for the next one.
* ## Example
JamieMason / randomise-package-json.js
Last active May 4, 2024 10:58
add random numbers to semver versions in package.json files to create mismatches in fixtures.
const root = "/Users/foldleft/Dev/rust-syncpack/fixtures/fluid-framework";
JamieMason / try-rescript.res
Created December 18, 2023 22:04
Try ReScript
// looking at an alternative to ReScript's Option
// which exists at runtime when compiled to JS
type maybe<'a> = {
_tag: [#Some],
value: 'a,
let createMaybe = (value: 'a): maybe<'a> => {
JamieMason / syncpack-dependents.json
Created September 26, 2023 10:02
Projects depending on, sorted by most stars
{ "org": "@pnpm", "repo": "pnpm/pnpm", "stars": 25486, "forks": 790 },
{ "org": "@mantinedev", "repo": "mantinedev/mantine", "stars": 21487, "forks": 1513 },
{ "org": "@BuilderIO", "repo": "BuilderIO/qwik", "stars": 18903, "forks": 1076 },
{ "org": "@microsoft", "repo": "microsoft/fluentui", "stars": 16391, "forks": 2540 },
{ "org": "@microsoft", "repo": "microsoft/pyright", "stars": 10898, "forks": 1172 },
{ "org": "@callstack", "repo": "callstack/linaria", "stars": 10805, "forks": 430 },
{ "org": "@woocommerce", "repo": "woocommerce/woocommerce", "stars": 8728, "forks": 10800 },
{ "org": "@electron", "repo": "electron/forge", "stars": 5816, "forks": 472 },
{ "org": "@altair-graphql", "repo": "altair-graphql/altair", "stars": 4828, "forks": 272 },
type GetFn = () => {
next(iteration: IteratorResult<any, any>): IteratorResult<any, any>;
function iterateOverSyncOrAsyncGenerator<T extends Iterable<any>>(getIterator: GetFn, gen: T): Iterable<any>;
function iterateOverSyncOrAsyncGenerator<T extends AsyncIterable<any>>(getIterator: GetFn, gen: T): AsyncIterable<any>;
function iterateOverSyncOrAsyncGenerator<T extends Iterable<any> | AsyncIterable<any>>(
getIterator: GetFn,
gen: T
): Iterable<any> | AsyncIterable<any> {
import { R } from '@mobily/ts-belt';
/** Additional helpers for */
export const $R = {
* 1. Return an R.Ok<output[]> if every R.Result succeeds
* 2. Return an R.Error<Error> for the first failure encountered
all<Input, Output = Input>(
getResult: (value: Input) => R.Result<Output, Error>,
JamieMason /
Created March 2, 2022 12:49
Find all modules which a given JavaScript module depends on, and all they modules they depend on, and all they modules they depend on etc.

Find nested dependencies or imports of a JavaScript Module

Find all deep/nested/recursive/descendant dependencies/imports/requires of a JavaScript Module.

Related to sverweij/dependency-cruiser#564, find all modules which a given JavaScript module depends on, and all the modules they depend on, and all the modules they depend on etc.


npm install -g ts-node

List All GitHub Pull Request Reviewers for a Repo

Needs jq installed.


for pull_number in {1..500}
JamieMason /
Last active December 8, 2021 20:34
Lossless Debounce Function in JavaScript

Lossless Debounce Function

Returns a function which will capture and collect all invocation arguments, to process in batches once ms consecutive resting time has passed.

Know a more common name for this function? Let me know in this discussion.


JamieMason /
Created November 29, 2021 16:55
Tick "Viewed" on every file you've scrolled past on a GitHub Pull Request

GitHub PR bulk mark file as viewed

Tick "Viewed" on every file you've scrolled past on a GitHub Pull Request

// Tick "Viewed" on every file you've scrolled past on a
// GitHub Pull Request
$$('.js-reviewed-checkbox').forEach((el) => {
  if (!el.checked && window.scrollY > el.getBoundingClientRect().top) {;