Skip to content

Commit

Permalink
fix IE9 problems with Array methods on Arguments object
Browse files Browse the repository at this point in the history
  • Loading branch information
konsultaner committed Mar 30, 2015
1 parent 9aa0558 commit 85c28cc
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 35 deletions.
5 changes: 5 additions & 0 deletions README.MD
Expand Up @@ -50,6 +50,11 @@ To execute the benchmark use command ```gulp bench``` after adding:
npm install --save-dev gulp-bench 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 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) 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)
Expand Down
4 changes: 3 additions & 1 deletion bench/query-test.js
Expand Up @@ -37,7 +37,9 @@ module.exports = {
{ {
name: 'Simple text search within 500,000 Elements', name: 'Simple text search within 500,000 Elements',
fn : function(){ 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;
} }
} }
] ]
Expand Down
2 changes: 1 addition & 1 deletion bin/json.odm.min.js

Large diffs are not rendered by default.

46 changes: 23 additions & 23 deletions doc/bench/benchmark-results.json
@@ -1,63 +1,63 @@
[ [
{ {
"name": "pointWithinPolygon: real live example for point in polygon with 756 edges", "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)", "timestamp": "Mon Mar 30 2015 16:16:43 GMT+0200 (Mitteleuropäische Sommerzeit)",
"count": 11803, "count": 11859,
"cycles": 4, "cycles": 5,
"hz": 231150.48685201688, "hz": 227206.30920054598,
"suite": "Geo benchmarks" "suite": "Geo benchmarks"
}, },
{ {
"name": "pointWithinLineString: real live example for point on polygon line with 756 edges", "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)", "timestamp": "Mon Mar 30 2015 16:16:49 GMT+0200 (Mitteleuropäische Sommerzeit)",
"count": 30315, "count": 30332,
"cycles": 4, "cycles": 4,
"hz": 575714.5267999222, "hz": 551198.9805362248,
"suite": "Geo benchmarks" "suite": "Geo benchmarks"
}, },
{ {
"name": "edgeIntersectsEdge: random edges", "name": "edgeIntersectsEdge: random edges",
"timestamp": "Sat Mar 28 2015 13:02:03 GMT+0100 (Mitteleuropäische Zeit)", "timestamp": "Mon Mar 30 2015 16:16:54 GMT+0200 (Mitteleuropäische Sommerzeit)",
"count": 224094, "count": 221526,
"cycles": 4, "cycles": 6,
"hz": 3150673.2939504143, "hz": 3036041.185034033,
"suite": "Geo benchmarks" "suite": "Geo benchmarks"
}, },
{ {
"name": "pointWithinPolygon: worst case point in worst case polygon with 2000 edges", "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)", "timestamp": "Mon Mar 30 2015 16:16:59 GMT+0200 (Mitteleuropäische Sommerzeit)",
"count": 471, "count": 468,
"cycles": 6, "cycles": 3,
"hz": 9202.760052746176, "hz": 8999.416284493025,
"suite": "Geo benchmarks" "suite": "Geo benchmarks"
}, },
{ {
"name": "pointWithinLineString: worst case point on worst case polygon line with 2000 edges", "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)", "timestamp": "Mon Mar 30 2015 16:17:05 GMT+0200 (Mitteleuropäische Sommerzeit)",
"count": 1085338, "count": 1071074,
"cycles": 5, "cycles": 5,
"hz": 20429809.78979747, "hz": 19524781.870863765,
"suite": "Geo benchmarks" "suite": "Geo benchmarks"
}, },
{ {
"name": "Simple Query all 500,000 Elements", "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, "count": 1,
"cycles": 1, "cycles": 1,
"hz": 2.6392006937892396, "hz": 2.545358738740628,
"suite": "Query benchmarks" "suite": "Query benchmarks"
}, },
{ {
"name": "Complex Query all 500,000 Elements", "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, "count": 1,
"cycles": 1, "cycles": 1,
"hz": 0.9184245912725004, "hz": 0.8459475102413795,
"suite": "Query benchmarks" "suite": "Query benchmarks"
}, },
{ {
"name": "Simple text search within 500,000 Elements", "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": {}, "error": {},
"count": 0, "count": 0,
"cycles": 0, "cycles": 0,
Expand Down
12 changes: 8 additions & 4 deletions doc/jsonOdm/0.0/query.js.html
Expand Up @@ -905,7 +905,8 @@ <h3>Modules</h3>
*/ */
jsonOdm.Query.prototype.$eq = function (comparable) { jsonOdm.Query.prototype.$eq = function (comparable) {
return this.$testCollection(arguments,function (collectionValue, possibleValues) { 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;
}); });
}; };


Expand All @@ -917,7 +918,8 @@ <h3>Modules</h3>
*/ */
jsonOdm.Query.prototype.$in = function (comparable) { jsonOdm.Query.prototype.$in = function (comparable) {
return this.$testCollection(comparable,function (collectionValue, possibleValues) { 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;
}); });
}; };


Expand All @@ -929,7 +931,8 @@ <h3>Modules</h3>
*/ */
jsonOdm.Query.prototype.$ne = function (comparable) { jsonOdm.Query.prototype.$ne = function (comparable) {
return this.$testCollection(arguments, function (collectionValue, possibleValues) { 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;
}); });
}; };


Expand All @@ -941,7 +944,8 @@ <h3>Modules</h3>
*/ */
jsonOdm.Query.prototype.$nin = function (comparable) { jsonOdm.Query.prototype.$nin = function (comparable) {
return this.$testCollection(comparable, function (collectionValue, possibleValues) { 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;
}); });
}; };


Expand Down
13 changes: 11 additions & 2 deletions src-test/util-test.js
Expand Up @@ -20,7 +20,9 @@ UtilTest.prototype.testIs = function () {
assertTrue("Should be an object",jsonOdm.util.is({},"object")); assertTrue("Should be an object",jsonOdm.util.is({},"object"));
assertTrue("Should be a boolean" ,jsonOdm.util.is(true,"boolean")); assertTrue("Should be a boolean" ,jsonOdm.util.is(true,"boolean"));
assertTrue("Should be a undefined",jsonOdm.util.is({}.undefined,"undefined")); 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"])); assertTrue("Should be a boolean" ,jsonOdm.util.is(true,["string","boolean"]));
assertFalse("Should be a boolean" ,jsonOdm.util.is(true,["string","number"])); assertFalse("Should be a boolean" ,jsonOdm.util.is(true,["string","number"]));
Expand All @@ -30,4 +32,11 @@ UtilTest.prototype.testObjectKeys = function () {
var myObject = {myKey:"myValue"}; var myObject = {myKey:"myValue"};
assertEquals("Should have the key","myKey",jsonOdm.util.objectKeys(myObject)[0]); assertEquals("Should have the key","myKey",jsonOdm.util.objectKeys(myObject)[0]);
assertEquals("Should have the key",1,jsonOdm.util.objectKeys(myObject).length); 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"]));
}
12 changes: 8 additions & 4 deletions src/query.js
Expand Up @@ -157,7 +157,8 @@ jsonOdm.Query.prototype.$branch = function (node) {
*/ */
jsonOdm.Query.prototype.$eq = function (comparable) { jsonOdm.Query.prototype.$eq = function (comparable) {
return this.$testCollection(arguments,function (collectionValue, possibleValues) { 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;
}); });
}; };


Expand All @@ -169,7 +170,8 @@ jsonOdm.Query.prototype.$eq = function (comparable) {
*/ */
jsonOdm.Query.prototype.$in = function (comparable) { jsonOdm.Query.prototype.$in = function (comparable) {
return this.$testCollection(comparable,function (collectionValue, possibleValues) { 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;
}); });
}; };


Expand All @@ -181,7 +183,8 @@ jsonOdm.Query.prototype.$in = function (comparable) {
*/ */
jsonOdm.Query.prototype.$ne = function (comparable) { jsonOdm.Query.prototype.$ne = function (comparable) {
return this.$testCollection(arguments, function (collectionValue, possibleValues) { 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;
}); });
}; };


Expand All @@ -193,7 +196,8 @@ jsonOdm.Query.prototype.$ne = function (comparable) {
*/ */
jsonOdm.Query.prototype.$nin = function (comparable) { jsonOdm.Query.prototype.$nin = function (comparable) {
return this.$testCollection(comparable, function (collectionValue, possibleValues) { 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;
}); });
}; };


Expand Down

0 comments on commit 85c28cc

Please sign in to comment.