提交 98659f55 编写于 作者: S shikai-123
上级 94d01f5b
...@@ -92,7 +92,7 @@ getOutput(): Promise<Uint8Array> ...@@ -92,7 +92,7 @@ getOutput(): Promise<Uint8Array>
```js ```js
var child = process.runCmd('ls'); var child = process.runCmd('ls');
var result = child.wait(); var result = child.wait();
child.getOutput.then(val=>{ child.getOutput().then(val=>{
console.log("child.getOutput = " + val); console.log("child.getOutput = " + val);
}) })
``` ```
...@@ -119,7 +119,7 @@ getErrorOutput(): Promise<Uint8Array> ...@@ -119,7 +119,7 @@ getErrorOutput(): Promise<Uint8Array>
```js ```js
var child = process.runCmd('madir test.text'); var child = process.runCmd('madir test.text');
var result = child.wait(); var result = child.wait();
child.getErrorOutput.then(val=>{ child.getErrorOutput().then(val=>{
console.log("child.getErrorOutput= " + val); console.log("child.getErrorOutput= " + val);
}) })
``` ```
...@@ -286,7 +286,7 @@ getThreadPriority(v: number): number ...@@ -286,7 +286,7 @@ getThreadPriority(v: number): number
**示例:** **示例:**
```js ```js
var tid = process.getTid(); var tid = process.tid;
var pres = process.getThreadPriority(tid); var pres = process.getThreadPriority(tid);
``` ```
...@@ -617,5 +617,5 @@ kill(signal: number, pid: number): boolean ...@@ -617,5 +617,5 @@ kill(signal: number, pid: number): boolean
```js ```js
var pres = process.pid var pres = process.pid
var result = that.kill(28, pres) var result = process.kill(28, pres)
``` ```
...@@ -71,8 +71,8 @@ toString(): string ...@@ -71,8 +71,8 @@ toString(): string
**示例:** **示例:**
```js ```js
const uri = new uri.URI('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); const result = new uri.URI('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
uri.toString() result.toString()
``` ```
......
...@@ -31,7 +31,7 @@ URLSearchParams的构造函数。 ...@@ -31,7 +31,7 @@ URLSearchParams的构造函数。
```js ```js
var objectParams = new Url.URLSearchParams([ ['user1', 'abc1'], ['query2', 'first2'], ['query3', 'second3'] ]); var objectParams = new Url.URLSearchParams([ ['user1', 'abc1'], ['query2', 'first2'], ['query3', 'second3'] ]);
var objectParams1 = new Url.URLSearchParams({"fod" : 1 , "bard" : 2}); var objectParams1 = new Url.URLSearchParams({"fod" : '1' , "bard" : '2'});
var objectParams2 = new Url.URLSearchParams('?fod=1&bard=2'); var objectParams2 = new Url.URLSearchParams('?fod=1&bard=2');
var urlObject = new Url.URL('https://developer.mozilla.org/?fod=1&bard=2'); var urlObject = new Url.URL('https://developer.mozilla.org/?fod=1&bard=2');
var params = new Url.URLSearchParams(urlObject.search); var params = new Url.URLSearchParams(urlObject.search);
...@@ -58,7 +58,7 @@ append(name: string, value: string): void ...@@ -58,7 +58,7 @@ append(name: string, value: string): void
```js ```js
let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
let paramsObject = new Url.URLSearchParams(urlObject.search.slice(1)); let paramsObject = new Url.URLSearchParams(urlObject.search.slice(1));
paramsObject.append('fod', 3); paramsObject.append('fod', '3');
``` ```
...@@ -110,7 +110,7 @@ getAll(name: string): string[] ...@@ -110,7 +110,7 @@ getAll(name: string): string[]
```js ```js
let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
let paramsObject = new Url.URLSearchParams(urlObject.search.slice(1)); let paramsObject = new Url.URLSearchParams(urlObject.search.slice(1));
paramsObject.append('fod', 3); // Add a second value for the fod parameter. paramsObject.append('fod', '3'); // Add a second value for the fod parameter.
console.log(params.getAll('fod')) // Output ["1","3"]. console.log(params.getAll('fod')) // Output ["1","3"].
``` ```
...@@ -196,10 +196,9 @@ get(name: string): string | null ...@@ -196,10 +196,9 @@ get(name: string): string | null
**示例:** **示例:**
```js ```js
var paramsOject = new Url.URLSearchParams(document.location.search.substring(1)); var paramsOject = new Url.URLSearchParams('name=Jonathan&age=18');
var name = paramsOject.get("name"); // is the string "Jonathan" var name = paramsOject.get("name"); // is the string "Jonathan"
var age = parseInt(paramsOject.get("age"), 10); // is the number 18 var age = parseInt(paramsOject.get("age"), 10); // is the number 18
var address = paramsOject.get("address"); // null
``` ```
...@@ -252,7 +251,7 @@ set(name: string, value: string): void ...@@ -252,7 +251,7 @@ set(name: string, value: string): void
```js ```js
let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
let paramsObject = new Url.URLSearchParams(urlObject.search.slice(1)); let paramsObject = new Url.URLSearchParams(urlObject.search.slice(1));
paramsObject.set('baz', 3); // Add a third parameter. paramsObject.set('baz', '3'); // Add a third parameter.
``` ```
...@@ -364,7 +363,7 @@ toString(): string ...@@ -364,7 +363,7 @@ toString(): string
```js ```js
let url = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); let url = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
let params = new Url.URLSearchParams(url.search.slice(1)); let params = new Url.URLSearchParams(url.search.slice(1));
params.append('fod', 3); params.append('fod', '3');
console.log(params.toString()); console.log(params.toString());
``` ```
......
...@@ -90,11 +90,12 @@ callbackWrapper(original: Function): (err: Object, value: Object )=>void ...@@ -90,11 +90,12 @@ callbackWrapper(original: Function): (err: Object, value: Object )=>void
async function promiseFn() { async function promiseFn() {
return Promise.reject('value'); return Promise.reject('value');
} }
var err = "type err";
var cb = util.callbackWrapper(promiseFn); var cb = util.callbackWrapper(promiseFn);
cb((err, ret) => { cb((err, ret) => {
console.log(err); console.log(err);
console.log(ret); console.log(ret);
}) }, err)
``` ```
...@@ -121,16 +122,12 @@ promiseWrapper(original: (err: Object, value: Object) => void): Object ...@@ -121,16 +122,12 @@ promiseWrapper(original: (err: Object, value: Object) => void): Object
**示例:** **示例:**
```js ```js
function aysnFun(str1, str2, callback) { function aysnFun() {
if (typeof str1 === 'string' && typeof str2 === 'string') { return 0;
callback(null, str1 + str2);
} else {
callback('type err');
}
} }
let newPromiseObj = util.promiseWrapper(aysnFun)("Hello", 'World'); let newPromiseObj = util.promiseWrapper(aysnFun);
newPromiseObj.then(res => { newPromiseObj().then(res => {
console.log(res); console.log(res);
}) })
``` ```
...@@ -321,10 +318,11 @@ encodeInto(input: string, dest: Uint8Array, ): { read: number; written: number } ...@@ -321,10 +318,11 @@ encodeInto(input: string, dest: Uint8Array, ): { read: number; written: number }
**示例:** **示例:**
```js ```js
var that = new util.TextEncoder(); var that = new util.TextEncoder()
var buffer = new ArrayBuffer(4); var buffer = new ArrayBuffer(4)
this.dest = new Uint8Array(buffer); var dest = new Uint8Array(buffer)
var result = that.encodeInto("abcd", this.dest); var result = new Object()
result = that.encodeInto('abcd', dest)
``` ```
## RationalNumber<sup>8+</sup> ## RationalNumber<sup>8+</sup>
...@@ -371,7 +369,7 @@ static createRationalFromString​(rationalString: string): RationalNumber​ ...@@ -371,7 +369,7 @@ static createRationalFromString​(rationalString: string): RationalNumber​
**示例:** **示例:**
```js ```js
var rationalNumber = new util.RationalNumber(1,2); var rationalNumber = new util.RationalNumber(1,2);
var rational = rationalNumer.creatRationalFromString("3/4"); var rational = util.RationalNumber.createRationalFromString("3/4");
``` ```
...@@ -396,7 +394,7 @@ compareTo​(another: RationalNumber): number​ ...@@ -396,7 +394,7 @@ compareTo​(another: RationalNumber): number​
**示例:** **示例:**
```js ```js
var rationalNumber = new util.RationalNumber(1,2); var rationalNumber = new util.RationalNumber(1,2);
var rational = rationalNumer.creatRationalFromString("3/4"); var rational = util.RationalNumber.createRationalFromString("3/4");
var result = rationalNumber.compareTo(rational); var result = rationalNumber.compareTo(rational);
``` ```
...@@ -442,7 +440,7 @@ equals​(obj: Object): boolean ...@@ -442,7 +440,7 @@ equals​(obj: Object): boolean
**示例:** **示例:**
```js ```js
var rationalNumber = new util.RationalNumber(1,2); var rationalNumber = new util.RationalNumber(1,2);
var rational = rationalNumer.creatRationalFromString("3/4"); var rational = util.RationalNumber.createRationalFromString("3/4");
var result = rationalNumber.equals(rational); var result = rationalNumber.equals(rational);
``` ```
...@@ -469,7 +467,7 @@ static getCommonDivisor​(number1: number,number2: number): number ...@@ -469,7 +467,7 @@ static getCommonDivisor​(number1: number,number2: number): number
**示例:** **示例:**
```js ```js
var rationalNumber = new util.RationalNumber(1,2); var rationalNumber = new util.RationalNumber(1,2);
var result = rationalNumber.getCommonDivisor(4,6); var result = util.RationalNumber.getCommonDivisor(4,6);
``` ```
...@@ -706,7 +704,7 @@ clear(): void ...@@ -706,7 +704,7 @@ clear(): void
```js ```js
var pro = new util.LruBuffer(); var pro = new util.LruBuffer();
pro.put(2,10); pro.put(2,10);
var result = pro.size(); var result = pro.length;
pro.clear(); pro.clear();
``` ```
...@@ -988,14 +986,6 @@ afterRemoval(isEvict: boolean,key: K,value: V,newValue: V): void ...@@ -988,14 +986,6 @@ afterRemoval(isEvict: boolean,key: K,value: V,newValue: V): void
{ {
super(); super();
} }
static getInstance()
{
if(this.instance == null)
{
this.instance = new ChildLruBuffer();
}
return this.instance;
}
afterRemoval(isEvict, key, value, newValue) afterRemoval(isEvict, key, value, newValue)
{ {
if (isEvict === false) if (isEvict === false)
...@@ -1004,7 +994,8 @@ afterRemoval(isEvict: boolean,key: K,value: V,newValue: V): void ...@@ -1004,7 +994,8 @@ afterRemoval(isEvict: boolean,key: K,value: V,newValue: V): void
} }
} }
} }
ChildLruBuffer.getInstance().afterRemoval(false,10,30,null); var lru = new ChildLruBuffer();
lru.afterRemoval(false,10,30,null);
``` ```
...@@ -1097,7 +1088,7 @@ entries(): IterableIterator&lt;[K,V]&gt; ...@@ -1097,7 +1088,7 @@ entries(): IterableIterator&lt;[K,V]&gt;
```js ```js
var pro = new util.LruBuffer(); var pro = new util.LruBuffer();
pro.put(2,10); pro.put(2,10);
var result = pro[symbol.iterator](); var result = pro[Symbol.iterator]();
``` ```
...@@ -1585,7 +1576,7 @@ encode(src: Uint8Array): Promise&lt;Uint8Array&gt; ...@@ -1585,7 +1576,7 @@ encode(src: Uint8Array): Promise&lt;Uint8Array&gt;
var rarray = new Uint8Array([99,122,69,122]); var rarray = new Uint8Array([99,122,69,122]);
that.encode(array).then(val=>{ that.encode(array).then(val=>{
for (var i = 0; i < rarray.length; i++) { for (var i = 0; i < rarray.length; i++) {
console.log(val[i]) console.log(val[i].toString())
} }
}) })
``` ```
...@@ -1644,7 +1635,7 @@ decode(src: Uint8Array | string): Promise&lt;Uint8Array&gt; ...@@ -1644,7 +1635,7 @@ decode(src: Uint8Array | string): Promise&lt;Uint8Array&gt;
var rarray = new Uint8Array([115,49,51]); var rarray = new Uint8Array([115,49,51]);
that.decode(array).then(val=>{ that.decode(array).then(val=>{
for (var i = 0; i < rarray.length; i++) { for (var i = 0; i < rarray.length; i++) {
console.log(val[i]) console.log(val[i].toString())
} }
}) })
``` ```
...@@ -1688,7 +1679,7 @@ isAnyArrayBuffer(value: Object): boolean ...@@ -1688,7 +1679,7 @@ isAnyArrayBuffer(value: Object): boolean
**示例:** **示例:**
```js ```js
var that = new util.types(); var that = new util.types();
var result = that.isAnyArrayBuffer(new ArrayBuffer([])); var result = that.isAnyArrayBuffer(new ArrayBuffer(0));
``` ```
...@@ -1768,7 +1759,7 @@ isArrayBuffer(value: Object): boolean ...@@ -1768,7 +1759,7 @@ isArrayBuffer(value: Object): boolean
**示例:** **示例:**
```js ```js
var that = new util.types(); var that = new util.types();
var result = that.isArrayBuffer(new ArrayBuffer([])); var result = that.isArrayBuffer(new ArrayBuffer(0));
``` ```
......
...@@ -146,7 +146,7 @@ thatSer.setNamespace("h", "http://www.w3.org/TR/html4/"); ...@@ -146,7 +146,7 @@ thatSer.setNamespace("h", "http://www.w3.org/TR/html4/");
thatSer.startElement("table"); thatSer.startElement("table");
thatSer.setAttributes("importance", "high"); thatSer.setAttributes("importance", "high");
thatSer.setText("Happy"); thatSer.setText("Happy");
endElement(); // => <h:table importance="high" xmlns:h="http://www.w3.org/TR/html4/">Happy</h:table> thatSer.endElement(); // => <h:table importance="high" xmlns:h="http://www.w3.org/TR/html4/">Happy</h:table>
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册