Merge pull request #14 from zcourts/master
add support for Array.foreach if not supported
This commit is contained in:
commit
d3736ce974
27
springy.js
27
springy.js
|
@ -25,6 +25,33 @@
|
||||||
* OTHER DEALINGS IN THE SOFTWARE.
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/forEach
|
||||||
|
if ( !Array.prototype.forEach ) {
|
||||||
|
Array.prototype.forEach = function( callback, thisArg ) {
|
||||||
|
var T, k;
|
||||||
|
if ( this == null ) {
|
||||||
|
throw new TypeError( " this is null or not defined" );
|
||||||
|
}
|
||||||
|
var O = Object(this);
|
||||||
|
var len = O.length >>> 0; // Hack to convert O.length to a UInt32
|
||||||
|
if ( {}.toString.call(callback) != "[object Function]" ) {
|
||||||
|
throw new TypeError( callback + " is not a function" );
|
||||||
|
}
|
||||||
|
if ( thisArg ) {
|
||||||
|
T = thisArg;
|
||||||
|
}
|
||||||
|
k = 0;
|
||||||
|
while( k < len ) {
|
||||||
|
var kValue;
|
||||||
|
if ( k in O ) {
|
||||||
|
kValue = O[ k ];
|
||||||
|
callback.call( T, kValue, k, O );
|
||||||
|
}
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
var Graph = function() {
|
var Graph = function() {
|
||||||
this.nodeSet = {};
|
this.nodeSet = {};
|
||||||
this.nodes = [];
|
this.nodes = [];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user