Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
@gnandretta/atom
Advanced tools
Manage and observe state changes in JavaScript, based on Clojure(Script) atoms.
var atom = require('atom');
var gabriel = atom({likes: "ice cream"});
gabriel.addWatch("logger", function(state) {
console.log(state);
});
gabriel.state // => {likes: "ice cream"}
gabriel.swap(function(state) {
return {likes: "cookies"};
});
// {likes: "cookies"} will be logged in the console
gabriel.state // => {likes: "cookies"}
I want a clear distinction between state and identity.
Creates a new atom with initial state
.
Returns the current state for the atom a
.
Sets the state of atom a
to state
.
Sets the state of atom a
to the result of applying the function f
to the current state, a.state
, and the provided args
.
function setLike(state, food) {
return Object.assign({}, state, {likes: food});
}
a.swap(setLike, "hamburguers");
a.state.likes // => "hamburguers"
Like reset
but it will pass the metadata meta
to the watches.
Like swap
but it will pass the metadata meta
to the watches.
Invoke the function f
every time the state of the atom a
is
updated. The key
parameter is a String that is used to identify
the watch and remove it later.
Every time the function f
is invoked, it will recieve the following
params:
state
: current state of the atom, after the update.oldState
: the previous state of the atom, before the update. It is
possible that state === oldState
if you don't update the atom's
state or if you update the state in place. The function f
is
called every time one of the update methods are called, there is no
guarantee that the state
has actually changed and that the changes
are preserved in oldState
. That is up to you.key
: the key provided when adding the watch.meta
: the metadata provided when performing the update with
mreset
or mswap
. If the update was done through reset
or
swap
this parameter will be undefined
.Stop invoking the function for the watch with the key
key.
FAQs
Atom like reference type to manage and observe state changes
The npm package @gnandretta/atom receives a total of 0 weekly downloads. As such, @gnandretta/atom popularity was classified as not popular.
We found that @gnandretta/atom 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
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.