Skip to content

Instantly share code, notes, and snippets.

@19h
Created July 20, 2011 02:11
Show Gist options
  • Save 19h/1094191 to your computer and use it in GitHub Desktop.
Save 19h/1094191 to your computer and use it in GitHub Desktop.
Hightspeed Fibonacci-Function, returns JSON. The iterations are given as parameter.
(function(a){var c;c||(c={});(function(){function b(c,d){var g,i,j,l,n=e,o,q=d[c];q&&typeof q==="object"&&typeof q.toJSON==="function"&&(q=q.toJSON(c));typeof h==="function"&&(q=h.call(d,c,q));switch(typeof q){case"string":return a(q);case"number":return isFinite(q)?String(q):"null";case"boolean":case"null":return String(q);case"object":if(!q)return"null";e+=f;o=[];if(Object.prototype.toString.apply(q)==="[object Array]"){l=q.length;for(g=0;g<l;g+=1)o[g]=b(g,q)||"null";j=o.length===0?"[]":e?"[\n"+e+o.join(",\n"+e)+"\n"+n+"]":"["+o.join(",")+"]";e=n;return j}if(h&&typeof h==="object"){l=h.length;for(g=0;g<l;g+=1)typeof h[g]==="string"&&(i=h[g],(j=b(i,q))&&o.push(a(i)+(e?": ":":")+j))}else for(i in q)Object.prototype.hasOwnProperty.call(q,i)&&(j=b(i,q))&&o.push(a(i)+(e?": ":":")+j);j=o.length===0?"{}":e?"{\n"+e+o.join(",\n"+e)+"\n"+n+"}":"{"+o.join(",")+"}";e=n;return j}}function a(a){d.lastIndex=0;return d.test(a)?'"'+a.replace(d,function(a){var b=g[a];return typeof b==="string"?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}var d=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,e,f,g={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},h;if(typeof c.stringify!=="function")c.stringify=function(a,c,d){var g;f=e="";if(typeof d==="number")for(g=0;g<d;g+=1)f+=" ";else typeof d==="string"&&(f=d);if((h=c)&&typeof c!=="function"&&(typeof c!=="object"||typeof c.length!=="number"))throw Error("JSON.stringify");return b("",{"":a})}})();alert(c.stringify(function(){i=0;for(b=[];i<=a;++i)b[i]=function(a){var b,c=[0,1];for(b=0;b<a;++b)c.push(c[0]+c[1]),c.shift();return c[0]}(i);return b}()))})(40)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment