forked from davglass/nodejs-yui3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
library.js
executable file
·53 lines (44 loc) · 1.38 KB
/
library.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env node
var start = (new Date()).getTime();
var sys = require('sys');
var YUI = require("yui3").YUI;
YUI({
filter: 'debug',
debug: true
}).use('json', 'base', 'yql', function(Y) {
//sys.puts('Inside: ' + sys.inspect(process.memoryUsage()));
//Logger outputs with sys.puts
Y.log('This is a test');
//Lang is available
Y.log('Test: ' + Y.Lang.isBoolean(true), 'debug', 'myapp');
//Creating a simple class
var One = function() {
One.superclass.constructor.apply(this, arguments);
};
//Extending it with Y.Base so we have Custom Events and a lifecycle
Y.extend(One, Y.Base, {
test: function() {
this.publish('foo', {
emitFacade: true
});
this.fire('foo');
}
}, {
NAME: 'one'
});
//Create a new instance of our new class
var o = new One();
o.on('foo', function(o) {
Y.log('Foo Fired', 'debug', 'myapp');
//Y.log(o, 'debug');
});
o.test(); //Should fire the one:foo Event.
//sys.puts(sys.inspect(Y));
Y.YQL('select * from github.user.info where (id = "davglass")', function(r) {
//Do something here.
Y.log(r.query, 'debug', 'yql');
Y.log((new Date()).getTime() - start + 'ms', 'info', 'TIMER');
});
var json = '{ "test": "one" }';
Y.log(Y.JSON.parse(json), 'debug', 'json');
});