corrade-nucleus-nucleons – Blame information for rev 38

Subversion Repositories:
Rev:
Rev Author Line No. Line
38 office 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';
5  
6 export var prototypeMin = deprecate(
7 'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',
8 function () {
9 var other = createLocal.apply(null, arguments);
10 if (this.isValid() && other.isValid()) {
11 return other < this ? this : other;
12 } else {
13 return createInvalid();
14 }
15 }
16 );
17  
18 export var prototypeMax = deprecate(
19 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',
20 function () {
21 var other = createLocal.apply(null, arguments);
22 if (this.isValid() && other.isValid()) {
23 return other > this ? this : other;
24 } else {
25 return createInvalid();
26 }
27 }
28 );
29  
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.
32 //
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) {
36 var res, i;
37 if (moments.length === 1 && isArray(moments[0])) {
38 moments = moments[0];
39 }
40 if (!moments.length) {
41 return createLocal();
42 }
43 res = moments[0];
44 for (i = 1; i < moments.length; ++i) {
45 if (!moments[i].isValid() || moments[i][fn](res)) {
46 res = moments[i];
47 }
48 }
49 return res;
50 }
51  
52 // TODO: Use [].sort instead?
53 export function min () {
54 var args = [].slice.call(arguments, 0);
55  
56 return pickBy('isBefore', args);
57 }
58  
59 export function max () {
60 var args = [].slice.call(arguments, 0);
61  
62 return pickBy('isAfter', args);
63 }