Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

conbo-objectproxy

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

conbo-objectproxy - npm Package Compare versions

Comparing version 1.0.0 to 1.0.3

100

lib/conbo-objectproxy.js

@@ -18,63 +18,77 @@ (function(window, factory)

{
var s = {};
/**
* Pseudo-class to proxy objects, enabling them to be be used with
* Class used to proxy objects, enabling them to be be used with
* ConboJS two-way data binding as an alternative to a Hash
*
* @class ObjectUtils
* @author Neil Rackett
* @param {*} target - The object to proxy
* @param {boolean} [strict=false] - Prevent reading or creation of dynamic and private properties?
*/
function ObjectProxy(target, strict)
var ObjectProxy = conbo.EventDispatcher.extend(
/** @lends conbo.ObjectProxy.prototype */
{
var exists = function(name, obj)
__construct: function(t)
{
obj || (obj = target);
if (strict)
if (s !== t)
{
if (/^_/.test(name)) throw new Error('Property "'+name+'" on '+obj+' is private');
if (!(name in obj)) throw new Error('Property "'+name+'" does not exist on '+obj);
throw new Error('ObjectProxy cannot be called or instantiated directly: use ObjectProxt.create()');
}
return true;
};
var handler =
}
},
/** @lends conbo.ObjectProxy */
{
/**
* Wrap the specified object using an ObjectProxy
*
* @memberof ObjectProxy
* @method create
* @param {*} target - The object to proxy
* @param {boolean} [strict=false] - Prevent reading or creation of dynamic and private properties?
* @returns {ObjectProxy}
*/
create: function(target, strict)
{
get: (eventDispatcher, name) =>
var exists = function(name, obj)
{
if (name in eventDispatcher || /^__/.test(name))
obj || (obj = target);
if (strict)
{
return eventDispatcher[name];
if (/^_/.test(name)) throw new Error('Property "'+name+'" on '+obj+' is private');
if (!(name in obj)) throw new Error('Property "'+name+'" does not exist on '+obj);
}
if (exists(name))
{
return target[name];
}
},
set: (eventDispatcher, name, value) =>
return true;
};
var handler =
{
if (exists(name) && obj[name] !== value)
get: (eventDispatcher, name) =>
{
target[name] = value;
eventDispatcher.dispatchEvent(new conbo.ConboEvent(conbo.ConboEvent.CHANGE, {property:name, value:value}));
}
},
};
if (name in eventDispatcher || /^__/.test(name))
{
return eventDispatcher[name];
}
return new Proxy(new conbo.EventDispatcher(), handler);
}
if (exists(name))
{
return target[name];
}
},
set: (eventDispatcher, name, value) =>
{
if (exists(name) && obj[name] !== value)
{
target[name] = value;
eventDispatcher.dispatchEvent(new conbo.ConboEvent(conbo.ConboEvent.CHANGE, {property:name, value:value}));
}
},
};
/**
* Wraps the specified object using an ObjectProxy
*
* @memberof ObjectProxy
* @method create
* @param {*} target - The object to proxy
* @param {boolean} [strict=false] - Prevent reading or creation of dynamic and private properties?
*/
ObjectProxy.create = ObjectProxy;
return new Proxy(new ObjectProxy(s), handler);
}
});

@@ -81,0 +95,0 @@ return ObjectProxy;

{
"name": "conbo-objectproxy",
"version": "1.0.0",
"version": "1.0.3",
"description": "Bindable object proxy for ConboJS",

@@ -5,0 +5,0 @@ "main": "lib/conbo-objectproxy.js",

# ObjectProxy for ConboJS 4
`ObjectProxy` is an experimental pseudo-class for ConboJS that uses `Proxy` to wrap regular JavaScript objects to enable them to be be used with ConboJS two-way data binding, as an alternative to using a `Hash` or similar data model.
`ObjectProxy` is an experimental class for ConboJS that uses the ES2015 `Proxy` to wrap plain JavaScript objects to enable them to be be used with ConboJS two-way data binding, as an alternative to using a `Hash` or similar data model.
The `ObjectProxy` pseudo-class can be imported as an AMD, CommonJS or global module.
The `ObjectProxy` class can be imported as an AMD, CommonJS or global module.

@@ -11,12 +11,9 @@ ## Getting started

You can create a new `ObjectProxy` in one of 2 ways:
You can create a new `ObjectProxy` using the static `create` method:
```javascript
var obj = {a:0};
var proxy1 = ObjectProxy(obj);
var proxy2 = ObjectProxy.create(obj);
var obj = {a: 0};
var proxy = ObjectProxy.create(obj);
```
Both methods have the same outcome, but the second method seems a little cleaner until we work out how to create a version that can use `new ObjectProxy(obj)`.
## Strict proxies

@@ -23,0 +20,0 @@

@@ -1,2 +0,1 @@

export as namespace ObjectProxy;
export = ObjectProxy;

@@ -11,8 +10,4 @@

* @author Neil Rackett
* @param {any} target - The object to proxy
* @param {boolean} [strict=false] - Prevent reading or creation of dynamic and private properties?
*/
declare function ObjectProxy(target:any, strict?:boolean):any;
declare namespace ObjectProxy
declare class ObjectProxy extends conbo.EventDispatcher
{

@@ -22,8 +17,6 @@ /**

*
* @memberof ObjectProxy
* @method create
* @param {*} target - The object to proxy
* @param {any} target - The object to proxy
* @param {boolean} [strict=false] - Prevent reading or creation of dynamic and private properties?
*/
function create(target:any, strict?:boolean):any;
public static create(target:any, strict?:boolean):ObjectProxy;
}
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