Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
simple-bound
Advanced tools
A simple and customizable reactive binding framework for node and browser. Work in progress.
npm install --save simple-bound
For more options see installation
Many JavaScript libraries and frameworks use some form of data-binding under the hood. That binding usually comes in various shapes and sizes, all of which end up in the "vendor" part of your project. But currently there's no truly utilitary and versatile solution. So most of the time you want to use the power of, let's say, two-way binding in you own library or project - you have to code that part from scratch.
Bound
aims to change that.
Bound
is currently in the alpha state, there might be some a lot of bugs. Feel free to report them in the issues section. 🙂
npm install --save simple-bound
# or
yarn add simple-bound
ES
import Bound from 'simple-bound'
CommonJS
const Bound = require('simple-bound').default;
UNPKG
<script src="https://unpkg.com/simple-bound"></script>
<script>
window.Bound = bound.default;
</script>
Let's say you want to bind to objects together in a way that a change to one object would change the other. It's very simple to do with Bound
:
const obj1 = {
prop: 'foo'
};
const obj2 = {
prop: 'foo'
};
// Send the proto object to snapshot the structure.
const bound = new Bound(obj);
// Bind both objects via Bound instace:
bound.bind(obj1);
bound.bind(obj2);
obj1.prop = 'bar';
console.log(obj2.prop);
// -> "bar"
// Magic!
import Bound, {
bound,
Binding
} from 'simple-bound';
let obj = {
test: 'foo';
}
let obj2 = {
test: 'foo';
}
const justABoundObject = bound({
test: 'prop'
});
justABoundObject.__bound__ // Bound instance
justABoundObject.__bound__.bind(obj);
justABoundObject.test = 'bar';
console.log(obj.test); // -> "bar"
justABoundObject.__bound__.storage // { test: Binding {} }
justABoundObject.__bound__.boundObject // === justABoundObject
obj = justABoundObject.__bound__.unbind(obj); // obj is now free from bindings
// Binding class
const binding = new Binding(/* twoWay */ false, /* defaultValue */ '');
binding.addSubscriber(obj, 'test', 'master');
binding.addSubscriber(obj2, 'test', 'slave');
// Updates all subscribers
binding.set('test'); // obj.test === 'test' && obj2.test === 'test'
// Master: updates all subscribers
obj.test = 'foo'; // obj2.test === 'foo' && binding.get() === 'foo'
// Slave: updates only itself
obj2.test = 'bar'; // obj.test === 'foo' && binding.get() === 'foo'
// Master: updates all subscribers
obj.test = 'baz'; // obj2.test === 'baz' && binding.get() === 'baz'
binding.removeSubscriber(obj2); // By object reference
binding.removeSubscriber(0); // By index
binding.clearSubscribers();
FAQs
A simple and customizable reactive data-binding library.
We found that simple-bound demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.