Skip to main content
Module

x/rambda/source/once.js

Faster and smaller alternative to Ramda
Go to Latest
File
import {curry} from './curry'
function onceFn(fn, context) { let result
return function () { if (fn) { result = fn.apply(context || this, arguments) fn = null }
return result }}
export function once(fn, context) { if (arguments.length === 1) { const wrap = onceFn(fn, context)
return curry(wrap) }
return onceFn(fn, context)}