-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathministdlib.py
More file actions
58 lines (52 loc) · 1.59 KB
/
ministdlib.py
File metadata and controls
58 lines (52 loc) · 1.59 KB
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
58
# Python to PythonJS Mini Standard Library
# by Brett Hartshorn - copyright 2013
# You may destribute this file using the "New BSD" or MIT license
REQUIRES = 1
LUA = {
'time': {
## requires socket module, install for luajit on ubuntu - `sudo-apt get install lua-socket`
## for lua interpreter on ubuntu - `sudo apt-get install liblua5.1-socket`
REQUIRES : ['socket'],
'time' : 'time = function() return socket.gettime() end',
'clock' : 'clock = function() return socket.gettime() end'
},
'math': {
'sin' : 'sin = function(a) return math.sin(a[1]) end',
'cos' : 'cos = function(a) return math.cos(a[1]) end',
'sqrt' : 'sqrt = function(a) return math.sqrt(a[1]) end',
}
}
DART = {
'time': {
'time' : 'time() { return new DateTime.now().millisecondsSinceEpoch / 1000.0; }',
'clock' : 'clock() { return new DateTime.now().millisecondsSinceEpoch / 1000.0; }'
},
'math': {
'sin' : 'var sin = math.sin',
'cos' : 'var cos = math.cos',
'sqrt' : 'var sqrt = math.sqrt',
},
'random' : {
'random' : 'var random = __random__'
}
}
JS = {
'time': {
'time': 'function time() { return new Date().getTime() / 1000.0; }',
'clock': 'function clock() { return new Date().getTime() / 1000.0; }'
},
'random': {
'random': 'var random = Math.random'
},
'bisect' : {
'bisect' : '/*bisect from fake bisect module*/' ## bisect is a builtin
},
'math' : {
'sin' : 'var sin = Math.sin',
'cos' : 'var cos = Math.cos',
'sqrt': 'var sqrt = Math.sqrt'
},
'os.path' : {
'dirname' : "function dirname(s) { return s.slice(0, s.lastIndexOf('/')+1)}; var os = {'path':{'dirname':dirname}}"
}
}