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

mvcobject

Package Overview
Dependencies
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mvcobject - npm Package Compare versions

Comparing version 0.2.0 to 0.5.0

6

bower.json
{
"name": "mvcobject",
"main": "MVCObject.js",
"version": "0.2.0",
"homepage": "https://github.com/Jeremial/MVCObject",
"version": "0.5.0",
"homepage": "https://github.com/Treri/MVCObject",
"authors": [
"Jeremial <jeremial90@gmail.com>"
"Treri <treri.liu@gmail.com>"
],

@@ -9,0 +9,0 @@ "description": "An implementation of Google Maps' MVCObject for Node.js and browers",

@@ -12,3 +12,3 @@ // Generated by CoffeeScript 1.9.1

MVCObject = (function() {
var capitalize, getGetterName, getSetterName, getUid, getterNameCache, setterNameCache, triggerChange, uid;
var accessors, bindings, capitalize, getGetterName, getSetterName, getUid, getterNameCache, setterNameCache, toKey, triggerChange, uid;

@@ -68,3 +68,11 @@ function MVCObject() {}

toKey = function(key) {
return "_" + key;
};
bindings = "__bindings__";
accessors = "__accessors__";
/**

@@ -97,5 +105,5 @@ * @description 这个函数的触发需要时机

}
target.__bindings__ || (target.__bindings__ = {});
(base = target.__bindings__)[targetKey] || (base[targetKey] = {});
ref = target.__bindings__[targetKey];
target[bindings] || (target[bindings] = {});
(base = target[bindings])[targetKey] || (base[targetKey] = {});
ref = target[bindings][targetKey];
results = [];

@@ -119,5 +127,5 @@ for (bindingUid in ref) {

var accessor, getterName, target, targetKey, value;
this.__accessors__ || (this.__accessors__ = {});
if (this.__accessors__.hasOwnProperty(key)) {
accessor = this.__accessors__[key];
this[accessors] || (this[accessors] = {});
if (this[accessors].hasOwnProperty(key)) {
accessor = this[accessors][key];
targetKey = accessor.targetKey;

@@ -134,4 +142,4 @@ target = accessor.target;

}
} else if (this.hasOwnProperty(key)) {
value = this[key];
} else if (this.hasOwnProperty(toKey(key))) {
value = this[toKey(key)];
}

@@ -152,5 +160,5 @@ return value;

var accessor, setterName, target, targetKey;
this.__accessors__ || (this.__accessors__ = {});
if (this.__accessors__.hasOwnProperty(key)) {
accessor = this.__accessors__[key];
this[accessors] || (this[accessors] = {});
if (this[accessors].hasOwnProperty(key)) {
accessor = this[accessors][key];
targetKey = accessor.targetKey;

@@ -163,10 +171,11 @@ target = accessor.target;

if (target[setterName]) {
return target[setterName](value);
target[setterName](value);
} else {
return target.set(targetKey, value);
target.set(targetKey, value);
}
} else {
this[key] = value;
return triggerChange(this, key);
this[toKey(key)] = value;
triggerChange(this, key);
}
return this;
};

@@ -190,16 +199,16 @@

var accessor, target, targetKey;
this.__accessors__ || (this.__accessors__ = {});
if (this.__accessors__.hasOwnProperty(key)) {
accessor = this.__accessors__[key];
this[accessors] || (this[accessors] = {});
if (this[accessors].hasOwnProperty(key)) {
accessor = this[accessors][key];
targetKey = accessor.targetKey;
target = accessor.target;
return target.notify(targetKey);
target.notify(targetKey);
} else {
return triggerChange(this, key);
triggerChange(this, key);
}
return this;
};
MVCObject.prototype.setValues = function(values) {
var key, results, setterName, value;
results = [];
var key, setterName, value;
for (key in values) {

@@ -210,8 +219,8 @@ if (!hasProp.call(values, key)) continue;

if (this[setterName]) {
results.push(this[setterName](value));
this[setterName](value);
} else {
results.push(this.set(key, value));
this.set(key, value);
}
}
return results;
return this;
};

@@ -232,9 +241,9 @@

this.unbind(key);
this.__accessors__ || (this.__accessors__ = {});
target.__bindings__ || (target.__bindings__ = {});
(base = target.__bindings__)[targetKey] || (base[targetKey] = {});
this[accessors] || (this[accessors] = {});
target[bindings] || (target[bindings] = {});
(base = target[bindings])[targetKey] || (base[targetKey] = {});
binding = new Accessor(this, key);
accessor = new Accessor(target, targetKey);
this.__accessors__[key] = accessor;
target.__bindings__[targetKey][getUid(this)] = binding;
this[accessors][key] = accessor;
target[bindings][targetKey][getUid(this)] = binding;
if (!noNotify) {

@@ -255,23 +264,23 @@ triggerChange(this, key);

var accessor, target, targetKey;
this.__accessors__ || (this.__accessors__ = {});
accessor = this.__accessors__[key];
this[accessors] || (this[accessors] = {});
accessor = this[accessors][key];
if (accessor) {
target = accessor.target;
targetKey = accessor.targetKey;
this[key] = this.get(key);
delete target.__bindings__[targetKey][getUid(this)];
return delete this.__accessors__[key];
this[toKey(key)] = this.get(key);
delete target[bindings][targetKey][getUid(this)];
delete this[accessors][key];
}
return this;
};
MVCObject.prototype.unbindAll = function() {
var key, ref, results;
this.__accessors__ || (this.__accessors__ = {});
ref = this.__accessors__;
results = [];
var key, ref;
this[accessors] || (this[accessors] = {});
ref = this[accessors];
for (key in ref) {
if (!hasProp.call(ref, key)) continue;
results.push(this.unbind(key));
this.unbind(key);
}
return results;
return this;
};

@@ -278,0 +287,0 @@

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

(function(){var t,s,_={}.hasOwnProperty;s=function(){function s(){}var e,n,r,i,o,c,a,h;return o={},c={},h=0,n=function(t){return o.hasOwnProperty(t)?o[t]:o[t]="get"+e(t)},r=function(t){return c.hasOwnProperty(t)?c[t]:c[t]="set"+e(t)},e=function(t){return t.substr(0,1).toUpperCase()+t.substr(1)},i=function(t){return t.__uid__||(t.__uid__=++h)},a=function(t,s){var e,n,r,i,o,c;i=s+"_changed",t[i]?t[i]():"function"==typeof t.changed&&t.changed(s),t.__bindings__||(t.__bindings__={}),(e=t.__bindings__)[s]||(e[s]={}),o=t.__bindings__[s],c=[];for(r in o)_.call(o,r)&&(n=o[r],c.push(a(n.target,n.targetKey)));return c},s.prototype.get=function(t){var s,_,e,r,i;return this.__accessors__||(this.__accessors__={}),this.__accessors__.hasOwnProperty(t)?(s=this.__accessors__[t],r=s.targetKey,e=s.target,_=n(r),i=e[_]?e[_]():e.get(r),s.to&&(i=s.to(i))):this.hasOwnProperty(t)&&(i=this[t]),i},s.prototype.set=function(t,s){var _,e,n,i;return this.__accessors__||(this.__accessors__={}),this.__accessors__.hasOwnProperty(t)?(_=this.__accessors__[t],i=_.targetKey,n=_.target,e=r(i),_.from&&(s=_.from(s)),n[e]?n[e](s):n.set(i,s)):(this[t]=s,a(this,t))},s.prototype.changed=function(){},s.prototype.notify=function(t){var s,_,e;return this.__accessors__||(this.__accessors__={}),this.__accessors__.hasOwnProperty(t)?(s=this.__accessors__[t],e=s.targetKey,_=s.target,_.notify(e)):a(this,t)},s.prototype.setValues=function(t){var s,e,n,i;e=[];for(s in t)_.call(t,s)&&(i=t[s],n=r(s),e.push(this[n]?this[n](i):this.set(s,i)));return e},s.prototype.bindTo=function(s,_,e,n){var r,o,c;return e||(e=s),this.unbind(s),this.__accessors__||(this.__accessors__={}),_.__bindings__||(_.__bindings__={}),(o=_.__bindings__)[e]||(o[e]={}),c=new t(this,s),r=new t(_,e),this.__accessors__[s]=r,_.__bindings__[e][i(this)]=c,n||a(this,s),r},s.prototype.unbind=function(t){var s,_,e;return this.__accessors__||(this.__accessors__={}),s=this.__accessors__[t],s?(_=s.target,e=s.targetKey,this[t]=this.get(t),delete _.__bindings__[e][i(this)],delete this.__accessors__[t]):void 0},s.prototype.unbindAll=function(){var t,s,e;this.__accessors__||(this.__accessors__={}),s=this.__accessors__,e=[];for(t in s)_.call(s,t)&&e.push(this.unbind(t));return e},s}(),t=function(){function t(t,s){this.target=t,this.targetKey=s}return t.prototype.transform=function(t,s){return this.from=t,this.to=s,this.target.notify(this.targetKey)},t}(),"undefined"!=typeof module&&null!==module?module.exports=s:"function"==typeof define?define(function(){return s}):window.MVCObject=s}).call(this);
(function(){var t,n,r={}.hasOwnProperty;n=function(){function n(){}var e,i,s,o,h,u,a,f,c,p,y;return a={},f={},y=0,o=function(t){return a.hasOwnProperty(t)?a[t]:a[t]="get"+s(t)},h=function(t){return f.hasOwnProperty(t)?f[t]:f[t]="set"+s(t)},s=function(t){return t.substr(0,1).toUpperCase()+t.substr(1)},u=function(t){return t.__uid__||(t.__uid__=++y)},c=function(t){return"_"+t},i="__bindings__",e="__accessors__",p=function(t,n){var e,s,o,h,u,a;h=n+"_changed",t[h]?t[h]():"function"==typeof t.changed&&t.changed(n),t[i]||(t[i]={}),(e=t[i])[n]||(e[n]={}),u=t[i][n],a=[];for(o in u)r.call(u,o)&&(s=u[o],a.push(p(s.target,s.targetKey)));return a},n.prototype.get=function(t){var n,r,i,s,h;return this[e]||(this[e]={}),this[e].hasOwnProperty(t)?(n=this[e][t],s=n.targetKey,i=n.target,r=o(s),h=i[r]?i[r]():i.get(s),n.to&&(h=n.to(h))):this.hasOwnProperty(c(t))&&(h=this[c(t)]),h},n.prototype.set=function(t,n){var r,i,s,o;return this[e]||(this[e]={}),this[e].hasOwnProperty(t)?(r=this[e][t],o=r.targetKey,s=r.target,i=h(o),r.from&&(n=r.from(n)),s[i]?s[i](n):s.set(o,n)):(this[c(t)]=n,p(this,t)),this},n.prototype.changed=function(){},n.prototype.notify=function(t){var n,r,i;return this[e]||(this[e]={}),this[e].hasOwnProperty(t)?(n=this[e][t],i=n.targetKey,r=n.target,r.notify(i)):p(this,t),this},n.prototype.setValues=function(t){var n,e,i;for(n in t)r.call(t,n)&&(i=t[n],e=h(n),this[e]?this[e](i):this.set(n,i));return this},n.prototype.bindTo=function(n,r,s,o){var h,a,f;return s||(s=n),this.unbind(n),this[e]||(this[e]={}),r[i]||(r[i]={}),(a=r[i])[s]||(a[s]={}),f=new t(this,n),h=new t(r,s),this[e][n]=h,r[i][s][u(this)]=f,o||p(this,n),h},n.prototype.unbind=function(t){var n,r,s;return this[e]||(this[e]={}),n=this[e][t],n&&(r=n.target,s=n.targetKey,this[c(t)]=this.get(t),delete r[i][s][u(this)],delete this[e][t]),this},n.prototype.unbindAll=function(){var t,n;this[e]||(this[e]={}),n=this[e];for(t in n)r.call(n,t)&&this.unbind(t);return this},n}(),t=function(){function t(t,n){this.target=t,this.targetKey=n}return t.prototype.transform=function(t,n){return this.from=t,this.to=n,this.target.notify(this.targetKey)},t}(),"undefined"!=typeof module&&null!==module?module.exports=n:"function"==typeof define?define(function(){return n}):window.MVCObject=n}).call(this);
{
"name": "mvcobject",
"version": "0.2.0",
"version": "0.5.0",
"description": "An implementation of Google Maps' MVCObject for Node.js and browers",

@@ -5,0 +5,0 @@ "main": "MVCObject.js",

@@ -13,10 +13,10 @@ ## MVCObject [![NPM version](https://badge.fury.io/js/mvcobject.png)](http://badge.fury.io/js/mvcobject) [![Build Status](https://travis-ci.org/Treri/MVCObject.png)](https://travis-ci.org/Treri/MVCObject) [![Dependencies Status](https://david-dm.org/Treri/MVCObject.png)](https://david-dm.org/Treri/MVCObject)

----- | ----- | -----
bindTo(key:string, target:MVCObject, targetKey?:string, noNotify?:boolean) | None | Binds a View to a Model.
changed(key:string) | None | Generic handler for state changes. Override this in derived classes to handle arbitrary state changes.
bindTo(key:string, target:MVCObject, targetKey?:string, noNotify?:boolean) | accessor | Binds a View to a Model.
changed(key:string) | ? | Generic handler for state changes. Override this in derived classes to handle arbitrary state changes.
get(key:string) | * | Gets a value.
notify(key:string) | None | Notify all observers of a change on this property. This notifies both objects that are bound to the object's property as well as the object that it is bound to.
set(key:string, value:*) | None | Sets a value.
setValues(values:Object) | None | Sets a collection of key-value pairs.
unbind(key:string) | None | Removes a binding. Unbinding will set the unbound property to the current value. The object will not be notified, as the value has not changed.
unbindAll() | None | Removes all bindings.
notify(key:string) | this | Notify all observers of a change on this property. This notifies both objects that are bound to the object's property as well as the object that it is bound to.
set(key:string, value:*) | this | Sets a value.
setValues(values:Object) | this | Sets a collection of key-value pairs.
unbind(key:string) | this | Removes a binding. Unbinding will set the unbound property to the current value. The object will not be notified, as the value has not changed.
unbindAll() | this | Removes all bindings.

@@ -65,3 +65,3 @@ ### Usage

Copyright (c) 2013 Treri treri.liu@gmail.com
Copyright (c) 2013-2015 Treri treri.liu@gmail.com

@@ -68,0 +68,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

"use strict";
require('coffee-script').register();
global.chai = require('chai');

@@ -4,0 +3,0 @@ global.sinon = require('sinon');

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