Skip to content

Instantly share code, notes, and snippets.

View assertnotnull's full-sized avatar
🏠
Working from home

Patrice Gauthier assertnotnull

🏠
Working from home
View GitHub Profile
@assertnotnull
assertnotnull / promiseMap.ts
Last active October 25, 2021 17:43
Map promises
import R from 'ramda'
export async function mapAsync<Type, ReturnedType>(
promiseFunc: (value: Type) => Promise<ReturnedType>,
values: Type[],
chunk = 3
) {
const processChunk = processWithFunction<Type, ReturnedType>(promiseFunc)
const chunks = R.splitEvery(chunk, values)
return R.flatten(await R.reduce(processChunk, Promise.resolve([]), chunks))
@assertnotnull
assertnotnull / proof.ts
Created October 19, 2022 17:57
mapAsync
import { PerformanceObserver, performance } from 'perf_hooks';
import R from "ramda";
const perfObserver = new PerformanceObserver((items) => {
items.getEntries().forEach((entry) => {
console.log(`${entry.name}: ${entry.duration}}`)
})
})
perfObserver.observe({entryTypes: ["measure"]})
@assertnotnull
assertnotnull / branch-title.fish
Last active May 26, 2026 15:46
Fish shell: git town propose with PR renamed
function branch-title
set -l branch $argv[1]
if test -z "$branch"
set branch (git branch --show-current)
end
echo $branch | sed -E \
's|^([^/]+)/([a-zA-Z]+)-([0-9]+)-(.*)$|\1(\U\2\E-\3): \L\4|; s|-| |g; s|\(([A-Z]+) ([0-9]+)\)|(\1-\2)|'
end