1
is the same as a function without a body at all. For example, in SpiderMonkey, (function(){1}).toString() === (function(){}).toString()
.
]]>[a, b] = [b, a]
work but not advanced stuff.
If you want to see some destructuring documentation (it’s pretty lacking though), refer to New in JavaScript 1.7 on MDC.
I also have another bug report:
prettyPrint throw errors when it is passed E4X XML objects. Unlike the other stuff I have mentioned, E4X actually is part of an Ecma standard (specifically, ECMA-357). Stuff like prettyPrint(<foo><bar/><baz/></foo>)
should work after you fix the bug. This can be easily fixed by using the native prettyPrinting
in E4X using XML.prettyPrinting
, XML.prettyIndent
, and XML.prototype.function::toXMLString
. It would involve temporarily changing the two prettyPrinting preferences temporarily and reverting them if needed.
An alternative option for if you don’t want to support JavaScript: You could just fix only the last bug I mentioned and just rename this library to prettyPrint for ECMAScript
.
function([a, b], {”(”:c, d}) { return a+b+c+d }
in the wild… Could you link to some documentation or perhaps a specification detailing this?
As for your first issue (function() 1
), I’ve fixed this as best I can.
Btw, you can force a function to be printed as an object like so:
prettyPrint( myFunction, { forceObject: true } ); |
prettyPrint(function() 1)
won’t work.
Also, the whole thing gets messed up when there is are any parenthesis in the arguments. The arguments are also removed from their destructuring context. For example, prettyPrint(function([a, b], {"(":c, d}) { return a+b+c+d })
puts a, b, c
in the arguments cell and c}) { return a + b + c;
in the body cell. If I remove the { return
and }
, it puts nothing in the arguments cell and ')': b}) b + 1;
in the body cell. If the "(":c
argument is replaced with ")":c
, then prettyPrint thinks the arguments are a, b,
, including that extra comma.
Arguments can be very complex, so if there is any destructuring, it should be shown just like any object being passed to prettyPrint.
]]>It’s really helped.
]]>@Sebastian & @Mert, The editor is E-textEditor. The theme is “iPlastic”.
@Mandrake, Are you using Chrome v.2? Older versions (<2) of Chrome don't support canvas.toDataURL
; if this is the case then it should work now, please try it and let me know. (I would test it myself but my version of Chrome is too new)
thanks for that
]]>