nerv_,
спасибо буду знать
вопрос если я хочу все двойки поменять синтаксис внизу правильный ? или это как то по другому можно
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
</head>
<body>
<script>/*
recursive-iterator v1.0.0
https://github.com/nervgh/recursive-iterator
*/
!function(a,b){"function"==typeof define&&define.amd?define("RecursiveIterator",[],function(){return a.RecursiveIterator=b()}):"object"==typeof exports?module.exports=b():a.RecursiveIterator=b()}(this,function(){"use strict";var a=function(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}return Array.from(a)},b=function(a,b,c){b&&Object.defineProperties(a,b),c&&Object.defineProperties(a.prototype,c)},c=function(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")},d=function(){function d(b){var e=void 0===arguments[1]?0:arguments[1],f=void 0===arguments[2]?!1:arguments[2],g=void 0===arguments[3]?100:arguments[3];c(this,d),this.__bypassMode=e,this.__ignoreCircular=f,this.__maxDeep=g,this.__queue=[].concat(a(d.getChildNodes(b,[],0))),this.__node=d.getNode(),this.__cache=[b],this.__makeIterable()}return b(d,{getKeys:{value:function(a){return Object.keys(a).sort()},writable:!0,configurable:!0},isObject:{value:function(a){return a instanceof Object},writable:!0,configurable:!0},getChildNodes:{value:function(a,b,c){return d.getKeys(a).map(function(e){return d.getNode(a,a[e],e,b.concat(e),c+1)})},writable:!0,configurable:!0},getNode:{value:function(a,b,c){var d=void 0===arguments[3]?[]:arguments[3],e=void 0===arguments[4]?0:arguments[4];return{parent:a,node:b,key:c,path:d,deep:e}},writable:!0,configurable:!0}},{next:{value:function(){var b=this.__node&&this.__node.node,c=this.__node&&this.__node.path,e=this.__node&&this.__node.deep;if(this.__maxDeep>e&&d.isObject(b))if(this.isCircular(b)){if(!this.__ignoreCircular)throw new Error("Circular reference")}else if(this.onStepInto(b)){if(this.__bypassMode){var f;(f=this.__queue).push.apply(f,a(d.getChildNodes(b,c,e)))}else{var g;(g=this.__queue).unshift.apply(g,a(d.getChildNodes(b,c,e)))}this.__cache.push(b)}return this.__node=this.__queue.shift(),this.__node||this.destroy(),{value:this.__node,done:!this.__node}},writable:!0,configurable:!0},destroy:{value:function(){this.__queue.length=0,this.__cache.length=0,this.__node=void 0},writable:!0,configurable:!0},isLeaf:{value:function(a){if(!d.isObject(a))return!0;var b=d.getKeys(a);return!b.length},writable:!0,configurable:!0},isCircular:{value:function(a){return-1!==this.__cache.indexOf(a)},writable:!0,configurable:!0},onStepInto:{value:function(){return!0},writable:!0,configurable:!0},__makeIterable:{value:function(){var a=this;try{this[Symbol.iterator]=function(){return a}}catch(b){}},writable:!0,configurable:!0}}),d}(),e=d;return e});
</script>
<script>
var mazePacman1 = [
[1, 2, 3, 4, 5],
[2, 1, 4, 5, 5]
];
var iterator = new RecursiveIterator(mazePacman1);
for(var item = iterator.next(); !item.done; item = iterator.next()) {
var state = item.value;
if (state.node == 2) state.parent[state.key] = 90
}
alert(JSON.stringify(mazePacman1))
</script>
</body>
</html>