Skip to content

Instantly share code, notes, and snippets.

View stefanmaric's full-sized avatar
🐿️
ship it

Stefan Maric stefanmaric

🐿️
ship it
View GitHub Profile
@stefanmaric
stefanmaric / README.md
Created March 21, 2020 18:47
CS:Source setup on Ubuntu

CS:Source setup on Ubuntu

@stefanmaric
stefanmaric / selectRelativeTimeUnit.js
Last active September 21, 2021 22:20
Util function to select unit and value for the Intl.RelativeTimeFormat API
export const UNITS = [
{
multiplier: 1000,
name: 'second',
threshold: 45,
},
{
multiplier: 60,
name: 'minute',
threshold: 45,
@stefanmaric
stefanmaric / findInStream.test.ts
Last active July 23, 2024 15:25
Find and replace in web stream
import { strict as assert } from 'node:assert'
import fs from 'node:fs'
import path from 'node:path'
import { afterEach, beforeEach, describe, it } from 'node:test'
import { Readable } from 'node:stream'
import { findInStream as _find } from './src/utils/findInStream'
const findInStream = (pathname: string, search: string) => {
return _find(Readable.toWeb(fs.createReadStream(pathname)), search)