Permalink
Browse files

The wonderful "white" hint

  • Loading branch information...
1 parent a95c18f commit f4a5da1c6d4c1de47dd6940b8670a6c84957a81d @kriszyp kriszyp committed Feb 8, 2014
View
@@ -5,36 +5,36 @@ define([
'dojo/_base/declare',
'./Store',
'./Memory'
-], function(lang, arrayUtil, when, declare, Store, Memory){
+], function (lang, arrayUtil, when, declare, Store, Memory) {
// module:
// dstore/Cache
return declare(Store, {
cachingStore: null,
constructor: function (options) {
- for(var i in options){
+ for (var i in options) {
// mixin the options
this[i] = options[i];
}
- if(!this.cachingStore){
+ if (!this.cachingStore) {
this.cachingStore = new Memory();
}
this._collectionCache = {};
},
_tryCacheForResults: function (method, serialized, args) {
var cachingStore = this.cachingStore;
- if(this.allLoaded && this.hasOwnProperty('cachingStore')){
+ if (this.allLoaded && this.hasOwnProperty('cachingStore')) {
// if we have loaded everything, we can go to the caching store
// for quick client side querying
var subCachingStore = new Memory();
// wait for it to finish loading
var data = when(when(this.allLoaded, function () {
return cachingStore[method].apply(cachingStore, args);
- }), function(results){
+ }), function (results) {
// now process the results to populate sub caching store
var data = results.data;
- for(var i = 0; i < data.length; i++){
+ for (var i = 0; i < data.length; i++) {
subCachingStore.put(data[i]);
}
return data;
@@ -50,25 +50,25 @@ define([
if (cacheable) {
// we use a key to see if we already have a sub-collection
serialized = method + ':' + serialized;
- if(this._collectionCache[serialized]){
+ if (this._collectionCache[serialized]) {
return this._collectionCache[serialized];
}
}
// nothing in the cache, have to use the inherited method to perform the action
var results = this.inherited(args);
- if(cacheable){
+ if (cacheable) {
this._collectionCache[serialized] = results;
}
// give the results it's own collection cache and caching store
results._collectionCache = {};
if (results.data) {
var store = this;
- when(results.allLoaded = results.data, function(data){
+ when(results.allLoaded = results.data, function (data) {
results.cachingStore = new Memory({data: data});
- for(var i = 0, l = data.length; i < l; i++){
+ for (var i = 0, l = data.length; i < l; i++) {
var object = data[i];
- if(!store.isLoaded || store.isLoaded(object)){
+ if (!store.isLoaded || store.isLoaded(object)) {
cachingStore.put(object);
}
}
@@ -93,15 +93,15 @@ define([
var store = this;
if (this.allLoaded) {
// everything has been loaded, use the caching store
- return when(this.allLoaded, function(){
+ return when(this.allLoaded, function () {
return store.cachingStore.fetch();
});
}
/* jshint boss: true */
- return this.allLoaded = when(this.inherited(arguments), function(results){
- arrayUtil.forEach(results, function(object){
+ return this.allLoaded = when(this.inherited(arguments), function (results) {
+ arrayUtil.forEach(results, function (object) {
// store each object before calling the callback
- if(!store.isLoaded || store.isLoaded(object)){
+ if (!store.isLoaded || store.isLoaded(object)) {
cachingStore.put(object);
}
});
@@ -118,10 +118,10 @@ define([
var masterGet = this.getInherited(arguments);
var masterStore = this;
// if everything is being loaded, we always wait for that to finish
- return when(this.allLoaded, function(){
- return when(cachingStore.get(id), function(result){
- return result || when(masterGet.call(masterStore, id, directives), function(result){
- if(result){
+ return when(this.allLoaded, function () {
+ return when(cachingStore.get(id), function (result) {
+ return result || when(masterGet.call(masterStore, id, directives), function (result) {
+ if (result) {
cachingStore.put(result, {id: id});
}
return result;
@@ -131,7 +131,7 @@ define([
},
add: function (object, directives) {
var cachingStore = this.cachingStore;
- return when(this.inherited(arguments), function(result){
+ return when(this.inherited(arguments), function (result) {
// now put result in cache (note we don't do add, because add may have
// called put() and already added it)
cachingStore.put(object && typeof result === 'object' ? result : object, directives);
@@ -143,7 +143,7 @@ define([
// first remove from the cache, so it is empty until we get a response from the master store
var cachingStore = this.cachingStore;
cachingStore.remove((directives && directives.id) || this.getIdentity(object));
- return when(this.inherited(arguments), function(result){
+ return when(this.inherited(arguments), function (result) {
// now put result in cache
cachingStore.put(object && typeof result === 'object' ? result : object, directives);
// the result from the put should be dictated by the master store and be unaffected by the cachingStore
View
@@ -62,7 +62,7 @@ define([
this._parent.property(dependsOn[i]).observe(changeListener, true));
}
return {
- remove: function() {
+ remove: function () {
for (var i = 0; i < dependsOn.length; i++) {
handles[i].remove();
}
View
8 Csv.js
@@ -1,7 +1,7 @@
define([
'dojo/_base/lang',
'dojo/_base/declare'
-], function(lang, declare) {
+], function (lang, declare) {
// originally from https://github.com/kfranqueiro/dojo-smore/blob/master/Csv.js
var quoteRx = /^\s*"([\S\s]*)"\s*$/,
doubleQuoteRx = /""/g,
@@ -43,7 +43,7 @@ define([
// If true, leading/trailing space will be trimmed from any unquoted values.
trim: false,
- parse: function(str) {
+ parse: function (str) {
// summary:
// Populates the store based on a CSV-formatted string.
// str: String
@@ -131,12 +131,12 @@ define([
// The data is assembled; return
return data;
},
- toCsv: function(options){
+ toCsv: function (options) {
// summary:
// Returns data from Memory store, re-exported to CSV format.
return this.stringify(this.data, options);
},
- stringify: function(data, options) {
+ stringify: function (data, options) {
// summary:
// Serializes data as CSV
// options: Object?
View
@@ -1,5 +1,5 @@
define(['dojo/_base/declare', 'dojo/_base/lang', 'dojo/_base/array', './SimpleQuery' /*=====, './api/Store' =====*/],
- function(declare, lang, arrayUtil, SimpleQuery /*=====, Store =====*/){
+ function (declare, lang, arrayUtil, SimpleQuery /*=====, Store =====*/) {
// module:
// dstore/Memory
View
@@ -6,7 +6,7 @@ define([
'dojo/when'
], function (declare, lang, Deferred, aspect, when) {
- function getSchemaProperty (object, key) {
+ function getSchemaProperty(object, key) {
// this function will retrieve the individual property definition
// from the schema, for the provided object and key
var definition = object.schema[key];
@@ -40,7 +40,7 @@ define([
}
if (property && property.validate) {
- return when(property.validate(), function(isValid) {
+ return when(property.validate(), function (isValid) {
if (!isValid) {
// errors, so don't perform set
if (!hasOwnPropertyInstance) {
@@ -74,7 +74,7 @@ define([
// make sure we have a deferred
deferred = new Deferred();
}
- value.then(function (value){
+ value.then(function (value) {
// result received, call callback, and then indicate another item is done
doneItem(callback(value, key));
}).then(null, deferred.reject);
@@ -159,7 +159,7 @@ define([
// suppress any non-date from serialization output
object.prepareForSerialization();
return object._store && when(object._store[scenario === 'insert' ? 'add' : 'put'](object),
- function(returned) {
+ function (returned) {
if (typeof returned === 'object') {
// receive any updates from the server
object.set(returned);
@@ -293,7 +293,7 @@ define([
// we can shortcut right to just setting the object property
this[key] = value;
// check to see if we should do validation
- if (definition && definition.validateOnSet !== false){
+ if (definition && definition.validateOnSet !== false) {
validate(this, key);
}
}
@@ -331,7 +331,7 @@ define([
// check to see if we are allowed to validate this key
if (!fieldMap || (fieldMap.hasOwnProperty(key))) {
// run validation
- whenItem(validate(object, key), function (isValid, key){
+ whenItem(validate(object, key), function (isValid, key) {
if (!isValid) {
notValid(key);
}
@@ -480,17 +480,17 @@ define([
if (hasOldObject || hasNewObject) {
// we will iterate through the properties recording the changes
var changes = {};
- if (hasOldObject){
+ if (hasOldObject) {
for (key in oldValue) {
changes[key] = {old: oldValue[key]};
}
}
- if (hasNewObject){
+ if (hasNewObject) {
for (key in value) {
(changes[key] = changes[key] || {}).value = value[key];
}
}
- for(key in changes){
+ for (key in changes) {
// now for each change, we can notify the property object
var change = changes[key];
property.set(key, change.value, change.old);
@@ -554,7 +554,7 @@ define([
errors.push(value + ' is not a ' + this.type);
}
- if(this.required && !(value != null && value !== '')) {
+ if (this.required && !(value != null && value !== '')) {
errors.push('required, and it was not present');
}
return errors;
@@ -599,11 +599,11 @@ define([
});
// a function that returns a function, to stop JSON serialization of an
// object
- function toJSONHidden () {
+ function toJSONHidden() {
return toJSONHidden;
}
// An object that will be hidden from JSON serialization
- var Hidden = function() {
+ var Hidden = function () {
};
Hidden.prototype.toJSON = toJSONHidden;
Oops, something went wrong.

0 comments on commit f4a5da1

Please sign in to comment.