lukeed / lukeed/flru

Addl methods?

Open
#1 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

maybe
Dominant language
JavaScript
Stars
347
Forks
5
PR merge metrics
No merged PRs in 30d

Description

Could add keys, values, and/or forEach methods... but the problem is whether or not to include the "stale" (prev) cache values. These are technically on their way out & not necessarily current values, but may be. 🤔

Since a LRU is really just a set and get anyway, this may fall out of scope anyway.

Could also add a remove method, but it still falls out of scope. At least it doesn't have the same stale-vs-not concern.

Extracted snippet before release. Removing methods is breaking, but adding them is not~

remove: function (key) {
  if (curr[key] !== void 0) {
    curr[key] = void 0;
  }
  if (prev[key] !== void 0) {
    prev[key] = void 0;
  }
},
keys: function () {
  var k, arr=[];
  for (k in curr) arr.push(k);
  return arr;
},
values: function () {
  var k, arr=[];
  for (k in curr) arr.push(curr[k]);
  return arr;
},
forEach: function (fn, ctx) {
  ctx = ctx || this;
  for (var k in curr) {
    fn.call(ctx, curr[k], k, curr);
  }
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue does not name a file or test; start by locating the LRU implementation and tracing how the curr and prev caches are maintained. Confirm the supported method scope and stale-value semantics with maintainers, then add coverage for the agreed behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.