From a4d4893c77f9c48dedc88472a2e418bfd65e33a1 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Tue, 16 Aug 2022 15:46:32 +0800 Subject: update docs. --- doc/docs/doc/README.md | 128 ++++++++++++++++++++++++------------------------- doc/package.json | 2 +- 2 files changed, 63 insertions(+), 67 deletions(-) (limited to 'doc') diff --git a/doc/docs/doc/README.md b/doc/docs/doc/README.md index c6b493c..5f00860 100755 --- a/doc/docs/doc/README.md +++ b/doc/docs/doc/README.md @@ -571,68 +571,6 @@ readFile "example.txt" -### Backcall - -Backcalls are used for unnesting callbacks. They are defined using arrows pointed to the left as the last parameter by default filling in a function call. All the syntax is mostly the same as regular arrow functions except that it is just pointing the other way and the function body does not require indent. - -```moonscript -<- f -print "hello" -``` - -
-<- f
-print "hello"
-
-
- -Fat arrow functions are also available. - -```moonscript -<= f -print @value -``` - -
-<= f
-print @value
-
-
- -You can specify a placeholder for where you want the backcall function to go as a parameter. - -```moonscript -(x) <- map _, {1, 2, 3} -x * 2 -``` - -
-(x) <- map _, {1, 2, 3}
-x * 2
-
-
- -If you wish to have further code after your backcalls, you can set them aside with a do statement. - -```moonscript -result, msg = do - (data) <- readAsync "filename.txt" - print data - (info) <- processAsync data - check info -print result, msg -``` - -
-result, msg = do
-  (data) <- readAsync "filename.txt"
-  print data
-  (info) <- processAsync data
-  check info
-print result, msg
-
-
- ### Nil Coalescing The nil-coalescing operator **??** returns the value of its left-hand operand if it isn't **nil**; otherwise, it evaluates the right-hand operand and returns its result. The **??** operator doesn't evaluate its right-hand operand if the left-hand operand evaluates to non-nil. @@ -1655,6 +1593,68 @@ if func 1, 2, 3, +## Backcalls + +Backcalls are used for unnesting callbacks. They are defined using arrows pointed to the left as the last parameter by default filling in a function call. All the syntax is mostly the same as regular arrow functions except that it is just pointing the other way and the function body does not require indent. + +```moonscript +<- f +print "hello" +``` + +
+<- f
+print "hello"
+
+
+ +Fat arrow functions are also available. + +```moonscript +<= f +print @value +``` + +
+<= f
+print @value
+
+
+ +You can specify a placeholder for where you want the backcall function to go as a parameter. + +```moonscript +(x) <- map _, {1, 2, 3} +x * 2 +``` + +
+(x) <- map _, {1, 2, 3}
+x * 2
+
+
+ +If you wish to have further code after your backcalls, you can set them aside with a do statement. + +```moonscript +result, msg = do + (data) <- readAsync "filename.txt" + print data + (info) <- processAsync data + check info +print result, msg +``` + +
+result, msg = do
+  (data) <- readAsync "filename.txt"
+  print data
+  (info) <- processAsync data
+  check info
+print result, msg
+
+
+ ## Table Literals Like in Lua, tables are delimited in curly braces. @@ -2889,10 +2889,6 @@ assert y.__class.__parent ~= X -- X is not parent of Y -::: warning NOTICE -The rest of the document is describing mostly the same syntax taken from Moonscript. So you may as well refer to the [Moonscript Reference](http://moonscript.org/reference) to get the same explanation. -::: - ## With Statement A common pattern involving the creation of an object is calling a series of functions and setting a series of properties immediately after creating it. diff --git a/doc/package.json b/doc/package.json index d484ef9..0784500 100755 --- a/doc/package.json +++ b/doc/package.json @@ -19,7 +19,7 @@ "vuepress": "^1.3.1" }, "dependencies": { - "vue-js-modal": "^2.0.0-rc.6", + "vue-js-modal": "^2.0.1", "vue-prism-editor": "^1.2.2" } } -- cgit v1.2.3-55-g6feb