aboutsummaryrefslogtreecommitdiffstats
path: root/vnfmarket/src/main/webapp/vnfmarket/node_modules/phantomjs/lib/phantom/examples/sleepsort.coffee
blob: 863ad14a3c5b09d31c2520335349f38b63006210 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
###
Sort integers from the command line in a very ridiculous way: leveraging timeouts :P
###

system = require 'system'

if system.args.length < 2
  console.log "Usage: phantomjs sleepsort.coffee PUT YOUR INTEGERS HERE SEPARATED BY SPACES"
  phantom.exit 1
else
  sortedCount = 0
  args = Array.prototype.slice.call(system.args, 1)
  for int in args
    setTimeout (do (int) ->
      ->
        console.log int
        ++sortedCount
        phantom.exit() if sortedCount is args.length),
      int