Skip to content

Instantly share code, notes, and snippets.

@wes-goulet
wes-goulet / launch.json
Created April 18, 2020 21:47
Example VSCode Debug Config for debugging rollup and jest tests
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Rollup",
"program": "${workspaceFolder}/node_modules/.bin/rollup",
"args": ["-c"],
"internalConsoleOptions": "openOnSessionStart"
@wes-goulet
wes-goulet / type-guard-example.js
Created October 10, 2020 18:31
Type Guard in jsdoc comment
/** @typedef {{swim: () => void}} Fish */
/** @typedef {{fly: () => void}} Bird */
/**
* @param {Fish | Bird} pet
* @returns {pet is Fish}
*/
function isFish(pet) {
return "swim" in pet;
}
window.onscroll = function () {
/** @type {HTMLElement | null} */
const header = document.querySelector('header');
if (header !== null) {
if (window.scrollY < 5) {
header.classList.remove('scrolled');
} else {
header.classList.add('scrolled');
}
}
@wes-goulet
wes-goulet / insta-fetcher.mjs
Created May 11, 2022 23:09
Node script to fetch instagram posts for a given user and save the files to a folder
#!/usr/bin/env node
// @ts-check
import fetch from "node-fetch";
import fs from "fs";
import { IgApiClient } from "instagram-private-api";
/**
* @typedef InstaPost
* @prop {string} thumbnailUrl