UNPKG

focused

Version:

Lens/Optics library for JavaScript

49 lines (42 loc) 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const Void = exports.Void = { empty: () => { throw "Void.empty! (you're likely using view with a Traversal, try preview or toList instead)"; }, concat: () => { throw "Void.concat! (you're likely using view with a Traversal, try preview or toList instead)"; } }; const List = exports.List = { empty: () => [], concat: xxs => [].concat(...xxs), pure: x => [x], map: (f, xs) => xs.map(f) }; const First = exports.First = { empty: () => null, concat2: (x1, x2) => x1 !== null ? x1 : x2, concat: xs => xs.reduce(First.concat2, null) }; const Any = exports.Any = { empty: () => false, concat2: (x1, x2) => x1 || x2, concat: xs => xs.reduce(Any.concat2, false) }; const Identity = exports.Identity = { pure: x => x, map: (f, x) => f(x), combine: (f, xs) => f(xs) }; const Const = exports.Const = aMonoid => ({ pure: _ => aMonoid.empty(), map: (f, x) => x, combine: (_, xs) => aMonoid.concat(xs) }); const ConstVoid = exports.ConstVoid = Const(Void); const ConstList = exports.ConstList = Const(List); const ConstFirst = exports.ConstFirst = Const(First); const ConstAny = exports.ConstAny = Const(Any);