Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@thi.ng/atom
Advanced tools
Clojure inspired mutable wrappers for (usually) immutable values, with support for watches.
TODO
yarn add @thi.ng/atom
import * as atom from "@thi.ng/atom";
const a = new atom.Atom(23);
// obtain value via deref()
a.deref();
// 23
// add watch to observe value changes
a.addWatch("foo", (id, prev, curr) => console.log(`${id}: ${prev} -> ${curr}`));
// true
a.swap((val)=> val + 1);
// foo: 23 -> 24
a.reset(42);
// foo: 24 -> 42
// main state
main = new atom.Atom({ a: { b: { c: 23 }, d: { e: 42 } }, f: 66 });
// cursor to `c` value
cursor = new atom.Cursor(main, "a.b.c");
// or
cursor = new atom.Cursor(main, ["a","b","c"]);
// alternatively provide path implicitly via lookup & update functions
// both fns will be called with cursor's parent state
// this allows the cursor implementation to work with any data structure
// as long as the updater DOES NOT mutate in place
cursor = new atom.Cursor(
main,
(s) => s.a.b.c,
(s, x) => ({...s, a: {...s.a, b: {...s.a.b, c: x}}})
);
// add watch just as with Atom
cursor.addWatch("foo", console.log);
cursor.deref()
// 23
cursor.swap(x => x + 1);
// foo 23 24
main.deref()
// { a: 24, b: 42 }
© 2018 Karsten Schmidt // Apache Software License 2.0
FAQs
Mutable wrappers for nested immutable values with optional undo/redo history and transaction support
We found that @thi.ng/atom demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.