Skip to content

Commit

Permalink
chore: extendable wrapper function (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz authored and iamkun committed Feb 28, 2019
1 parent 2e75247 commit 421e02f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@ class Dayjs {
const isStartOf = !Utils.isUndefined(startOf) ? startOf : true
const unit = Utils.prettyUnit(units)
const instanceFactory = (d, m) => {
const ins = wrapper(new Date(this.$y, m, d), this)
const ins = Utils.wrapper(new Date(this.$y, m, d), this)
return isStartOf ? ins : ins.endOf(C.D)
}
const instanceFactorySet = (method, slice) => {
const argumentStart = [0, 0, 0, 0]
const argumentEnd = [23, 59, 59, 999]
return wrapper(this.toDate()[method].apply( // eslint-disable-line prefer-spread
return Utils.wrapper(this.toDate()[method].apply( // eslint-disable-line prefer-spread
this.toDate(),
(isStartOf ? argumentStart : argumentEnd).slice(slice)
), this)
Expand Down Expand Up @@ -225,7 +225,7 @@ class Dayjs {
const instanceFactorySet = (n) => {
const date = new Date(this.$d)
date.setDate(date.getDate() + (n * number))
return wrapper(date, this)
return Utils.wrapper(date, this)
}
if (unit === C.M) {
return instanceFactory(C.M, this.$M)
Expand All @@ -246,7 +246,7 @@ class Dayjs {
}[unit] || 1 // ms

const nextTimeStamp = this.valueOf() + (number * step)
return wrapper(nextTimeStamp, this)
return Utils.wrapper(nextTimeStamp, this)
}

subtract(number, string) {
Expand Down Expand Up @@ -344,7 +344,7 @@ class Dayjs {
}

clone() {
return wrapper(this.toDate(), this)
return Utils.wrapper(this.toDate(), this)
}

toDate() {
Expand Down

0 comments on commit 421e02f

Please sign in to comment.