Sha256: 6d3a7ec0e9c6d63cdf3f2b642810cc609e4c06638899d2781574ad220c283efc

Contents?: true

Size: 1.51 KB

Versions: 9

Compression:

Stored size: 1.51 KB

Contents

import { deprecate } from '../utils/deprecate';
import isArray from '../utils/is-array';
import { createLocal } from '../create/local';

export var prototypeMin = deprecate(
     'moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548',
     function () {
         var other = createLocal.apply(null, arguments);
         return other < this ? this : other;
     }
 );

export var prototypeMax = deprecate(
    'moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548',
    function () {
        var other = createLocal.apply(null, arguments);
        return other > this ? this : other;
    }
);

// Pick a moment m from moments so that m[fn](other) is true for all
// other. This relies on the function fn to be transitive.
//
// moments should either be an array of moment objects or an array, whose
// first element is an array of moment objects.
function pickBy(fn, moments) {
    var res, i;
    if (moments.length === 1 && isArray(moments[0])) {
        moments = moments[0];
    }
    if (!moments.length) {
        return createLocal();
    }
    res = moments[0];
    for (i = 1; i < moments.length; ++i) {
        if (moments[i][fn](res)) {
            res = moments[i];
        }
    }
    return res;
}

// TODO: Use [].sort instead?
export function min () {
    var args = [].slice.call(arguments, 0);

    return pickBy('isBefore', args);
}

export function max () {
    var args = [].slice.call(arguments, 0);

    return pickBy('isAfter', args);
}

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
sedge_cms-0.0.1 vendor/assets/components/moment/src/lib/moment/min-max.js
date_picker-0.0.6 test/dummy/vendor/assets/components/moment/src/lib/moment/min-max.js
date_picker-0.0.5 test/dummy/vendor/assets/components/moment/src/lib/moment/min-max.js
date_picker-0.0.4 test/dummy/vendor/assets/components/moment/src/lib/moment/min-max.js
date_picker-0.0.3 test/dummy/vendor/assets/components/moment/src/lib/moment/min-max.js
date_picker-0.0.2 test/dummy/vendor/assets/components/moment/src/lib/moment/min-max.js
date_picker-0.0.1 test/dummy/vendor/assets/components/moment/src/lib/moment/min-max.js
puppet-herald-0.8.1 lib/puppet-herald/public/bower_components/moment/src/lib/moment/min-max.js
puppet-herald-0.8.0 lib/puppet-herald/public/bower_components/moment/src/lib/moment/min-max.js