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 59fdb1f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,8 @@
"rollup-plugin-terser": "^7.0.2",
"size-limit": "^0.18.0",
"typescript": "^2.8.3"
},
"volta": {
"node": "16.20.2"
}
}
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()
})

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 59fdb1f

Please # to comment.