Kernel: Javascript (Node.js)
JavaScript in CoCalc
In [1]:
Out[1]:
2
In [2]:
Out[2]:
'v12.16.3'
In [3]:
Out[3]:
[ 1, 2, 5, 10 ]
In [4]:
In [5]:
Out[5]:
[
23, 24, 25, 26, 27,
28, 29, 30, 31, 32
]
Testing Async
Make sure to read http://n-riesco.github.io/ijavascript/doc/async.ipynb.html !!!
In [6]:
Out[6]:
Hello, World!
I'm done waiting a second.
In [7]:
In [8]:
Out[8]:
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"1+1 "
]
}
In [9]:
In [10]:
Out[10]:
start
done
Little HTTP Server
Open it up at https://cocalc.com/[YOUR PROJECT ID]/server/8080
more info: https://doc.cocalc.com/howto/webserver.html
In [11]:
Out[11]:
Server {
insecureHTTPParser: undefined,
_events: [Object: null prototype] {
request: [Function],
connection: [Function: connectionListener]
},
_eventsCount: 2,
_maxListeners: undefined,
_connections: 0,
_handle: TCP {
reading: false,
onconnection: [Function: onconnection],
[Symbol(owner)]: [Circular]
},
_usingWorkers: false,
_workers: [],
_unref: false,
allowHalfOpen: true,
pauseOnConnect: false,
httpAllowHalfOpen: false,
timeout: 120000,
keepAliveTimeout: 5000,
maxHeadersCount: null,
headersTimeout: 40000,
_connectionKey: '6::::8080',
[Symbol(IncomingMessage)]: [Function: IncomingMessage],
[Symbol(ServerResponse)]: [Function: ServerResponse],
[Symbol(kCapture)]: false,
[Symbol(asyncId)]: 79
}
The code above then works like that:

In [0]: