Skip to content

Commit

Permalink
legacy deprecated peek() method
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jan 21, 2022
1 parent de3ce63 commit 5c74c2b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,23 @@ class LRUCache {
}
}

/* istanbul ignore next - deprecated */
peek (key, opts = {}) {
if (!optsWarned.has('length_property')) {
optsWarned.add('length_property')
const code = 'LRU_CACHE_peek'
const msg = 'please use cache.get(key, {updateRecencyOnGet:false}) instead'
const { prototype } = LRUCache
const { get } = Object.getOwnPropertyDescriptor(prototype, 'peek')
process.emitWarning(msg, 'DeprecationWarning', code, get)
}
return this.get(key, {
...opts,
updateAgeOnGet: false,
updateRecencyOnGet: false,
})
}

delete (key) {
const { dispose } = this
const fromOld = this.old.get(key)
Expand Down

0 comments on commit 5c74c2b

Please sign in to comment.