Skip to content

Commit

Permalink
fix: change valueof definition to allow object.freeze
Browse files Browse the repository at this point in the history
  • Loading branch information
norbertsuski committed Nov 19, 2024
1 parent 975e2fa commit 0a14f6f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/plugin/duration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ class Duration {
constructor(input, unit, locale) {
this.$d = {}
this.$l = locale

Object.defineProperty(this, 'valueOf', {
value: () => this.asMilliseconds(this)
})

if (input === undefined) {
this.$ms = 0
this.parseFromMilliseconds()
Expand Down Expand Up @@ -236,10 +241,6 @@ class Duration {
.fromNow(!withSuffix)
}

valueOf() {
return this.asMilliseconds()
}

milliseconds() { return this.get('milliseconds') }
asMilliseconds() { return this.as('milliseconds') }
seconds() { return this.get('seconds') }
Expand Down

0 comments on commit 0a14f6f

Please sign in to comment.