Skip to content

method for get + del  #159

@KrishnaPG

Description

@KrishnaPG

For storing one-time reference items, such as OTP, it would be useful to have a method, say take, that would return the object and also delete it from the cache (so that any further get will result in undefined).

Something like below:

function take(key) {
  const val = this.get(key);
  if(val) this.delete(key);
  return val;
}

While this can be easily done at the app-level, for stronger semantics it would be nice to have in the API itself, if possible.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions