Skip to content

Commit

Permalink
升级到 v.8.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
h7lin committed Jul 4, 2017
1 parent 1255890 commit 4e739a0
Show file tree
Hide file tree
Showing 74 changed files with 259 additions and 194 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# node-api-cn
Node.js API 中文文档 v8.1.2
Node.js API 中文文档 v8.1.3

http://nodejs.cn/api/
6 changes: 3 additions & 3 deletions async_hooks/type.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@

The `type` is a string that represents the type of resource that caused
`init` to call. Generally it will be the name of the resource's constructor.
The resource types provided by the built-in Node.js modules are:
`init` to be called. Generally, it will correspond to the name of the
resource's constructor.

```
FSEVENTWRAP, FSREQWRAP, GETADDRINFOREQWRAP, GETNAMEINFOREQWRAP, HTTPPARSER,
JSSTREAM, PIPECONNECTWRAP, PIPEWRAP, PROCESSWRAP, QUERYWRAP, SHUTDOWNWRAP,
SIGNALWRAP, STATWATCHER, TCPCONNECTWRAP, TCPWRAP, TIMERWRAP, TTYWRAP,
UDPSENDWRAP, UDPWRAP, WRITEWRAP, ZLIB, SSLCONNECTION, PBKDF2REQUEST,
RANDOMBYTESREQUEST, TLSWRAP
RANDOMBYTESREQUEST, TLSWRAP, Timeout, Immediate, TickObject
```

Users are be able to define their own `type` when using the public embedder API.
Expand Down
18 changes: 16 additions & 2 deletions child_process/example_sending_a_socket_object.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
const normal = require('child_process').fork('child.js', ['normal']);
const special = require('child_process').fork('child.js', ['special']);
// 开启 server,并发送 socket 给子进程
const server = require('net').createServer();
// 开启 server,并发送 socket 给子进程。
// 使用 `pauseOnConnect` 防止 socket 在被发送到子进程之前被读取。
const server = require('net').createServer({ pauseOnConnect: true });
server.on('connection', (socket) => {
// 特殊优先级
Expand All @@ -29,11 +30,24 @@ process.on('message', (m, socket) => {
socket.end(`请求被 ${process.argv[2]} 优先级处理`);
}
});
process.on('message', (m, socket) => {
if (m === 'socket') {
if (socket) {
// 检查客户端 socket 是否存在。
// socket 在被发送与被子进程接收这段时间内可被关闭。
socket.end(`请求被 ${process.argv[2]} 优先级处理`);
}
}
});
```

一旦一个 socket 已被传给了子进程,则父进程不再能够跟踪 socket 何时被销毁。
为了表明这个,`.connections` 属性会变成 `null`
当发生这种情况时,建议不要使用 `.maxConnections`

It is also recommended that any `'message'` handlers in the child process
verify that `socket` exists, as the connection may have been closed during the
time it takes to send the connection to the child.

注意,该函数内部使用 [`JSON.stringify()`] 序列化 `message`

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<!-- YAML
added: v0.1.94
-->
- `output_encoding` {string}
- `outputEncoding` {string}

Returns any remaining enciphered contents. If `output_encoding`
Returns any remaining enciphered contents. If `outputEncoding`
parameter is one of `'latin1'`, `'base64'` or `'hex'`, a string is returned.
If an `output_encoding` is not provided, a [`Buffer`][] is returned.
If an `outputEncoding` is not provided, a [`Buffer`][] is returned.

Once the `cipher.final()` method has been called, the `Cipher` object can no
longer be used to encrypt data. Attempts to call `cipher.final()` more than
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<!-- YAML
added: v0.7.1
-->
- `auto_padding` {boolean} Defaults to `true`.
- `autoPadding` {boolean} Defaults to `true`.
- Returns the {Cipher} for method chaining.

When using block encryption algorithms, the `Cipher` class will automatically
add padding to the input data to the appropriate block size. To disable the
default padding call `cipher.setAutoPadding(false)`.

When `auto_padding` is `false`, the length of the entire input data must be a
When `autoPadding` is `false`, the length of the entire input data must be a
multiple of the cipher's block size or [`cipher.final()`][] will throw an Error.
Disabling automatic padding is useful for non-standard padding, for instance
using `0x0` instead of PKCS padding.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ added: v0.1.94
changes:
- version: v6.0.0
pr-url: https://github.com/nodejs/node/pull/5522
description: The default `input_encoding` changed from `binary` to `utf8`.
description: The default `inputEncoding` changed from `binary` to `utf8`.
-->
- `data` {string | Buffer | TypedArray | DataView}
- `input_encoding` {string}
- `output_encoding` {string}
- `inputEncoding` {string}
- `outputEncoding` {string}

Updates the cipher with `data`. If the `input_encoding` argument is given,
Updates the cipher with `data`. If the `inputEncoding` argument is given,
its value must be one of `'utf8'`, `'ascii'`, or `'latin1'` and the `data`
argument is a string using the specified encoding. If the `input_encoding`
argument is a string using the specified encoding. If the `inputEncoding`
argument is not given, `data` must be a [`Buffer`][], `TypedArray`, or
`DataView`. If `data` is a [`Buffer`][], `TypedArray`, or `DataView`, then
`input_encoding` is ignored.
`inputEncoding` is ignored.

The `output_encoding` specifies the output format of the enciphered
data, and can be `'latin1'`, `'base64'` or `'hex'`. If the `output_encoding`
The `outputEncoding` specifies the output format of the enciphered
data, and can be `'latin1'`, `'base64'` or `'hex'`. If the `outputEncoding`
is specified, a string using the specified encoding is returned. If no
`output_encoding` is provided, a [`Buffer`][] is returned.
`outputEncoding` is provided, a [`Buffer`][] is returned.

The `cipher.update()` method can be called multiple times with new data until
[`cipher.final()`][] is called. Calling `cipher.update()` after
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ changes:
from `binary` to `utf8`.
-->
- `prime` {string | Buffer | TypedArray | DataView}
- `prime_encoding` {string}
- `primeEncoding` {string}
- `generator` {number | string | Buffer | TypedArray | DataView} Defaults to `2`.
- `generator_encoding` {string}
- `generatorEncoding` {string}

Creates a `DiffieHellman` key exchange object using the supplied `prime` and an
optional specific `generator`.

The `generator` argument can be a number, string, or [`Buffer`][]. If
`generator` is not specified, the value `2` is used.

The `prime_encoding` and `generator_encoding` arguments can be `'latin1'`,
The `primeEncoding` and `generatorEncoding` arguments can be `'latin1'`,
`'hex'`, or `'base64'`.

If `prime_encoding` is specified, `prime` is expected to be a string; otherwise
If `primeEncoding` is specified, `prime` is expected to be a string; otherwise
a [`Buffer`][], `TypedArray`, or `DataView` is expected.

If `generator_encoding` is specified, `generator` is expected to be a string;
If `generatorEncoding` is specified, `generator` is expected to be a string;
otherwise a number, [`Buffer`][], `TypedArray`, or `DataView` is expected.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!-- YAML
added: v0.5.0
-->
- `prime_length` {number}
- `primeLength` {number}
- `generator` {number | string | Buffer | TypedArray | DataView} Defaults to `2`.

Creates a `DiffieHellman` key exchange object and generates a prime of
`prime_length` bits using an optional specific numeric `generator`.
`primeLength` bits using an optional specific numeric `generator`.
If `generator` is not specified, the value `2` is used.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!-- YAML
added: v0.11.14
-->
- `curve_name` {string}
- `curveName` {string}

Creates an Elliptic Curve Diffie-Hellman (`ECDH`) key exchange object using a
predefined curve specified by the `curve_name` string. Use
predefined curve specified by the `curveName` string. Use
[`crypto.getCurves()`][] to obtain a list of available curve names. On recent
OpenSSL releases, `openssl ecparam -list_curves` will also display the name
and description of each available elliptic curve.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- YAML
added: v0.7.5
-->
- `group_name` {string}
- `groupName` {string}

Creates a predefined `DiffieHellman` key exchange object. The
supported groups are: `'modp1'`, `'modp2'`, `'modp5'` (defined in
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<!-- YAML
added: v0.11.14
-->
- `private_key` {Object | string}
- `privateKey` {Object | string}
- `key` {string} A PEM encoded private key.
- `passphrase` {string} An optional passphrase for the private key.
- `padding` {crypto.constants} An optional padding value defined in
`crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING`,
`RSA_PKCS1_PADDING`, or `crypto.constants.RSA_PKCS1_OAEP_PADDING`.
- `buffer` {Buffer | TypedArray | DataView}

Decrypts `buffer` with `private_key`.
Decrypts `buffer` with `privateKey`.

`private_key` can be an object or a string. If `private_key` is a string, it is
`privateKey` can be an object or a string. If `privateKey` is a string, it is
treated as the key with no passphrase and will use `RSA_PKCS1_OAEP_PADDING`.

Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<!-- YAML
added: v1.1.0
-->
- `private_key` {Object | string}
- `privateKey` {Object | string}
- `key` {string} A PEM encoded private key.
- `passphrase` {string} An optional passphrase for the private key.
- `padding` {crypto.constants} An optional padding value defined in
`crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING` or
`RSA_PKCS1_PADDING`.
- `buffer` {Buffer | TypedArray | DataView}

Encrypts `buffer` with `private_key`.
Encrypts `buffer` with `privateKey`.

`private_key` can be an object or a string. If `private_key` is a string, it is
`privateKey` can be an object or a string. If `privateKey` is a string, it is
treated as the key with no passphrase and will use `RSA_PKCS1_PADDING`.

Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<!-- YAML
added: v1.1.0
-->
- `public_key` {Object | string}
- `publicKey` {Object | string}
- `key` {string} A PEM encoded private key.
- `passphrase` {string} An optional passphrase for the private key.
- `padding` {crypto.constants} An optional padding value defined in
`crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING`,
`RSA_PKCS1_PADDING`, or `crypto.constants.RSA_PKCS1_OAEP_PADDING`.
- `buffer` {Buffer | TypedArray | DataView}

Decrypts `buffer` with `public_key`.
Decrypts `buffer` with `publicKey`.

`public_key` can be an object or a string. If `public_key` is a string, it is
`publicKey` can be an object or a string. If `publicKey` is a string, it is
treated as the key with no passphrase and will use `RSA_PKCS1_PADDING`.

Because RSA public keys can be derived from private keys, a private key may
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<!-- YAML
added: v0.11.14
-->
- `public_key` {Object | string}
- `publicKey` {Object | string}
- `key` {string} A PEM encoded private key.
- `passphrase` {string} An optional passphrase for the private key.
- `padding` {crypto.constants} An optional padding value defined in
`crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING`,
`RSA_PKCS1_PADDING`, or `crypto.constants.RSA_PKCS1_OAEP_PADDING`.
- `buffer` {Buffer | TypedArray | DataView}

Encrypts the content of `buffer` with `public_key` and returns a new
Encrypts the content of `buffer` with `publicKey` and returns a new
[`Buffer`][] with encrypted content.

`public_key` can be an object or a string. If `public_key` is a string, it is
`publicKey` can be an object or a string. If `publicKey` is a string, it is
treated as the key with no passphrase and will use `RSA_PKCS1_OAEP_PADDING`.

Because RSA public keys can be derived from private keys, a private key may
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<!-- YAML
added: v0.1.94
-->
- `output_encoding` {string}
- `outputEncoding` {string}

Returns any remaining deciphered contents. If `output_encoding`
Returns any remaining deciphered contents. If `outputEncoding`
parameter is one of `'latin1'`, `'ascii'` or `'utf8'`, a string is returned.
If an `output_encoding` is not provided, a [`Buffer`][] is returned.
If an `outputEncoding` is not provided, a [`Buffer`][] is returned.

Once the `decipher.final()` method has been called, the `Decipher` object can
no longer be used to decrypt data. Attempts to call `decipher.final()` more
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- YAML
added: v0.7.1
-->
- `auto_padding` {boolean} Defaults to `true`.
- `autoPadding` {boolean} Defaults to `true`.
- Returns the {Cipher} for method chaining.

When data has been encrypted without standard block padding, calling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ added: v0.1.94
changes:
- version: v6.0.0
pr-url: https://github.com/nodejs/node/pull/5522
description: The default `input_encoding` changed from `binary` to `utf8`.
description: The default `inputEncoding` changed from `binary` to `utf8`.
-->
- `data` {string | Buffer | TypedArray | DataView}
- `input_encoding` {string}
- `output_encoding` {string}
- `inputEncoding` {string}
- `outputEncoding` {string}

Updates the decipher with `data`. If the `input_encoding` argument is given,
Updates the decipher with `data`. If the `inputEncoding` argument is given,
its value must be one of `'latin1'`, `'base64'`, or `'hex'` and the `data`
argument is a string using the specified encoding. If the `input_encoding`
argument is a string using the specified encoding. If the `inputEncoding`
argument is not given, `data` must be a [`Buffer`][]. If `data` is a
[`Buffer`][] then `input_encoding` is ignored.
[`Buffer`][] then `inputEncoding` is ignored.

The `output_encoding` specifies the output format of the enciphered
data, and can be `'latin1'`, `'ascii'` or `'utf8'`. If the `output_encoding`
The `outputEncoding` specifies the output format of the enciphered
data, and can be `'latin1'`, `'ascii'` or `'utf8'`. If the `outputEncoding`
is specified, a string using the specified encoding is returned. If no
`output_encoding` is provided, a [`Buffer`][] is returned.
`outputEncoding` is provided, a [`Buffer`][] is returned.

The `decipher.update()` method can be called multiple times with new data until
[`decipher.final()`][] is called. Calling `decipher.update()` after
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- YAML
added: v0.5.0
-->
- `otherPublicKey` {string | Buffer | TypedArray | DataView}
- `inputEncoding` {string}
- `outputEncoding` {string}

Computes the shared secret using `otherPublicKey` as the other
party's public key and returns the computed shared secret. The supplied
key is interpreted using the specified `inputEncoding`, and secret is
encoded using specified `outputEncoding`. Encodings can be
`'latin1'`, `'hex'`, or `'base64'`. If the `inputEncoding` is not
provided, `otherPublicKey` is expected to be a [`Buffer`][],
`TypedArray`, or `DataView`.

If `outputEncoding` is given a string is returned; otherwise, a
[`Buffer`][] is returned.

11 changes: 0 additions & 11 deletions crypto/diffiehellman_setprivatekey_private_key_encoding.md

This file was deleted.

11 changes: 11 additions & 0 deletions crypto/diffiehellman_setprivatekey_privatekey_encoding.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- YAML
added: v0.5.0
-->
- `privateKey` {string | Buffer | TypedArray | DataView}
- `encoding` {string}

Sets the Diffie-Hellman private key. If the `encoding` argument is provided
and is either `'latin1'`, `'hex'`, or `'base64'`, `privateKey` is expected
to be a string. If no `encoding` is provided, `privateKey` is expected
to be a [`Buffer`][], `TypedArray`, or `DataView`.

Loading

0 comments on commit 4e739a0

Please sign in to comment.