@paperbits/core
Version:
Paperbits core components.
21 lines (17 loc) • 506 B
text/typescript
import * as ko from "knockout";
ko.extenders.max = (target, max) => {
const result = ko.pureComputed({
read: target,
write: (newValue) => {
const current = target();
if (newValue <= max) {
target(newValue);
}
else if (newValue !== current) {
target.notifySubscribers(newValue);
}
}
}).extend({ notify: "always" });
result(target());
return result;
};