Skip to content

Instantly share code, notes, and snippets.

View mk0y's full-sized avatar

Marko Jakic mk0y

View GitHub Profile
@sc0ttj
sc0ttj / vanilla-js-router.js
Last active April 28, 2023 12:12
Vanilla JS Router
/* Vanilla JS router
*
* An isomorphic router - works client-side (browser), or server-side (NodeJS)
*
* It resolves URL paths like '/profile/1' to route patterns such as '/profile/:id',
* and generates a params object that is passed to each route.
*
* Features:
*
* - Easy setup, zero dependencies
@leihuang23
leihuang23 / lens.js
Created January 18, 2019 00:08
Lens implementation in JavaScript
const curry = fn => (...args) =>
args.length >= fn.length ? fn(...args) : curry(fn.bind(undefined, ...args))
const always = a => b => a
const compose = (...fns) => args => fns.reduceRight((x, f) => f(x), args)
const getFunctor = x =>
Object.freeze({
value: x,
@outbreak
outbreak / lens.js
Last active June 9, 2020 11:13
Functional Lenses
// Operators
const eq = (a) => (b) => a === b
// Types
const typeOf = (a) => typeof a
const isArray = (a) => Array.isArray(a)
const isUndefined = (a) => eq('undefined')(typeOf(a))
// Lists
const reverse = (xs) => xs.reverse()