New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

simple-bound

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-bound - npm Package Compare versions

Comparing version 0.0.3 to 0.1.0

15

dist/bound.cjs.js

@@ -271,4 +271,3 @@ 'use strict';

value: this,
enumerable: false,
writable: false
writable: true
});

@@ -289,3 +288,3 @@ if (BaseBound.config.debug && typeof proto !== 'object') {

BaseBound.prototype.bindAndMap = function (obj, mapToOriginal, twoWay) {
throw new BoundError('Method not implemented');
throw new BoundError('Method not implemented.');
};

@@ -355,2 +354,6 @@ Object.defineProperty(BaseBound, "config", {

if (path === void 0) { path = ''; }
Object.defineProperty(_obj, '__bound__', {
value: fromPath(_this.boundObject, path).__bound__,
writable: true
});
for (var key in fromPath(_this.storage, path)) {

@@ -369,3 +372,3 @@ var nextPath = !path ? key : path + "." + key;

__bind(obj, twoWay);
obj.__bound__ = this;
return this;
};

@@ -381,2 +384,3 @@ /**

if (path === void 0) { path = ''; }
_obj.__bound__ = undefined;
for (var key in fromPath(_this.storage, path)) {

@@ -390,6 +394,5 @@ var nextPath = !path ? key : path + "." + key;

else {
__unbind(nextValue, nextPath);
_obj[key] = __unbind(nextValue, nextPath);
}
}
delete _obj.__bound__;
return JSON.parse(JSON.stringify(_obj));

@@ -396,0 +399,0 @@ };

@@ -231,4 +231,3 @@ class BoundError extends Error {

value: this,
enumerable: false,
writable: false
writable: true
});

@@ -249,3 +248,3 @@ if (BaseBound.config.debug && typeof proto !== 'object') {

bindAndMap(obj, mapToOriginal, twoWay) {
throw new BoundError('Method not implemented');
throw new BoundError('Method not implemented.');
}

@@ -305,2 +304,6 @@ /**

const __bind = (_obj, _twoWay = true, path = '') => {
Object.defineProperty(_obj, '__bound__', {
value: fromPath(this.boundObject, path).__bound__,
writable: true
});
for (const key in fromPath(this.storage, path)) {

@@ -319,3 +322,3 @@ const nextPath = !path ? key : `${path}.${key}`;

__bind(obj, twoWay);
obj.__bound__ = this;
return this;
}

@@ -329,2 +332,3 @@ /**

const __unbind = (_obj, path = '') => {
_obj.__bound__ = undefined;
for (const key in fromPath(this.storage, path)) {

@@ -338,6 +342,5 @@ const nextPath = !path ? key : `${path}.${key}`;

else {
__unbind(nextValue, nextPath);
_obj[key] = __unbind(nextValue, nextPath);
}
}
delete _obj.__bound__;
return JSON.parse(JSON.stringify(_obj));

@@ -344,0 +347,0 @@ };

@@ -270,4 +270,3 @@ var bound = (function (exports) {

value: this,
enumerable: false,
writable: false
writable: true
});

@@ -288,3 +287,3 @@ if (BaseBound.config.debug && typeof proto !== 'object') {

BaseBound.prototype.bindAndMap = function (obj, mapToOriginal, twoWay) {
throw new BoundError('Method not implemented');
throw new BoundError('Method not implemented.');
};

@@ -354,2 +353,6 @@ Object.defineProperty(BaseBound, "config", {

if (path === void 0) { path = ''; }
Object.defineProperty(_obj, '__bound__', {
value: fromPath(_this.boundObject, path).__bound__,
writable: true
});
for (var key in fromPath(_this.storage, path)) {

@@ -368,3 +371,3 @@ var nextPath = !path ? key : path + "." + key;

__bind(obj, twoWay);
obj.__bound__ = this;
return this;
};

@@ -380,2 +383,3 @@ /**

if (path === void 0) { path = ''; }
_obj.__bound__ = undefined;
for (var key in fromPath(_this.storage, path)) {

@@ -389,6 +393,5 @@ var nextPath = !path ? key : path + "." + key;

else {
__unbind(nextValue, nextPath);
_obj[key] = __unbind(nextValue, nextPath);
}
}
delete _obj.__bound__;
return JSON.parse(JSON.stringify(_obj));

@@ -395,0 +398,0 @@ };

@@ -273,4 +273,3 @@ (function (global, factory) {

value: this,
enumerable: false,
writable: false
writable: true
});

@@ -291,3 +290,3 @@ if (BaseBound.config.debug && typeof proto !== 'object') {

BaseBound.prototype.bindAndMap = function (obj, mapToOriginal, twoWay) {
throw new BoundError('Method not implemented');
throw new BoundError('Method not implemented.');
};

@@ -357,2 +356,6 @@ Object.defineProperty(BaseBound, "config", {

if (path === void 0) { path = ''; }
Object.defineProperty(_obj, '__bound__', {
value: fromPath(_this.boundObject, path).__bound__,
writable: true
});
for (var key in fromPath(_this.storage, path)) {

@@ -371,3 +374,3 @@ var nextPath = !path ? key : path + "." + key;

__bind(obj, twoWay);
obj.__bound__ = this;
return this;
};

@@ -383,2 +386,3 @@ /**

if (path === void 0) { path = ''; }
_obj.__bound__ = undefined;
for (var key in fromPath(_this.storage, path)) {

@@ -392,6 +396,5 @@ var nextPath = !path ? key : path + "." + key;

else {
__unbind(nextValue, nextPath);
_obj[key] = __unbind(nextValue, nextPath);
}
}
delete _obj.__bound__;
return JSON.parse(JSON.stringify(_obj));

@@ -398,0 +401,0 @@ };

@@ -26,4 +26,3 @@ "use strict";

value: this,
enumerable: false,
writable: false
writable: true
});

@@ -44,3 +43,3 @@ if (BaseBound.config.debug && typeof proto !== 'object') {

bindAndMap(obj, mapToOriginal, twoWay) {
throw new boundError_1.default('Method not implemented');
throw new boundError_1.default('Method not implemented.');
}

@@ -47,0 +46,0 @@ /**

10

dist/lib/bound/bound.js

@@ -45,2 +45,6 @@ "use strict";

const __bind = (_obj, _twoWay = true, path = '') => {
Object.defineProperty(_obj, '__bound__', {
value: util_1.fromPath(this.boundObject, path).__bound__,
writable: true
});
for (const key in util_1.fromPath(this.storage, path)) {

@@ -59,3 +63,3 @@ const nextPath = !path ? key : `${path}.${key}`;

__bind(obj, twoWay);
obj.__bound__ = this;
return this;
}

@@ -69,2 +73,3 @@ /**

const __unbind = (_obj, path = '') => {
_obj.__bound__ = undefined;
for (const key in util_1.fromPath(this.storage, path)) {

@@ -78,6 +83,5 @@ const nextPath = !path ? key : `${path}.${key}`;

else {
__unbind(nextValue, nextPath);
_obj[key] = __unbind(nextValue, nextPath);
}
}
delete _obj.__bound__;
return JSON.parse(JSON.stringify(_obj));

@@ -84,0 +88,0 @@ };

@@ -56,3 +56,3 @@ import Binding, { IBindingPlugin } from '../binding';

*/
abstract bind<U extends T>(obj: U, twoWay?: boolean): any;
abstract bind<U extends T>(obj: U, twoWay?: boolean): this;
/**

@@ -64,3 +64,3 @@ * [NOT_IMPLEMENTED] Maps the object of a different shape to the original binding object

*/
bindAndMap<U>(obj: U, mapToOriginal: BindObjectMap<T>, twoWay?: boolean): void;
bindAndMap<U>(obj: U, mapToOriginal: BindObjectMap<T>, twoWay?: boolean): this;
/**

@@ -71,3 +71,3 @@ * Unbinds an object and destroys all of its listeners

*/
abstract unbind<U extends T>(obj: U): any;
abstract unbind<U extends T>(obj: U): U;
/**

@@ -74,0 +74,0 @@ * Global binding config. Changes affect all instances.

@@ -26,3 +26,3 @@ import Binding from '../binding';

* @param [twoWay] whether the binding should be two-way
*/ bind<U extends T>(obj: U, twoWay?: boolean): void;
*/ bind<U extends T>(obj: U, twoWay?: boolean): this;
/**

@@ -29,0 +29,0 @@ * Unbinds an object and destroys all of its listeners

@@ -8,4 +8,4 @@ import BaseBound, { IBoundPluginMap } from './base';

constructor(obj: T, plugins?: IBoundPluginMap<T>);
bind<U extends T>(obj: U, twoWay?: boolean): void;
unbind<U extends T>(obj: U): void;
bind<U extends T>(obj: U, twoWay?: boolean): this;
unbind<U extends T>(obj: U): U;
}
{
"name": "simple-bound",
"version": "0.0.3",
"version": "0.1.0",
"description": "A simple and customizable reactive data-binding library.",

@@ -112,5 +112,5 @@ "keywords": [

"ts-node": "^6.0.0",
"tslint": "^5.8.0",
"tslint": "^5.11.0",
"typescript": "^3.0.1"
}
}

@@ -202,2 +202,6 @@ # simple-bound

API can seem a bit tricky at first, because the concept of data-binding does not imply any uniformal way of doing it.
We recommend checking out an [interactive playground at RunKit](https://npm.runkit.com/simple-bound) for better intuitive understanding of how things work.
### TLDR

@@ -275,2 +279,4 @@

---
### Binding

@@ -287,3 +293,3 @@ > Stores and updates single property bindings.

#### Binding Constructor
#### Binding constructor
```js

@@ -298,3 +304,3 @@ new Binding(/* is always two-way */ false, /* default initial value */ 'value')

#### Binding Instance
#### Binding instance
```js

@@ -392,7 +398,64 @@ const instance = new Binding(false, 'value');

---
### Bound
> Allows multiple full-object bindings.
Stores bindings and binds objects together, providing the highest possible abstraction level for bindings.
#### Bound constructor
```js
new Bound({ property: 'value' })
```
Creates an instance of Bound using a proto object.
#### Bound instance
```js
const bound = new Binding({ property: 'value' });
```
##### Bound properties
> ```ts
> bound.storage: IBindingStorage
> ```
> Stores bindings in a structure that is identical to the binding-prototype-object.
> ```js
> bound.boundObject
> ```
> A bound object created from a constuctor's snapshot object.
> Contains an instance of the Bound class itself by the `__bound__` key.
##### Bound methods
> ```js
> bound.bind(obj, /* two-way? */ true)
> ```
> Binds an object to all other current subscribers.
> If the second argument is false
> ```js
> bound.unbind(/* object reference */ obj)
> ```
> Unbinds an object and destroys all of its listeners
##### Bound static fields
> ```js
> Bound.config === {
> debug: false
> }
> ```
> Global binding config. Changes affect all instances.
> ```js
> Bound.isBound(/* object reference */ obj)
> ```
> Checks whether an object has already been bound.
---
## Coming Soon
- Full documentation
- Plugins
- Event listeners
- Interceptors and pipes (maybe?)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc