UNPKG

type-enforcer

Version:
19 lines (14 loc) 467 B
import { hasOtherValidValue, processOutput } from './helper'; export default (options) => function(newValue, isForcedSave) { const value = options.get.call(this); if (arguments.length) { if (!hasOtherValidValue(options.other, newValue)) { newValue = options.enforce(newValue, value, options); } if (options.compare(newValue, value) || isForcedSave) { options.set.call(this, newValue); } return this; } return processOutput(value, options); };