Skip to content

Commit

Permalink
chore: Reduce main bundle size (#997)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamkun authored Aug 10, 2020
1 parent f76e3ce commit db976aa
Showing 1 changed file with 16 additions and 33 deletions.
49 changes: 16 additions & 33 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,38 +122,6 @@ class Dayjs {
return this.set(set, input)
}

year(input) {
return this.$g(input, '$y', C.Y)
}

month(input) {
return this.$g(input, '$M', C.M)
}

day(input) {
return this.$g(input, '$W', C.D)
}

date(input) {
return this.$g(input, '$D', C.DATE)
}

hour(input) {
return this.$g(input, '$H', C.H)
}

minute(input) {
return this.$g(input, '$m', C.MIN)
}

second(input) {
return this.$g(input, '$s', C.S)
}

millisecond(input) {
return this.$g(input, '$ms', C.MS)
}

unix() {
return Math.floor(this.valueOf() / 1000)
}
Expand Down Expand Up @@ -398,7 +366,22 @@ class Dayjs {
}
}

dayjs.prototype = Dayjs.prototype
const proto = Dayjs.prototype
dayjs.prototype = proto;
[
['$ms', C.MS],
['$s', C.S],
['$m', C.MIN],
['$H', C.H],
['$W', C.D],
['$M', C.M],
['$y', C.Y],
['$D', C.DATE]
].forEach((g) => {
proto[g[1]] = function (input) {
return this.$g(input, g[0], g[1])
}
})

dayjs.extend = (plugin, option) => {
plugin(option, Dayjs, dayjs)
Expand Down

0 comments on commit db976aa

Please sign in to comment.