Skip to content

Instantly share code, notes, and snippets.

View mk0y's full-sized avatar

Marko Jakic mk0y

View GitHub Profile
@mk0y
mk0y / lens.js
Created June 9, 2020 12:21 — forked from leihuang23/lens.js
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,

Folder Structure

Motivations

  • Clear feature ownership
  • Module usage predictibility (refactoring, maintainence, you know what's shared, what's not, prevents accidental regressions, avoids huge directories of not-actually-reusable modules, etc)