npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

memory-decay

v0.0.3

Published

# Background In many applications it seems like a useful capability to have datafields of an object automatically deleted after some time.

Downloads

5

Readme

memory-decay

Background

In many applications it seems like a useful capability to have datafields of an object automatically deleted after some time.

E.g. authentication codes, which are valid for a limited time.

With this package you initialize the Object first, then whenever you want to have automatic deletion, call the obj.letForget("key") function.

Usage

Requirements

  • ESM importability

Installation

Current git version:

npm install git+https://github.com/JhonnyJason/memory-decay-output.git

Npm Registry:

npm install memory-decay

Current Functionality

  • Set a global default decay time.
  • Prepare an object such that it's datafields may be forgotten -> adds letForget function
  • Specify a specific datafield to be forgotten in the specified time letForget(key, timeMS) - timeMS is optional
  • If you call letForget again it will postpone the deletion to the new time.
setDefaultDecayMS = (decayTimeMS) ->
makeForgetable  = (object, decayTimeMS) -> object
# here decayTimeMS is optional - defaultDecayMS will be take if decayTimeMS is not specified
# the same object as provided is returned
# the object now has a new function attached
object.letForget = (key, decayTimeMSs) ->
# also here decayTimeMS is optional - either the Object specified or the global default is taken if decayTimeMS is not specified
import { makeForgetable } from "memory-decay"

## default default is 30000ms
volatileIdeaMemory = makeForgetable({})

volatileIdeaMemory.task1 = "think about task 2"
volatileIdeaMemory.letForget("task1") ## is forgotten in 30000ms

volatileIdeaMemory.task2 = "plan task 3"
volatileIdeaMemory.letForget("task1", 1000) ## is forgotten in 1000ms


longtermMemory = {}
makeForgetable(longtermMemory, 30000000000)
longtermMemory.secret = "super secret secret"
longtermMemory.letForget("secret") ## is forgotten in 347 days

Further steps

  • maybe make a proxy out of it so that the "letForget" is always implicitely triggered when set
  • figure out what to do next^^

All sorts of inputs are welcome, thanks!


License

Unlicense JhonnyJason style