-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathsandbox.coffee
executable file
·58 lines (43 loc) · 1.26 KB
/
sandbox.coffee
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
54
55
56
57
#!/usr/bin/env coffee
_ = require 'lodash'
Q = require 'q'
fs = require 'fs'
os = require 'os'
assert = require 'assert'
n = [['four', 4], ['three', 3], ['seven', 7], ['nine', 9]]
s = _.sortBy(n, ([t,n]) -> n)
_.zip(['three', 'four', 'seven', 'nine'], _(s).map(([t,n]) -> t).value()).forEach(([L,R]) -> assert.equal(L, R))
assert.equal('', ''.split('__')[0])
assert.equal(0, _([1]).filter((v) -> isNaN(v)).size())
idx = require './src/index'
config =
migrationsDir: "test"
console.log "Config: #{config}"
console.log "Stat:", fs.statSync('sandbox.coffee')
idx.listMigrations config
.then (files) ->
console.log "Migration files:", files
.catch (error) ->
console.log "Error: #{error}\n#{error.stack}"
console.log "Shift empty array:", [].shift()
promiseMe = (value) ->
d = Q.defer()
setTimeout(-> d.resolve value, 5000)
d.promise
Q.all [promiseMe('A'), promiseMe('B')]
.spread (a, b) ->
console.log "a: #{a}"
console.log "b: #{b}"
.catch (error) ->
console.log error
cpus = os.cpus()
cpuCount = _(cpus).size()
console.log "[#{cpuCount}] CPUs:\n", cpus
Q.fcall ->
return Q.fcall ->
return 1
.then (one) ->
throw new Error("This is supposed to happen.")
console.log "What?!"
.catch (error) ->
console.log "Hey! We caught an exception: #{error}"