MCPcopy
hub / github.com/tdewolff/minify / addSubtract

Function addSubtract

_benchmarks/sample_moment.js:3668–3692  ·  view source on GitHub ↗
(mom, duration, isAdding, updateOffset)

Source from the content-addressed store, hash-verified

3666 }
3667
3668 function addSubtract(mom, duration, isAdding, updateOffset) {
3669 var milliseconds = duration._milliseconds,
3670 days = absRound(duration._days),
3671 months = absRound(duration._months);
3672
3673 if (!mom.isValid()) {
3674 // No op
3675 return;
3676 }
3677
3678 updateOffset = updateOffset == null ? true : updateOffset;
3679
3680 if (months) {
3681 setMonth(mom, get(mom, 'Month') + months * isAdding);
3682 }
3683 if (days) {
3684 set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
3685 }
3686 if (milliseconds) {
3687 mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
3688 }
3689 if (updateOffset) {
3690 hooks.updateOffset(mom, days || months);
3691 }
3692 }
3693
3694 var add = createAdder(1, 'add'),
3695 subtract = createAdder(-1, 'subtract');

Callers 2

getSetOffsetFunction · 0.85
createAdderFunction · 0.85

Calls 4

setMonthFunction · 0.85
absRoundFunction · 0.70
getFunction · 0.70
set$1Function · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…