Skip to content

Commit

Permalink
Remove uses of for-of loops in RPC modules
Browse files Browse the repository at this point in the history
The React Native packager does not transform for-of loops, and minification step uses UglifyJS, which does not yet support ES6 syntax.

Fixes #120
  • Loading branch information
appden committed Nov 6, 2015
1 parent 54b94b6 commit 336ef55
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
3 changes: 3 additions & 0 deletions lib/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"browser": true,
"es6": true,
},
"ecmaFeatures": {
"forOf": false
},
"globals": {
"global": true
}
Expand Down
4 changes: 2 additions & 2 deletions lib/objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ function create(realmId, info) {
object[keys.id] = info.id;
object[keys.type] = info.type;

for (let prop of schema.properties) {
schema.properties.forEach((prop) => {
let name = prop.name;

props[name] = {
get: util.getterForProperty(name),
set: util.setterForProperty(name),
};
}
});

Object.defineProperties(object, props);

Expand Down
4 changes: 1 addition & 3 deletions lib/realm.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ class Realm {

rpc.commitTransaction(realmId);

for (let callback of this[listenersKey]) {
callback(this, 'change');
}
this[listenersKey].forEach((cb) => cb(this, 'change'));
}
}

Expand Down
8 changes: 3 additions & 5 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ function addMutationListener(realmId, callback) {
function fireMutationListeners(realmId) {
let listeners = mutationListeners[realmId];
if (listeners) {
for (let callback of listeners) {
callback();
}
listeners.forEach((cb) => cb());
}
}

Expand Down Expand Up @@ -97,11 +95,11 @@ function createList(prototype, realmId, info, mutable) {
function createMethods(prototype, type, methodNames, mutates) {
let props = {};

for (let name of methodNames) {
methodNames.forEach((name) => {
props[name] = {
value: createMethod(type, name, mutates),
};
}
});

Object.defineProperties(prototype, props);
}
Expand Down

0 comments on commit 336ef55

Please sign in to comment.