Last change
on this file since 31525 was 31525, checked in by ak19, 7 years ago |
Nathan provided more stuff: Themes folder contains Sencha's Themebuilder which generates GXT Themes. It includes the .theme and generated .jar files for the project theme.
|
File size:
758 bytes
|
Line | |
---|
1 | // sleepsort.js - Sort integers from the commandline in a very ridiculous way: leveraging timeouts :P
|
---|
2 | var system = require('system');
|
---|
3 |
|
---|
4 | function sleepSort(array, callback) {
|
---|
5 | var sortedCount = 0,
|
---|
6 | i, len;
|
---|
7 | for ( i = 0, len = array.length; i < len; ++i ) {
|
---|
8 | setTimeout((function(j){
|
---|
9 | return function() {
|
---|
10 | console.log(array[j]);
|
---|
11 | ++sortedCount;
|
---|
12 | (len === sortedCount) && callback();
|
---|
13 | };
|
---|
14 | }(i)), array[i]);
|
---|
15 | }
|
---|
16 | }
|
---|
17 |
|
---|
18 | if ( system.args < 2 ) {
|
---|
19 | console.log("Usage: phantomjs sleepsort.js PUT YOUR INTEGERS HERE SEPARATED BY SPACES");
|
---|
20 | phantom.exit(1);
|
---|
21 | } else {
|
---|
22 | sleepSort(Array.prototype.slice.call(system.args, 1), function() {
|
---|
23 | phantom.exit();
|
---|
24 | });
|
---|
25 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.