File tree Expand file tree Collapse file tree 3 files changed +101
-1
lines changed Expand file tree Collapse file tree 3 files changed +101
-1
lines changed Original file line number Diff line number Diff line change 44#####################################################################################
55# CoCalc Examples - Documentation Files Compiler #
66# #
7- # Copyright (C) 2015 -- 2018 , SageMath, Inc. #
7+ # Copyright (C) 2015 -- 2020 , SageMath, Inc. #
88# #
99# Distributed under the terms of the GNU General Public License (GPL), version 2+ #
1010# #
@@ -125,6 +125,7 @@ def examples_data(input_dir, output_fn):
125125 "bash" : recursive_dict (),
126126 "octave" : recursive_dict (),
127127 "julia" : recursive_dict (),
128+ "javascript" : recursive_dict (),
128129 }
129130
130131 # This processes all yaml input files and fails when any assertion is violated.
@@ -246,6 +247,7 @@ def language_to_kernel(lang):
246247 "python" : "python3" ,
247248 "r" : "ir" ,
248249 "julia" : "julia-1.1" ,
250+ "javascript" : "javascript" ,
249251 }
250252 return data .get (lang .lower (), lang )
251253
Original file line number Diff line number Diff line change 1+ # CoCalc Snippets for Javascript
2+ # Copyright: SageMath Inc., 2020
3+ # License: Creative Commons: Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
4+ ---
5+ language : javascript
6+ category : ["Advanced", "Async/Await"]
7+ ---
8+ title : " Async/Await in ijavascript"
9+ descr : >
10+ This is how you can run async code in `ijavascript`.
11+ Notice, how there is a 1 second delay between the outputs and only then the execution halts (calling `$$.done()`)
12+
13+ See [ijavascript async output](http://n-riesco.github.io/ijavascript/doc/async.ipynb.html) for more information.
14+ code : |
15+ $$.async();
16+
17+ console.log("Hello, World!");
18+
19+ function run() {
20+ console.log("I'm done waiting a second.");
21+ $$.done();
22+ }
23+
24+ setTimeout(run, 1000);
Original file line number Diff line number Diff line change 1+ # CoCalc Snippets for Javascript
2+ # Copyright: SageMath Inc., 2020
3+ # License: Creative Commons: Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
4+ ---
5+ language : javascript
6+ category : Tutorial / First Steps
7+ sortweight : -1
8+ ---
9+ title : Introduction
10+ descr : >
11+ This jupyter kernel runs JavaScript remotely in Node.js.
12+
13+ - [kernel ijavascript](https://github.com/n-riesco/ijavascript)
14+ - [node.js](https://nodejs.org/en/)
15+ code :
16+ - |
17+ # a simple calculation
18+ 1+1
19+ - |
20+ # the version of Node.js
21+ process.version
22+ ---
23+ title : Variables
24+ descr : >
25+ Use the equal sign to name an object to refer to it later.
26+ code :
27+ - |
28+ # define x
29+ x = 20
30+ x
31+ - |
32+ # now refer to x in a calculation
33+ 2 * x + 1
34+ ---
35+ title : Print output
36+ descr : >
37+ Use `console.log(...)` to show output – otherwise, only the last value in a cell will be displayed.
38+ code : |
39+ console.log("Hello, World!");
40+ console.log(9 * 9);
41+ console.log("finished");
42+ ---
43+ category : Tutorial / Arrays
44+ ---
45+ title : Arrays
46+ descr : >
47+ An array is an ordered collection of objects.
48+ code : |
49+ [1, 2, 5, 10]
50+ ---
51+ title : Array manipulations
52+ descr : >
53+ This is how you can change an element in an array and extract an element at a specific location.
54+
55+ The first element is at *index position 0*!
56+ code :
57+ - |
58+ arr = ['foo', 'bar', 'baz']
59+ arr[1] = 'apple'
60+ arr
61+ - |
62+ arr[0]
63+ ---
64+ category : Tutorial / Functions
65+ ---
66+ title : Introduction
67+ descr : >
68+ A JavaScript function is ...
69+ code :
70+ - |
71+ function foo(x) {
72+ return 2*x+1;
73+ }
74+ - foo(20)
You can’t perform that action at this time.
0 commit comments