
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
memo-switch
Advanced tools
A switch that memorizes state transition events.

npm install memo-switch
const MemoSwitch = require('memo-switch')
const memoSwitch = MemoSwitch.initialize()
console.log(memoSwitch.isActivated) // false
memoSwitch.toggle()
console.log(memoSwitch.isActivated) // true
// @flow
import MemoSwitch from 'memo-switch/jsnext'
This way, we can import the module and their type.
const memoSwitch = MemoSwitch.initialize()
const timestamp = new Date().getTime()
console.log(memoSwitch.isActivatedAt(timestamp)) // true
const minuteAgo = new Date().getTime() - 360000
console.log(memoSwitch.isActivatedAt(minuteAgo)) // false
Set default state to the 1st argument of MemoSwitch.initialize().
const memoSwitch = MemoSwitch.initialize(true)
console.log(memoSwitch.isActivated) // true
We can set time resolution of the events. Default resolution: MINUTE.
First, load the Resolutions constants.
const { Resolutions } = MemoSwitch
In ES modules,
import MemoSwitch, { Resolutions } from 'memo-switch'
Then, set at 2nd argument of MemoSwitch.initialize().
const memoSwitch = MemoSwitch.initialize(false, Resolutions.MILLISECOND)
Just stringify it.
const str = JSON.stringify(memoSwitch)
To restore, give the object to constructor.
const obj = JSON.parse(str)
const memoSwitch2 = new MemoSwitch(obj)
MIT
FAQs
A switch that memorizes state transition events.
We found that memo-switch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.