-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Debug and Xray npm packages. #129
Conversation
I'm about to add one more package to this one, brb |
I was reviewing this PR, trying to figure a way to simplify it if possible... |
Fixed abstract enum in Soap.hx
Great if you can, I've tried a couple of things but couldn't make it better than this. The problem is how to call properties on a function. (That |
Off the top of my head, regarding extern class Debug
implements npm.Package.Require<"debug","^2.2.0">
{
@:selfCall
public function new(name:String):Void;
// special function
public inline function call( data : Dynamic, ?infos : haxe.PosInfos ) {
var args = [data];
if( infos != null && infos.customParams != null ) {
args = args.concat( infos.customParams );
}
untyped this.apply( this, args );
}
// not sure about this one, but why not
// it could make it possible to `debug.log = haxe.Log.trace`
public var log: Dynamic -> ?haxe.PosInfos -> Void;
} See http://old.haxe.org/doc/cross/trace What do you think ? |
I'll take a look! |
Now I remember, there is a static |
Sorry, misclicked |
Just commited a version that supports |
Added commonmark Markdown renderer.
Expanded the Jade class now, and added the Commonmark markdown package. |
} | ||
|
||
public static inline function enable(name : String) : Void { | ||
untyped Lib.require("debug").enable(name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need inline
or this trick, do you ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish it was that simple. There are many things that should be fulfilled here:
- Easy instantiation:
var debug = new Debug("myapp")
- Easy usage:
debug("Working")
- Easy configuration:
debug.log(haxe.Log.trace)
- Easy static configuration:
Debug.log(someOtherLog)
It seems not possible to fulfill all these at the same time. If I use construct
and an abstract class, 2-4 can be fulfilled, keeping as close to the original API as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All 4 should be possible without inline
, since Debug
and DebugInstance
are two different classes, shouldn't it ?
So, any chance to get this pulled in? :) |
/** | ||
* A more powerful version of the default http-driver. | ||
*/ | ||
class XrayHttpDriver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not too much in favor of adding logic in externs :S
Sorry for the delay; I just added more comments :S |
I can remove the This was a nice metadata reference for those, btw: https://haxe.io/releases/3.2.0/#Rest-EitherType-selfCall-callable |
The problem is not so much with public static inline function enable(name : String) : Void {
untyped Lib.require("debug").enable(name);
}
public static inline function disable() : Void {
untyped Lib.require("debug").disable();
}
public static inline function log(log : Either<DebugInstance, DebugHaxeLogTraceFunction>) : Void {
untyped Lib.require("debug").log = log;
} with public static function enable(name : String) : Void;
public static function disable() : Void:
public static var log : Either<DebugInstance, DebugHaxeLogTraceFunction>; when possible. |
Ok, maybe that will work! I'll make an attempt. |
Added PrettyJson.hx
I think this is as good as it gets. Xray makes things very complicated, in plain js:
So I had to make two var xray = new Xray();
xray.x('https://google.com', {
main: 'title',
image: xray.x('#gbar a@href', 'title')
})
.done(function(err, result) {
trace(result);
}); Debug was easier with the static methods, I'm not very happy about the Added a bonus too, a much simpler prettyjson package. :) |
If you have suggestions for other names than |
Ok let's merge it as is :p |
Thanks! it's not a total disaster I hope. :) |
Two pretty useful packages. Debug is nice and simple: https://www.npmjs.com/package/debug
X-ray is more advanced, and I had to create a separate version of the request driver it uses, I hope that's ok.
Finally, since both packages uses a function with properties, I'm using an abstract for the implementation. The
@:callable
metadata makes it possible, with that it's possible to call the underlying function directly. Nice stuff!