UNPKG

type-enforcer

Version:
18 lines (13 loc) 425 B
import { processOutput } from './helper'; export default (options) => function(newValue, isForcedSave) { const value = options.get.call(this); if (arguments.length) { newValue = options.enforce(newValue, value, options); if (options.compare(newValue, value) || isForcedSave) { options.before.call(this, value); options.set.call(this, newValue); } return this; } return processOutput(value, options); };