From a6594f51193f38e79059d2d7bc060e8aca71ddad Mon Sep 17 00:00:00 2001 From: Thomas FORGIONE Date: Tue, 29 Sep 2015 09:29:02 +0200 Subject: [PATCH] Added polyfill for find for array --- controllers/prototype/dbrequests.js | 24 ++++++++++++++++++++++++ utils/load/load.sh | 1 + 2 files changed, 25 insertions(+) diff --git a/controllers/prototype/dbrequests.js b/controllers/prototype/dbrequests.js index eeb7032..744495a 100644 --- a/controllers/prototype/dbrequests.js +++ b/controllers/prototype/dbrequests.js @@ -1,3 +1,27 @@ +// Polyfill of find array +if (!Array.prototype.find) { + Array.prototype.find = function(predicate) { + if (this == null) { + throw new TypeError('Array.prototype.find a été appelé sur null ou undefined'); + } + if (typeof predicate !== 'function') { + throw new TypeError('predicate doit être une fonction'); + } + var list = Object(this); + var length = list.length >>> 0; + var thisArg = arguments[1]; + var value; + + for (var i = 0; i < length; i++) { + value = list[i]; + if (predicate.call(thisArg, value, i, list)) { + return value; + } + } + return undefined; + }; +} + var pg = require('pg'); var pgc = require('../../private.js'); var Log = require('../../lib/NodeLog.js'); diff --git a/utils/load/load.sh b/utils/load/load.sh index c82f5d8..82be3ef 100755 --- a/utils/load/load.sh +++ b/utils/load/load.sh @@ -1,4 +1,5 @@ #!/usr/bin/bash +rm cookies* for i in `seq 1 8`; do casperjs load.js --cookies-file=cookies"$i".txt& done