You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP

ember-buffered-proxy

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-buffered-proxy - npm Package Compare versions

Comparing version

to
0.3.0

import Ember from 'ember';
import {aliasMethod, empty} from './helpers';
var hasOwnProp = Object.prototype.hasOwnProperty;
var get = Ember.get;
var set = Ember.set;
var keys = Ember.keys;
var isArray = Ember.isArray;
var computed = Ember.computed;
var get = Ember.get;
var set = Ember.set;
var keys = Ember.keys;
var isArray = Ember.isArray;
var computed = Ember.computed;
function aliasMethod(methodName) {
return function() {
return this[methodName].apply(this, arguments);
};
}
export default Ember.Mixin.create({
function empty(obj) {
var key;
for (key in obj) {
if (!hasOwnProp.call(obj, key)) { continue; }
return false;
}
return true;
}
hasChanges : computed.readOnly('hasBufferedChanges'),
applyChanges : aliasMethod('applyBufferedChanges'),
discardChanges : aliasMethod('discardBufferedChanges'),
export default Ember.Mixin.create({
init: function() {
this.initializeBuffer();
this.hasBufferedChanges = false;
this._super.apply(this, arguments);
},
hasChanges: computed.readOnly('hasBufferedChanges'),
initializeBuffer: function(onlyTheseKeys) {

@@ -55,5 +44,6 @@ if(isArray(onlyTheseKeys) && !empty(onlyTheseKeys)) {

setUnknownProperty: function(key, value) {
var buffer = this.buffer;
var buffer = this.buffer;
var content = this.get('content');
var current;
var previous;

@@ -64,3 +54,3 @@ if (content != null) {

var previous = buffer.hasOwnProperty(key) ? buffer[key] : current;
previous = buffer.hasOwnProperty(key) ? buffer[key] : current;

@@ -89,3 +79,3 @@ if (previous === value) {

applyBufferedChanges: function(onlyTheseKeys) {
var buffer = this.buffer;
var buffer = this.buffer;
var content = this.get('content');

@@ -108,4 +98,2 @@

applyChanges: aliasMethod('applyBufferedChanges'),
discardBufferedChanges: function(onlyTheseKeys) {

@@ -128,5 +116,3 @@ var buffer = this.buffer;

}
},
discardChanges: aliasMethod('discardBufferedChanges'),
}
});
{
"name": "ember-buffered-proxy",
"description": "An Ember Object Proxy with change buffering",
"version": "0.2.3",
"version": "0.3.0",
"directories": {

@@ -6,0 +6,0 @@ "doc": "doc",

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

import Ember from 'ember';
import Mixin from 'ember-buffered-proxy/mixin';
import Ember from 'ember';
module("ember-buffered-proxy/mixin");
module('ember-buffered-proxy/mixin');
test("exists", function() {
test('exists', function() {
ok(Mixin);
});
test("that it works", function() {
test('that it works', function() {
var BufferedPorxy = Ember.ObjectProxy.extend(Mixin);

@@ -64,3 +64,3 @@

test("that apply/discard only these keys works", function() {
test('that apply/discard only these keys works', function() {
var BufferedPorxy = Ember.ObjectProxy.extend(Mixin);

@@ -161,3 +161,3 @@

test("aliased methods work", function() {
test('aliased methods work', function() {
var BufferedProxy = Ember.ObjectProxy.extend(Mixin);

@@ -170,12 +170,12 @@

proxy.set('property', 2);
ok(proxy.get('hasChanges'), "Modified proxy has changes");
ok(proxy.get('hasChanges'), 'Modified proxy has changes');
proxy.applyChanges();
equal(proxy.get('content.property'), 2, "Applying changes sets the content's property");
ok(!(proxy.get('hasChanges')), "Proxy has no changes after changes are applied");
equal(proxy.get('content.property'), 2, 'Applying changes sets the content\'s property');
ok(!(proxy.get('hasChanges')), 'Proxy has no changes after changes are applied');
proxy.set('baz', 3);
proxy.discardChanges();
equal(proxy.get('property'), 2, "Discarding changes resets the proxy's property");
ok(!(proxy.get('hasChanges')), "Proxy has no changes after changes are discarded");
equal(proxy.get('property'), 2, 'Discarding changes resets the proxy\'s property');
ok(!(proxy.get('hasChanges')), 'Proxy has no changes after changes are discarded');
});

@@ -5,10 +5,10 @@ import Ember from 'ember';

module("ember-buffered-proxy/mixin");
module('ember-buffered-proxy/mixin');
test("exists", function() {
test('exists', function() {
ok(BufferedProxy);
});
test("that appears correct", function() {
ok(BufferedMixin.detect( BufferedProxy.create()));
test('that appears correct', function() {
ok(BufferedMixin.detect(BufferedProxy.create()));
});