1 import { deprecate } from '../utils/deprecate';
2 import isArray from '../utils/is-array';
3 import { createLocal } from '../create/local';
4 import { createInvalid } from '../create/valid';
6 export var prototypeMin = deprecate(
7 'moment().min is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548',
9 var other = createLocal.apply(null, arguments);
10 if (this.isValid() && other.isValid()) {
11 return other < this ? this : other;
13 return createInvalid();
18 export var prototypeMax = deprecate(
19 'moment().max is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548',
21 var other = createLocal.apply(null, arguments);
22 if (this.isValid() && other.isValid()) {
23 return other > this ? this : other;
25 return createInvalid();
30 // Pick a moment m from moments so that m[fn](other) is true for all
31 // other. This relies on the function fn to be transitive.
33 // moments should either be an array of moment objects or an array, whose
34 // first element is an array of moment objects.
35 function pickBy(fn, moments) {
37 if (moments.length === 1 && isArray(moments[0])) {
40 if (!moments.length) {
44 for (i = 1; i < moments.length; ++i) {
45 if (!moments[i].isValid() || moments[i][fn](res)) {
52 // TODO: Use [].sort instead?
53 export function min () {
54 var args = [].slice.call(arguments, 0);
56 return pickBy('isBefore', args);
59 export function max () {
60 var args = [].slice.call(arguments, 0);
62 return pickBy('isAfter', args);