Permalink
Browse files

fix IE9 problems with Array methods on Arguments object

  • Loading branch information...
1 parent 9aa0558 commit 85c28cc41eb054b909b5041285569c7cef00e37c @konsultaner committed Mar 30, 2015
Showing with 59 additions and 35 deletions.
  1. +5 −0 README.MD
  2. +3 −1 bench/query-test.js
  3. +1 −1 bin/json.odm.min.js
  4. +23 −23 doc/bench/benchmark-results.json
  5. +8 −4 doc/jsonOdm/0.0/query.js.html
  6. +11 −2 src-test/util-test.js
  7. +8 −4 src/query.js
View
@@ -50,6 +50,11 @@ To execute the benchmark use command ```gulp bench``` after adding:
npm install --save-dev gulp-bench
```
+Browser Support
+---------------
+Unit test ran successfully under Chrome,iOS7+,IE9+,Firefox,Android 4.4.2+
+To be tested: Safari on OSX, IE8(test driver does not run in IE < 9 so it will be hard to test)
+
Example
------
This is only a basic example. Find more in the [docs](https://rawgit.com/konsultaner/jsonOdm/master/doc/jsonOdm/0.0/index.html), i.e. how to use [$geoWithin](https://rawgit.com/konsultaner/jsonOdm/master/doc/jsonOdm/0.0/jsonOdm.Query.html#$geoWithin)
View
@@ -37,7 +37,9 @@ module.exports = {
{
name: 'Simple text search within 500,000 Elements',
fn : function(){
- bigCollection.$query().$branch("profession").$text('"ish" mish fish -crab').$all();
+ var $q = bigCollection.$query();
+ $q.$branch("profession").$text('"ish" mish fish -crab').$all();
+ return;
}
}
]
View
Oops, something went wrong.
@@ -1,63 +1,63 @@
[
{
"name": "pointWithinPolygon: real live example for point in polygon with 756 edges",
- "timestamp": "Sat Mar 28 2015 13:01:52 GMT+0100 (Mitteleuropäische Zeit)",
- "count": 11803,
- "cycles": 4,
- "hz": 231150.48685201688,
+ "timestamp": "Mon Mar 30 2015 16:16:43 GMT+0200 (Mitteleuropäische Sommerzeit)",
+ "count": 11859,
+ "cycles": 5,
+ "hz": 227206.30920054598,
"suite": "Geo benchmarks"
},
{
"name": "pointWithinLineString: real live example for point on polygon line with 756 edges",
- "timestamp": "Sat Mar 28 2015 13:01:58 GMT+0100 (Mitteleuropäische Zeit)",
- "count": 30315,
+ "timestamp": "Mon Mar 30 2015 16:16:49 GMT+0200 (Mitteleuropäische Sommerzeit)",
+ "count": 30332,
"cycles": 4,
- "hz": 575714.5267999222,
+ "hz": 551198.9805362248,
"suite": "Geo benchmarks"
},
{
"name": "edgeIntersectsEdge: random edges",
- "timestamp": "Sat Mar 28 2015 13:02:03 GMT+0100 (Mitteleuropäische Zeit)",
- "count": 224094,
- "cycles": 4,
- "hz": 3150673.2939504143,
+ "timestamp": "Mon Mar 30 2015 16:16:54 GMT+0200 (Mitteleuropäische Sommerzeit)",
+ "count": 221526,
+ "cycles": 6,
+ "hz": 3036041.185034033,
"suite": "Geo benchmarks"
},
{
"name": "pointWithinPolygon: worst case point in worst case polygon with 2000 edges",
- "timestamp": "Sat Mar 28 2015 13:02:09 GMT+0100 (Mitteleuropäische Zeit)",
- "count": 471,
- "cycles": 6,
- "hz": 9202.760052746176,
+ "timestamp": "Mon Mar 30 2015 16:16:59 GMT+0200 (Mitteleuropäische Sommerzeit)",
+ "count": 468,
+ "cycles": 3,
+ "hz": 8999.416284493025,
"suite": "Geo benchmarks"
},
{
"name": "pointWithinLineString: worst case point on worst case polygon line with 2000 edges",
- "timestamp": "Sat Mar 28 2015 13:02:14 GMT+0100 (Mitteleuropäische Zeit)",
- "count": 1085338,
+ "timestamp": "Mon Mar 30 2015 16:17:05 GMT+0200 (Mitteleuropäische Sommerzeit)",
+ "count": 1071074,
"cycles": 5,
- "hz": 20429809.78979747,
+ "hz": 19524781.870863765,
"suite": "Geo benchmarks"
},
{
"name": "Simple Query all 500,000 Elements",
- "timestamp": "Sat Mar 28 2015 13:02:23 GMT+0100 (Mitteleuropäische Zeit)",
+ "timestamp": "Mon Mar 30 2015 16:17:14 GMT+0200 (Mitteleuropäische Sommerzeit)",
"count": 1,
"cycles": 1,
- "hz": 2.6392006937892396,
+ "hz": 2.545358738740628,
"suite": "Query benchmarks"
},
{
"name": "Complex Query all 500,000 Elements",
- "timestamp": "Sat Mar 28 2015 13:02:38 GMT+0100 (Mitteleuropäische Zeit)",
+ "timestamp": "Mon Mar 30 2015 16:17:30 GMT+0200 (Mitteleuropäische Sommerzeit)",
"count": 1,
"cycles": 1,
- "hz": 0.9184245912725004,
+ "hz": 0.8459475102413795,
"suite": "Query benchmarks"
},
{
"name": "Simple text search within 500,000 Elements",
- "timestamp": "Sat Mar 28 2015 13:02:38 GMT+0100 (Mitteleuropäische Zeit)",
+ "timestamp": "Mon Mar 30 2015 16:17:30 GMT+0200 (Mitteleuropäische Sommerzeit)",
"error": {},
"count": 0,
"cycles": 0,
@@ -905,7 +905,8 @@
*/
jsonOdm.Query.prototype.$eq = function (comparable) {
return this.$testCollection(arguments,function (collectionValue, possibleValues) {
- return Array.prototype.indexOf.call(possibleValues,collectionValue) > -1;
+ for(var i = 0; i &lt; possibleValues.length; i++) if(possibleValues[i] == collectionValue) return true;
+ return false;
});
};
@@ -917,7 +918,8 @@
*/
jsonOdm.Query.prototype.$in = function (comparable) {
return this.$testCollection(comparable,function (collectionValue, possibleValues) {
- return Array.prototype.indexOf.call(possibleValues,collectionValue) > -1;
+ for(var i = 0; i &lt; possibleValues.length; i++) if(possibleValues[i] == collectionValue) return true;
+ return false;
});
};
@@ -929,7 +931,8 @@
*/
jsonOdm.Query.prototype.$ne = function (comparable) {
return this.$testCollection(arguments, function (collectionValue, possibleValues) {
- return Array.prototype.indexOf.call(possibleValues,collectionValue) == -1;
+ for(var i = 0; i &lt; possibleValues.length; i++) if(possibleValues[i] == collectionValue) return false;
+ return true;
});
};
@@ -941,7 +944,8 @@
*/
jsonOdm.Query.prototype.$nin = function (comparable) {
return this.$testCollection(comparable, function (collectionValue, possibleValues) {
- return Array.prototype.indexOf.call(possibleValues,collectionValue) == -1;
+ for(var i = 0; i &lt; possibleValues.length; i++) if(possibleValues[i] == collectionValue) return false;
+ return true;
});
};
View
@@ -20,7 +20,9 @@ UtilTest.prototype.testIs = function () {
assertTrue("Should be an object",jsonOdm.util.is({},"object"));
assertTrue("Should be a boolean" ,jsonOdm.util.is(true,"boolean"));
assertTrue("Should be a undefined",jsonOdm.util.is({}.undefined,"undefined"));
- assertTrue("Should be a arraybuffer",jsonOdm.util.is(new ArrayBuffer(12),"arraybuffer"));
+ if(window.ArrayBuffer){ // only test it if it is supported
+ assertTrue("Should be a arraybuffer",jsonOdm.util.is(new ArrayBuffer(12),"arraybuffer"));
+ }
assertTrue("Should be a boolean" ,jsonOdm.util.is(true,["string","boolean"]));
assertFalse("Should be a boolean" ,jsonOdm.util.is(true,["string","number"]));
@@ -30,4 +32,11 @@ UtilTest.prototype.testObjectKeys = function () {
var myObject = {myKey:"myValue"};
assertEquals("Should have the key","myKey",jsonOdm.util.objectKeys(myObject)[0]);
assertEquals("Should have the key",1,jsonOdm.util.objectKeys(myObject).length);
-};
+};
+
+UtilTest.prototype.testBranch = function () {
+ var myObject = {myKey:"myValue",myArray:[{myKey:"value"}]};
+ assertEquals("Simple Branching","myValue",jsonOdm.util.branch(myObject,["myKey"]));
+ assertEquals("Deep Branching","value",jsonOdm.util.branch(myObject,["myArray",0,"myKey"]));
+ assertFalse("Deep Branching","myValue" == jsonOdm.util.branch(myObject,["myArray",0,"myKey"]));
+}
View
@@ -157,7 +157,8 @@ jsonOdm.Query.prototype.$branch = function (node) {
*/
jsonOdm.Query.prototype.$eq = function (comparable) {
return this.$testCollection(arguments,function (collectionValue, possibleValues) {
- return Array.prototype.indexOf.call(possibleValues,collectionValue) > -1;
+ for(var i = 0; i < possibleValues.length; i++) if(possibleValues[i] == collectionValue) return true;
+ return false;
});
};
@@ -169,7 +170,8 @@ jsonOdm.Query.prototype.$eq = function (comparable) {
*/
jsonOdm.Query.prototype.$in = function (comparable) {
return this.$testCollection(comparable,function (collectionValue, possibleValues) {
- return Array.prototype.indexOf.call(possibleValues,collectionValue) > -1;
+ for(var i = 0; i < possibleValues.length; i++) if(possibleValues[i] == collectionValue) return true;
+ return false;
});
};
@@ -181,7 +183,8 @@ jsonOdm.Query.prototype.$in = function (comparable) {
*/
jsonOdm.Query.prototype.$ne = function (comparable) {
return this.$testCollection(arguments, function (collectionValue, possibleValues) {
- return Array.prototype.indexOf.call(possibleValues,collectionValue) == -1;
+ for(var i = 0; i < possibleValues.length; i++) if(possibleValues[i] == collectionValue) return false;
+ return true;
});
};
@@ -193,7 +196,8 @@ jsonOdm.Query.prototype.$ne = function (comparable) {
*/
jsonOdm.Query.prototype.$nin = function (comparable) {
return this.$testCollection(comparable, function (collectionValue, possibleValues) {
- return Array.prototype.indexOf.call(possibleValues,collectionValue) == -1;
+ for(var i = 0; i < possibleValues.length; i++) if(possibleValues[i] == collectionValue) return false;
+ return true;
});
};

0 comments on commit 85c28cc

Please sign in to comment.