UNPKG

result-js

Version:
20 lines (14 loc) 377 B
'use strict'; const Result = require('../interface/result.h'); const hProto = Result.prototype; const sym = require('../interface/result-sym.h'); hProto.mapErr = function ($op) { const op = typeof $op === 'function' ? $op : () => this[sym.value] ; if (!this[sym.isOk]) { this[sym.value] = op(this[sym.value]); } return this; };