Skip to content

Commit

Permalink
文档更新
Browse files Browse the repository at this point in the history
  • Loading branch information
aiselp committed May 27, 2023
1 parent 568c463 commit 7e00e26
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 6 deletions.
4 changes: 4 additions & 0 deletions _sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,9 @@
- [axios](/axios)
- npm模块
- [cheerio](/npm/cheerio)
- [buffer](/npm/buffer)
- [stream](/npm/stream)
- [event-stream](/npm/event-stream)
- [events](/npm/events)

- [常见问题](/qa)
6 changes: 3 additions & 3 deletions axios.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# axios
v6.3.9新增
> <font color="#ec5315">稳定性: 实验</font>
<font color="#ef5952">**注意**: 这个模块是异步的,返回的全部都是`Promise`,如果你的程序有大量阻塞函数,请谨慎使用</font>
这个模块不会自动加载,如需使用,请用
```js
const axios = require('axios/index.js');
//或 在子模块中不可用
const axios = require('axios');
```
模块使用方法与axios完全一致,请参阅[官方网站](https://www.axios-http.cn/docs/intro),以下只介绍一些在autox中特有的内容。
Expand All @@ -23,6 +22,7 @@ const axios = require('axios');
* `json`
* `blob`
* `inputstream` java输入流
* `stream` Readable可读流 \*v6.4.0新增

支持的请求体数据类型:
* `RequestBody` okhttp3.RequestBody对象
Expand Down Expand Up @@ -83,7 +83,7 @@ axios.post('http://baidu.com', blob).then(function (res) {
```

## axios.browser
用于模拟浏览器环境的对象,包含`XMLHttpRequest``FormData`等,除了`FormData`其他对象都不建议直接使用
用于模拟浏览器环境的对象,包含`XMLHttpRequest``FormData`等,除了`FormData`其他对象都不建议使用

## axios.utils
包含一些操作blob对象方法
Expand Down
22 changes: 22 additions & 0 deletions npm/buffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Buffer
v6.4.0新增
> 稳定性: 稳定
node中Buffer的实现,使用文档见node文档,下方是autox中特有的内容
这个模块全局可用,因此不必
```js
const Buffer = require("buffer").Buffer;
```
## Buffer.prototype.getBytes()
返回buffer内部ArrayBuffer所对应的java字节数组
```js
let buf = Buffer.alloc(10)
let buf2 = Buffer.from(buf.buffer,0,5)
buf[0] = 40;
buf2[2] = 7;
log(buf.getBytes() === buf2.getBytes())//true
```
## Buffer.fromBytes(byteArr)
* byteArr {\<byte\>[]} java字节数组

从字节数组创建一个buffer,其内容是原数据的拷贝。
5 changes: 2 additions & 3 deletions npm/cheerio.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# cheerio
v6.3.9新增
> <font color="#FF34FF17">稳定性: 稳定</font>
这是一个用于解析和生成html/xml的库,使用方法请参阅[官方网站](https://github.com/cheeriojs/cheerio),该模块不会自动加载,如需使用
```
const cheerio = require('npm/cheerio');
const cheerio = require('cheerio');
```

这里简单介绍一下在autojs中的用途。
Expand Down Expand Up @@ -35,7 +36,6 @@ ui.text2.setText(text)

使用`cheerio`则可以像这样处理:
```
"ui";
const cheerio = require('npm/cheerio');
let text = "变量文本"
let $ = cheerio.load( `<vertical>
Expand All @@ -50,4 +50,3 @@ log(xml)
ui.layout(xml)
```
高级的用法还可以将xml组件化,列表生成等

22 changes: 22 additions & 0 deletions npm/event-stream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# event-stream
v6.4.0新增
> 稳定性: 稳定
来自npm模块event-stream,如需使用,请用
```js
const es = require('event-stream')
```
该模块用于便捷的创建流
```js
es.readable(function (count, callback) {
if(streamHasEnded)
return this.emit('end')

//...

this.emit('data', data) //use this way to emit multiple chunks per call.

callback() // you MUST always call the callback eventually.
// the function will not be called again until you do this.
})
```
8 changes: 8 additions & 0 deletions npm/events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# events
v6.4.0新增
> 稳定性: 稳定
node中events的实现,如需使用,请用
```js
const events = require('events')
```
30 changes: 30 additions & 0 deletions npm/stream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# stream
v6.4.0新增
> 稳定性: 稳定
注意: <font color="#ef5952">这个模块是异步的,使用此模块请勿阻塞线程</font>
该模块不会自动加载,如需使用,请用
```
const stream = require('stream');
```
使用方法参考node文档中stream,下方是一些autox中特有的内容
## stream.fromInputStream(inputStream[,options])
* inputStream {InputStream} java输入流
* options {object} 选项,详细见node文档

将java流转为Readable可读流,为提高处理速度,默认的缓冲区大小被设为64kb,io操作由内部io线程处理
## stream.fromOutputStream(outputStream[,options])
* outputStream {OutputStream} java输出流
* options {object} 选项,详细见node文档

将java流转为Writable可写流,为提高处理速度,默认的缓冲区大小被设为64kb,io操作由内部io线程处理
## stream.createFileReadStream(path[,bufferSize])
* path {String} 文件路径
* bufferSize {Number} 缓冲区大小,默认256k

从文件创建一个可读流
## stream.createFileWriteStream(path[,bufferSize])
* path {String} 文件路径
* bufferSize {Number} 缓冲区大小,默认256k

从文件创建一个可写流

0 comments on commit 7e00e26

Please sign in to comment.