Skip to content

Instantly share code, notes, and snippets.

View vbfox's full-sized avatar
❄️
Winter is coming

Julien Roncaglia vbfox

❄️
Winter is coming
View GitHub Profile
@vbfox
vbfox / runes.ts
Last active June 9, 2021 14:32
Javascript/Typescript Rune iterators
/**
* Iterate a string runes. Same as iterating [...str]
*
* Note: This assume that the string is well-formed
*
* WARNING: This is useless, use the string iterator.
*/
export function* runeIterator(s: string) {
const len = s.length;
let highSurrogate: number | undefined;
@vbfox
vbfox / useSplitGrid.ts
Last active June 2, 2022 09:15
split-grid as react hooks
import { useRef, useEffect, useCallback } from 'react';
import Split, { SplitOptions, SplitInstance } from 'split-grid';
export function useSplitGrid(options: SplitOptions): SplitInstance | undefined {
const splitInstance = useRef<SplitInstance>();
useEffect(() => {
const split = Split(options);
splitInstance.current = split;
return () => split.destroy();