The full dataset viewer is not available (click to read why). Only showing a preview of the rows.
Error code: DatasetGenerationCastError
Exception: DatasetGenerationCastError
Message: An error occurred while generating the dataset
All the data files must have the same columns, but at some point there are 4 new columns ({'name', 'parent', 'metadata', 'id'}) and 6 missing columns ({'source_file', 'module_name', 'methods_count', 'events_count', 'properties_count', 'content'}).
This happened while the json dataset builder was generating data using
hf://datasets/Aptlantis/nodejs-all.json/nodejs_granular.jsonl (at revision 1247cc36a89cc104a30319f693b01616953e6e4d), [/tmp/hf-datasets-cache/medium/datasets/80555121944970-config-parquet-and-info-Aptlantis-nodejs-all-json-43603334/hub/datasets--Aptlantis--nodejs-all.json/snapshots/1247cc36a89cc104a30319f693b01616953e6e4d/nodejs_documents.jsonl (origin=hf://datasets/Aptlantis/nodejs-all.json@1247cc36a89cc104a30319f693b01616953e6e4d/nodejs_documents.jsonl), /tmp/hf-datasets-cache/medium/datasets/80555121944970-config-parquet-and-info-Aptlantis-nodejs-all-json-43603334/hub/datasets--Aptlantis--nodejs-all.json/snapshots/1247cc36a89cc104a30319f693b01616953e6e4d/nodejs_granular.jsonl (origin=hf://datasets/Aptlantis/nodejs-all.json@1247cc36a89cc104a30319f693b01616953e6e4d/nodejs_granular.jsonl)]
Please either edit the data files to have matching columns, or separate them into different configurations (see docs at https://hf.co/docs/hub/datasets-manual-configuration#multiple-configurations)
Traceback: Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 1887, in _prepare_split_single
writer.write_table(table)
File "/usr/local/lib/python3.12/site-packages/datasets/arrow_writer.py", line 674, in write_table
pa_table = table_cast(pa_table, self._schema)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/datasets/table.py", line 2272, in table_cast
return cast_table_to_schema(table, schema)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/datasets/table.py", line 2218, in cast_table_to_schema
raise CastError(
datasets.table.CastError: Couldn't cast
id: string
type: string
parent: string
name: string
description: string
metadata: string
to
{'source_file': Value('string'), 'module_name': Value('string'), 'type': Value('string'), 'description': Value('string'), 'methods_count': Value('int64'), 'properties_count': Value('int64'), 'events_count': Value('int64'), 'content': Value('string')}
because column names don't match
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1347, in compute_config_parquet_and_info_response
parquet_operations = convert_to_parquet(builder)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 980, in convert_to_parquet
builder.download_and_prepare(
File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 884, in download_and_prepare
self._download_and_prepare(
File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 947, in _download_and_prepare
self._prepare_split(split_generator, **prepare_split_kwargs)
File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 1736, in _prepare_split
for job_id, done, content in self._prepare_split_single(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 1889, in _prepare_split_single
raise DatasetGenerationCastError.from_cast_error(
datasets.exceptions.DatasetGenerationCastError: An error occurred while generating the dataset
All the data files must have the same columns, but at some point there are 4 new columns ({'name', 'parent', 'metadata', 'id'}) and 6 missing columns ({'source_file', 'module_name', 'methods_count', 'events_count', 'properties_count', 'content'}).
This happened while the json dataset builder was generating data using
hf://datasets/Aptlantis/nodejs-all.json/nodejs_granular.jsonl (at revision 1247cc36a89cc104a30319f693b01616953e6e4d), [/tmp/hf-datasets-cache/medium/datasets/80555121944970-config-parquet-and-info-Aptlantis-nodejs-all-json-43603334/hub/datasets--Aptlantis--nodejs-all.json/snapshots/1247cc36a89cc104a30319f693b01616953e6e4d/nodejs_documents.jsonl (origin=hf://datasets/Aptlantis/nodejs-all.json@1247cc36a89cc104a30319f693b01616953e6e4d/nodejs_documents.jsonl), /tmp/hf-datasets-cache/medium/datasets/80555121944970-config-parquet-and-info-Aptlantis-nodejs-all-json-43603334/hub/datasets--Aptlantis--nodejs-all.json/snapshots/1247cc36a89cc104a30319f693b01616953e6e4d/nodejs_granular.jsonl (origin=hf://datasets/Aptlantis/nodejs-all.json@1247cc36a89cc104a30319f693b01616953e6e4d/nodejs_granular.jsonl)]
Please either edit the data files to have matching columns, or separate them into different configurations (see docs at https://hf.co/docs/hub/datasets-manual-configuration#multiple-configurations)Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.
source_file
string | module_name
string | type
string | description
string | methods_count
int64 | properties_count
int64 | events_count
int64 | content
string |
|---|---|---|---|---|---|---|---|
doc/api/all.markdown
|
timers
|
module
|
<p>All of the timer functions are globals. You do not need to <code>require()</code>
this module in order to use them.
</p>
| 8
| 0
| 0
|
{"description": "<p>All of the timer functions are globals. You do not need to <code>require()</code>\nthis module in order to use them.\n\n</p>\n", "methods": [{"type": "method", "module": "timers", "name": "setTimeout", "description": "<p>To schedule execution of a one-time <code>callback</code> after <code>delay</code> milliseconds. Returns a\n<code>timeoutId</code> for possible use with <code>clearTimeout()</code>. Optionally you can\nalso pass arguments to the callback.\n\n</p>\n<p>It is important to note that your callback will probably not be called in exactly\n<code>delay</code> milliseconds - Node.js makes no guarantees about the exact timing of when\nthe callback will fire, nor of the ordering things will fire in. The callback will\nbe called as close as possible to the time specified.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"callback\"}, {\"name\": \"delay\"}, {\"name\": \"arg\", \"optional\": true}, {\"name\": \"...\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "timers", "name": "clearTimeout", "description": "<p>Prevents a timeout from triggering.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"timeoutId\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "timers", "name": "setInterval", "description": "<p>To schedule the repeated execution of <code>callback</code> every <code>delay</code> milliseconds.\nReturns a <code>intervalId</code> for possible use with <code>clearInterval()</code>. Optionally\nyou can also pass arguments to the callback.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"callback\"}, {\"name\": \"delay\"}, {\"name\": \"arg\", \"optional\": true}, {\"name\": \"...\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "timers", "name": "clearInterval", "description": "<p>Stops a interval from triggering.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"intervalId\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "timers", "name": "unref", "description": "<p>The opaque value returned by <code>setTimeout</code> and <code>setInterval</code> also has the method\n<code>timer.unref()</code> which will allow you to create a timer that is active but if\nit is the only item left in the event loop won't keep the program running.\nIf the timer is already <code>unref</code>d calling <code>unref</code> again will have no effect.\n\n</p>\n<p>In the case of <code>setTimeout</code> when you <code>unref</code> you create a separate timer that\nwill wakeup the event loop, creating too many of these may adversely effect\nevent loop performance -- use wisely.\n\n</p>\n", "signatures": "[{\"params\": []}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "timers", "name": "ref", "description": "<p>If you had previously <code>unref()</code>d a timer you can call <code>ref()</code> to explicitly\nrequest the timer hold the program open. If the timer is already <code>ref</code>d calling\n<code>ref</code> again will have no effect.\n\n</p>\n", "signatures": "[{\"params\": []}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "timers", "name": "setImmediate", "description": "<p>To schedule the "immediate" execution of <code>callback</code> after I/O events\ncallbacks and before <code>setTimeout</code> and <code>setInterval</code> . Returns an\n<code>immediateId</code> for possible use with <code>clearImmediate()</code>. Optionally you\ncan also pass arguments to the callback.\n\n</p>\n<p>Immediates are queued in the order created, and are popped off the queue once\nper loop iteration. This is different from <code>process.nextTick</code> which will\nexecute <code>process.maxTickDepth</code> queued callbacks per iteration. <code>setImmediate</code>\nwill yield to the event loop after firing a queued callback to make sure I/O is\nnot being starved. While order is preserved for execution, other I/O events may\nfire between any two scheduled immediate callbacks.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"callback\"}, {\"name\": \"arg\", \"optional\": true}, {\"name\": \"...\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "timers", "name": "clearImmediate", "description": "<p>Stops an immediate from triggering.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"immediateId\"}]}]", "stability": null, "stabilityText": null}], "properties": [], "events": []}
|
doc/api/all.markdown
|
module
|
module
|
<p>Node has a simple module loading system. In Node, files and modules are in
one-to-one correspondence. As an example, <code>foo.js</code> loads the module
<code>circle.js</code> in the same directory.
</p>
<p>The contents of <code>foo.js</code>:
</p>
<pre><code>var circle = require('./circle.js');
console.log( 'The area of a circle of radius 4 is '
+ circle.area(4));</code></pre>
<p>The contents of <code>circle.js</code>:
</p>
<pre><code>var PI = Math.PI;
exports.area = function (r) {
return PI * r * r;
};
exports.circumference = function (r) {
return 2 * PI * r;
};</code></pre>
<p>The module <code>circle.js</code> has exported the functions <code>area()</code> and
<code>circumference()</code>. To export an object, add to the special <code>exports</code>
object.
</p>
<p>Variables
local to the module will be private. In this example the variable <code>PI</code> is
private to <code>circle.js</code>.
</p>
<p>The module system is implemented in the <code>require("module")</code> module.
</p>
| 0
| 0
| 0
|
{"description": "<p>Node has a simple module loading system. In Node, files and modules are in\none-to-one correspondence. As an example, <code>foo.js</code> loads the module\n<code>circle.js</code> in the same directory.\n\n</p>\n<p>The contents of <code>foo.js</code>:\n\n</p>\n<pre><code>var circle = require('./circle.js');\nconsole.log( 'The area of a circle of radius 4 is '\n + circle.area(4));</code></pre>\n<p>The contents of <code>circle.js</code>:\n\n</p>\n<pre><code>var PI = Math.PI;\n\nexports.area = function (r) {\n return PI * r * r;\n};\n\nexports.circumference = function (r) {\n return 2 * PI * r;\n};</code></pre>\n<p>The module <code>circle.js</code> has exported the functions <code>area()</code> and\n<code>circumference()</code>. To export an object, add to the special <code>exports</code>\nobject.\n\n</p>\n<p>Variables\nlocal to the module will be private. In this example the variable <code>PI</code> is\nprivate to <code>circle.js</code>.\n\n</p>\n<p>The module system is implemented in the <code>require("module")</code> module.\n\n</p>\n", "methods": [], "properties": [], "events": []}
|
doc/api/all.markdown
|
addons
|
module
|
<p>Addons are dynamically linked shared objects. They can provide glue to C and
C++ libraries. The API (at the moment) is rather complex, involving
knowledge of several libraries:
</p>
<ul>
<li><p>V8 JavaScript, a C++ library. Used for interfacing with JavaScript:
creating objects, calling functions, etc. Documented mostly in the
<code>v8.h</code> header file (<code>deps/v8/include/v8.h</code> in the Node source
tree), which is also available
<a href="http://izs.me/v8-docs/main.html">online</a>.</p>
</li>
<li><p><a href="https://github.com/joyent/libuv">libuv</a>, C event loop library.
Anytime one needs to wait for a file descriptor to become readable,
wait for a timer, or wait for a signal to received one will need to
interface with libuv. That is, if you perform any I/O, libuv will
need to be used.</p>
</li>
<li><p>Internal Node libraries. Most importantly is the <code>node::ObjectWrap</code>
class which you will likely want to derive from.</p>
</li>
<li><p>Others. Look in <code>deps/</code> for what else is available.</p>
</li>
</ul>
<p>Node statically compiles all its dependencies into the executable.
When compiling your module, you don't need to worry about linking to
any of these libraries.
</p>
<p>All of the following examples are available for
<a href="https://github.com/rvagg/node-addon-examples">download</a> and may be
used as a starting-point for your own Addon.
</p>
| 0
| 0
| 0
|
{"description": "<p>Addons are dynamically linked shared objects. They can provide glue to C and\nC++ libraries. The API (at the moment) is rather complex, involving\nknowledge of several libraries:\n\n</p>\n<ul>\n<li><p>V8 JavaScript, a C++ library. Used for interfacing with JavaScript:\ncreating objects, calling functions, etc. Documented mostly in the\n<code>v8.h</code> header file (<code>deps/v8/include/v8.h</code> in the Node source\ntree), which is also available\n<a href=\"http://izs.me/v8-docs/main.html\">online</a>.</p>\n</li>\n<li><p><a href=\"https://github.com/joyent/libuv\">libuv</a>, C event loop library.\nAnytime one needs to wait for a file descriptor to become readable,\nwait for a timer, or wait for a signal to received one will need to\ninterface with libuv. That is, if you perform any I/O, libuv will\nneed to be used.</p>\n</li>\n<li><p>Internal Node libraries. Most importantly is the <code>node::ObjectWrap</code>\nclass which you will likely want to derive from.</p>\n</li>\n<li><p>Others. Look in <code>deps/</code> for what else is available.</p>\n</li>\n</ul>\n<p>Node statically compiles all its dependencies into the executable.\nWhen compiling your module, you don't need to worry about linking to\nany of these libraries.\n\n</p>\n<p>All of the following examples are available for\n<a href=\"https://github.com/rvagg/node-addon-examples\">download</a> and may be\nused as a starting-point for your own Addon.\n\n</p>\n", "methods": [], "properties": [], "events": []}
|
doc/api/all.markdown
|
util
|
module
|
<p>These functions are in the module <code>'util'</code>. Use <code>require('util')</code> to access
them.
</p>
| 13
| 0
| 0
|
{"description": "<p>These functions are in the module <code>'util'</code>. Use <code>require('util')</code> to access\nthem.\n\n\n</p>\n", "methods": [{"type": "method", "module": "util", "name": "format", "description": "<p>Returns a formatted string using the first argument as a <code>printf</code>-like format.\n\n</p>\n<p>The first argument is a string that contains zero or more <em>placeholders</em>.\nEach placeholder is replaced with the converted value from its corresponding\nargument. Supported placeholders are:\n\n</p>\n<ul>\n<li><code>%s</code> - String.</li>\n<li><code>%d</code> - Number (both integer and float).</li>\n<li><code>%j</code> - JSON.</li>\n<li><code>%</code> - single percent sign (<code>'%'</code>). This does not consume an argument.</li>\n</ul>\n<p>If the placeholder does not have a corresponding argument, the placeholder is\nnot replaced.\n\n</p>\n<pre><code>util.format('%s:%s', 'foo'); // 'foo:%s'</code></pre>\n<p>If there are more arguments than placeholders, the extra arguments are\nconverted to strings with <code>util.inspect()</code> and these strings are concatenated,\ndelimited by a space.\n\n</p>\n<pre><code>util.format('%s:%s', 'foo', 'bar', 'baz'); // 'foo:bar baz'</code></pre>\n<p>If the first argument is not a format string then <code>util.format()</code> returns\na string that is the concatenation of all its arguments separated by spaces.\nEach argument is converted to a string with <code>util.inspect()</code>.\n\n</p>\n<pre><code>util.format(1, 2, 3); // '1 2 3'</code></pre>\n", "signatures": "[{\"params\": [{\"name\": \"format\"}, {\"name\": \"...\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "util", "name": "debug", "description": "<p>A synchronous output function. Will block the process and\noutput <code>string</code> immediately to <code>stderr</code>.\n\n</p>\n<pre><code>require('util').debug('message on stderr');</code></pre>\n", "signatures": "[{\"params\": [{\"name\": \"string\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "util", "name": "error", "description": "<p>Same as <code>util.debug()</code> except this will output all arguments immediately to\n<code>stderr</code>.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"...\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "util", "name": "puts", "description": "<p>A synchronous output function. Will block the process and output all arguments\nto <code>stdout</code> with newlines after each argument.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"...\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "util", "name": "print", "description": "<p>A synchronous output function. Will block the process, cast each argument to a\nstring then output to <code>stdout</code>. Does not place newlines after each argument.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"...\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "util", "name": "log", "description": "<p>Output with timestamp on <code>stdout</code>.\n\n</p>\n<pre><code>require('util').log('Timestamped message.');</code></pre>\n", "signatures": "[{\"params\": [{\"name\": \"string\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "util", "name": "inspect", "description": "<p>Return a string representation of <code>object</code>, which is useful for debugging.\n\n</p>\n<p>An optional <em>options</em> object may be passed that alters certain aspects of the\nformatted string:\n\n</p>\n<ul>\n<li><p><code>showHidden</code> - if <code>true</code> then the object's non-enumerable properties will be\nshown too. Defaults to <code>false</code>.</p>\n</li>\n<li><p><code>depth</code> - tells <code>inspect</code> how many times to recurse while formatting the\nobject. This is useful for inspecting large complicated objects. Defaults to\n<code>2</code>. To make it recurse indefinitely pass <code>null</code>.</p>\n</li>\n<li><p><code>colors</code> - if <code>true</code>, then the output will be styled with ANSI color codes.\nDefaults to <code>false</code>. Colors are customizable, see below.</p>\n</li>\n<li><p><code>customInspect</code> - if <code>false</code>, then custom <code>inspect()</code> functions defined on the\nobjects being inspected won't be called. Defaults to <code>true</code>.</p>\n</li>\n</ul>\n<p>Example of inspecting all properties of the <code>util</code> object:\n\n</p>\n<pre><code>var util = require('util');\n\nconsole.log(util.inspect(util, { showHidden: true, depth: null }));</code></pre>\n", "signatures": "[{\"params\": [{\"name\": \"object\"}, {\"name\": \"options\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "util", "name": "isArray", "description": "<p>Returns <code>true</code> if the given "object" is an <code>Array</code>. <code>false</code> otherwise.\n\n</p>\n<pre><code>var util = require('util');\n\nutil.isArray([])\n // true\nutil.isArray(new Array)\n // true\nutil.isArray({})\n // false</code></pre>\n", "signatures": "[{\"params\": [{\"name\": \"object\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "util", "name": "isRegExp", "description": "<p>Returns <code>true</code> if the given "object" is a <code>RegExp</code>. <code>false</code> otherwise.\n\n</p>\n<pre><code>var util = require('util');\n\nutil.isRegExp(/some regexp/)\n // true\nutil.isRegExp(new RegExp('another regexp'))\n // true\nutil.isRegExp({})\n // false</code></pre>\n", "signatures": "[{\"params\": [{\"name\": \"object\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "util", "name": "isDate", "description": "<p>Returns <code>true</code> if the given "object" is a <code>Date</code>. <code>false</code> otherwise.\n\n</p>\n<pre><code>var util = require('util');\n\nutil.isDate(new Date())\n // true\nutil.isDate(Date())\n // false (without 'new' returns a String)\nutil.isDate({})\n // false</code></pre>\n", "signatures": "[{\"params\": [{\"name\": \"object\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "util", "name": "isError", "description": "<p>Returns <code>true</code> if the given "object" is an <code>Error</code>. <code>false</code> otherwise.\n\n</p>\n<pre><code>var util = require('util');\n\nutil.isError(new Error())\n // true\nutil.isError(new TypeError())\n // true\nutil.isError({ name: 'Error', message: 'an error occurred' })\n // false</code></pre>\n", "signatures": "[{\"params\": [{\"name\": \"object\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "util", "name": "pump", "description": "<p>Read the data from <code>readableStream</code> and send it to the <code>writableStream</code>.\nWhen <code>writableStream.write(data)</code> returns <code>false</code> <code>readableStream</code> will be\npaused until the <code>drain</code> event occurs on the <code>writableStream</code>. <code>callback</code> gets\nan error as its only argument and is called when <code>writableStream</code> is closed or\nwhen an error occurs.\n\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"readableStream\"}, {\"name\": \"writableStream\"}, {\"name\": \"callback\", \"optional\": true}]}]", "stability": 0, "stabilityText": "Deprecated: Use readableStream.pipe(writableStream)"}, {"type": "method", "module": "util", "name": "inherits", "description": "<p>Inherit the prototype methods from one\n<a href=\"https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/constructor\">constructor</a>\ninto another. The prototype of <code>constructor</code> will be set to a new\nobject created from <code>superConstructor</code>.\n\n</p>\n<p>As an additional convenience, <code>superConstructor</code> will be accessible\nthrough the <code>constructor.super_</code> property.\n\n</p>\n<pre><code>var util = require("util");\nvar events = require("events");\n\nfunction MyStream() {\n events.EventEmitter.call(this);\n}\n\nutil.inherits(MyStream, events.EventEmitter);\n\nMyStream.prototype.write = function(data) {\n this.emit("data", data);\n}\n\nvar stream = new MyStream();\n\nconsole.log(stream instanceof events.EventEmitter); // true\nconsole.log(MyStream.super_ === events.EventEmitter); // true\n\nstream.on("data", function(data) {\n console.log('Received data: "' + data + '"');\n})\nstream.write("It works!"); // Received data: "It works!"</code></pre>\n", "signatures": "[{\"params\": [{\"name\": \"constructor\"}, {\"name\": \"superConstructor\"}]}]", "stability": null, "stabilityText": null}], "properties": [], "events": []}
|
doc/api/all.markdown
|
Events
|
module
|
<p>Many objects in Node emit events: a <code>net.Server</code> emits an event each time
a peer connects to it, a <code>fs.readStream</code> emits an event when the file is
opened. All objects which emit events are instances of <code>events.EventEmitter</code>.
You can access this module by doing: <code>require("events");</code>
</p>
<p>Typically, event names are represented by a camel-cased string, however,
there aren't any strict restrictions on that, as any string will be accepted.
</p>
<p>Functions can then be attached to objects, to be executed when an event
is emitted. These functions are called <em>listeners</em>.
</p>
| 8
| 0
| 1
|
{"description": "<p>Many objects in Node emit events: a <code>net.Server</code> emits an event each time\na peer connects to it, a <code>fs.readStream</code> emits an event when the file is\nopened. All objects which emit events are instances of <code>events.EventEmitter</code>.\nYou can access this module by doing: <code>require("events");</code>\n\n</p>\n<p>Typically, event names are represented by a camel-cased string, however,\nthere aren't any strict restrictions on that, as any string will be accepted.\n\n</p>\n<p>Functions can then be attached to objects, to be executed when an event\nis emitted. These functions are called <em>listeners</em>.\n\n\n</p>\n", "methods": [{"type": "method", "module": "Events.events.EventEmitter", "name": "addListener", "description": "<p>Adds a listener to the end of the listeners array for the specified event.\n\n</p>\n<pre><code>server.on('connection', function (stream) {\n console.log('someone connected!');\n});</code></pre>\n", "signatures": "[{\"params\": [{\"name\": \"event\"}, {\"name\": \"listener\"}]}, {\"params\": [{\"name\": \"event\"}, {\"name\": \"listener\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "Events.events.EventEmitter", "name": "on", "description": "<p>Adds a listener to the end of the listeners array for the specified event.\n\n</p>\n<pre><code>server.on('connection', function (stream) {\n console.log('someone connected!');\n});</code></pre>\n", "signatures": "[{\"params\": [{\"name\": \"event\"}, {\"name\": \"listener\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "Events.events.EventEmitter", "name": "once", "description": "<p>Adds a <strong>one time</strong> listener for the event. This listener is\ninvoked only the next time the event is fired, after which\nit is removed.\n\n</p>\n<pre><code>server.once('connection', function (stream) {\n console.log('Ah, we have our first user!');\n});</code></pre>\n", "signatures": "[{\"params\": [{\"name\": \"event\"}, {\"name\": \"listener\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "Events.events.EventEmitter", "name": "removeListener", "description": "<p>Remove a listener from the listener array for the specified event.\n<strong>Caution</strong>: changes array indices in the listener array behind the listener.\n\n</p>\n<pre><code>var callback = function(stream) {\n console.log('someone connected!');\n};\nserver.on('connection', callback);\n// ...\nserver.removeListener('connection', callback);</code></pre>\n", "signatures": "[{\"params\": [{\"name\": \"event\"}, {\"name\": \"listener\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "Events.events.EventEmitter", "name": "removeAllListeners", "description": "<p>Removes all listeners, or those of the specified event.\n\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"event\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "Events.events.EventEmitter", "name": "setMaxListeners", "description": "<p>By default EventEmitters will print a warning if more than 10 listeners are\nadded for a particular event. This is a useful default which helps finding memory leaks.\nObviously not all Emitters should be limited to 10. This function allows\nthat to be increased. Set to zero for unlimited.\n\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"n\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "Events.events.EventEmitter", "name": "listeners", "description": "<p>Returns an array of listeners for the specified event.\n\n</p>\n<pre><code>server.on('connection', function (stream) {\n console.log('someone connected!');\n});\nconsole.log(util.inspect(server.listeners('connection'))); // [ [Function] ]</code></pre>\n", "signatures": "[{\"params\": [{\"name\": \"event\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "Events.events.EventEmitter", "name": "emit", "description": "<p>Execute each of the listeners in order with the supplied arguments.\n\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"event\"}, {\"name\": \"arg1\", \"optional\": true}, {\"name\": \"arg2\", \"optional\": true}, {\"name\": \"...\", \"optional\": true}]}]", "stability": null, "stabilityText": null}], "properties": [], "events": [{"type": "event", "module": "Events.events.EventEmitter", "name": "newListener", "description": "<p>This event is emitted any time someone adds a new listener.\n\n</p>\n", "params": "[]"}]}
|
doc/api/all.markdown
|
domain
|
module
|
<p>Domains provide a way to handle multiple different IO operations as a
single group. If any of the event emitters or callbacks registered to a
domain emit an <code>error</code> event, or throw an error, then the domain object
will be notified, rather than losing the context of the error in the
<code>process.on('uncaughtException')</code> handler, or causing the program to
exit with an error code.
</p>
<p>This feature is new in Node version 0.8. It is a first pass, and is
expected to change significantly in future versions. Please use it and
provide feedback.
</p>
<p>Due to their experimental nature, the Domains features are disabled unless
the <code>domain</code> module is loaded at least once. No domains are created or
registered by default. This is by design, to prevent adverse effects on
current programs. It is expected to be enabled by default in future
Node.js versions.
</p>
| 7
| 1
| 0
|
{"description": "<p>Domains provide a way to handle multiple different IO operations as a\nsingle group. If any of the event emitters or callbacks registered to a\ndomain emit an <code>error</code> event, or throw an error, then the domain object\nwill be notified, rather than losing the context of the error in the\n<code>process.on('uncaughtException')</code> handler, or causing the program to\nexit with an error code.\n\n</p>\n<p>This feature is new in Node version 0.8. It is a first pass, and is\nexpected to change significantly in future versions. Please use it and\nprovide feedback.\n\n</p>\n<p>Due to their experimental nature, the Domains features are disabled unless\nthe <code>domain</code> module is loaded at least once. No domains are created or\nregistered by default. This is by design, to prevent adverse effects on\ncurrent programs. It is expected to be enabled by default in future\nNode.js versions.\n\n</p>\n", "methods": [{"type": "method", "module": "domain", "name": "create", "description": "<p>Returns a new Domain object.\n\n</p>\n", "signatures": "[{\"return\": {\"textRaw\": \"return: {Domain} \", \"name\": \"return\", \"type\": \"Domain\"}, \"params\": []}, {\"params\": []}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "domain.Domain", "name": "run", "description": "<p>Run the supplied function in the context of the domain, implicitly\nbinding all event emitters, timers, and lowlevel requests that are\ncreated in that context.\n\n</p>\n<p>This is the most basic way to use a domain.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code>var d = domain.create();\nd.on('error', function(er) {\n console.error('Caught error!', er);\n});\nd.run(function() {\n process.nextTick(function() {\n setTimeout(function() { // simulating some various async stuff\n fs.open('non-existent file', 'r', function(er, fd) {\n if (er) throw er;\n // proceed...\n });\n }, 100);\n });\n});</code></pre>\n<p>In this example, the <code>d.on('error')</code> handler will be triggered, rather\nthan crashing the program.\n\n</p>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`fn` {Function} \", \"name\": \"fn\", \"type\": \"Function\"}]}, {\"params\": [{\"name\": \"fn\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "domain.Domain", "name": "add", "description": "<p>Explicitly adds an emitter to the domain. If any event handlers called by\nthe emitter throw an error, or if the emitter emits an <code>error</code> event, it\nwill be routed to the domain's <code>error</code> event, just like with implicit\nbinding.\n\n</p>\n<p>This also works with timers that are returned from <code>setInterval</code> and\n<code>setTimeout</code>. If their callback function throws, it will be caught by\nthe domain 'error' handler.\n\n</p>\n<p>If the Timer or EventEmitter was already bound to a domain, it is removed\nfrom that one, and bound to this one instead.\n\n</p>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`emitter` {EventEmitter | Timer} emitter or timer to be added to the domain \", \"name\": \"emitter\", \"type\": \"EventEmitter | Timer\", \"desc\": \"emitter or timer to be added to the domain\"}]}, {\"params\": [{\"name\": \"emitter\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "domain.Domain", "name": "remove", "description": "<p>The opposite of <code>domain.add(emitter)</code>. Removes domain handling from the\nspecified emitter.\n\n</p>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`emitter` {EventEmitter | Timer} emitter or timer to be removed from the domain \", \"name\": \"emitter\", \"type\": \"EventEmitter | Timer\", \"desc\": \"emitter or timer to be removed from the domain\"}]}, {\"params\": [{\"name\": \"emitter\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "domain.Domain", "name": "bind", "description": "<p>The returned function will be a wrapper around the supplied callback\nfunction. When the returned function is called, any errors that are\nthrown will be routed to the domain's <code>error</code> event.\n\n</p>\n<h4>Example</h4>\n<pre><code>var d = domain.create();\n\nfunction readSomeFile(filename, cb) {\n fs.readFile(filename, 'utf8', d.bind(function(er, data) {\n // if this throws, it will also be passed to the domain\n return cb(er, data ? JSON.parse(data) : null);\n }));\n}\n\nd.on('error', function(er) {\n // an error occurred somewhere.\n // if we throw it now, it will crash the program\n // with the normal line number and stack message.\n});</code></pre>\n", "signatures": "[{\"return\": {\"textRaw\": \"return: {Function} The bound function \", \"name\": \"return\", \"type\": \"Function\", \"desc\": \"The bound function\"}, \"params\": [{\"textRaw\": \"`callback` {Function} The callback function \", \"name\": \"callback\", \"type\": \"Function\", \"desc\": \"The callback function\"}]}, {\"params\": [{\"name\": \"callback\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "domain.Domain", "name": "intercept", "description": "<p>This method is almost identical to <code>domain.bind(callback)</code>. However, in\naddition to catching thrown errors, it will also intercept <code>Error</code>\nobjects sent as the first argument to the function.\n\n</p>\n<p>In this way, the common <code>if (er) return callback(er);</code> pattern can be replaced\nwith a single error handler in a single place.\n\n</p>\n<h4>Example</h4>\n<pre><code>var d = domain.create();\n\nfunction readSomeFile(filename, cb) {\n fs.readFile(filename, 'utf8', d.intercept(function(data) {\n // note, the first argument is never passed to the\n // callback since it is assumed to be the 'Error' argument\n // and thus intercepted by the domain.\n\n // if this throws, it will also be passed to the domain\n // so the error-handling logic can be moved to the 'error'\n // event on the domain instead of being repeated throughout\n // the program.\n return cb(null, JSON.parse(data));\n }));\n}\n\nd.on('error', function(er) {\n // an error occurred somewhere.\n // if we throw it now, it will crash the program\n // with the normal line number and stack message.\n});</code></pre>\n", "signatures": "[{\"return\": {\"textRaw\": \"return: {Function} The intercepted function \", \"name\": \"return\", \"type\": \"Function\", \"desc\": \"The intercepted function\"}, \"params\": [{\"textRaw\": \"`callback` {Function} The callback function \", \"name\": \"callback\", \"type\": \"Function\", \"desc\": \"The callback function\"}]}, {\"params\": [{\"name\": \"callback\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "domain.Domain", "name": "dispose", "description": "<p>The dispose method destroys a domain, and makes a best effort attempt to\nclean up any and all IO that is associated with the domain. Streams are\naborted, ended, closed, and/or destroyed. Timers are cleared.\nExplicitly bound callbacks are no longer called. Any error events that\nare raised as a result of this are ignored.\n\n</p>\n<p>The intention of calling <code>dispose</code> is generally to prevent cascading\nerrors when a critical part of the Domain context is found to be in an\nerror state.\n\n</p>\n<p>Once the domain is disposed the <code>dispose</code> event will emit.\n\n</p>\n<p>Note that IO might still be performed. However, to the highest degree\npossible, once a domain is disposed, further errors from the emitters in\nthat set will be ignored. So, even if some remaining actions are still\nin flight, Node.js will not communicate further about them.\n\n</p>\n", "signatures": "[{\"params\": []}]", "stability": null, "stabilityText": null}], "properties": [{"type": "property", "module": "domain.Domain", "name": "members", "description": "<p>An array of timers and event emitters that have been explicitly added\nto the domain.\n\n</p>\n", "stability": null, "stabilityText": null}], "events": []}
|
doc/api/all.markdown
|
buffer
|
module
|
<p>Pure JavaScript is Unicode friendly but not nice to binary data. When
dealing with TCP streams or the file system, it's necessary to handle octet
streams. Node has several strategies for manipulating, creating, and
consuming octet streams.
</p>
<p>Raw data is stored in instances of the <code>Buffer</code> class. A <code>Buffer</code> is similar
to an array of integers but corresponds to a raw memory allocation outside
the V8 heap. A <code>Buffer</code> cannot be resized.
</p>
<p>The <code>Buffer</code> class is a global, making it very rare that one would need
to ever <code>require('buffer')</code>.
</p>
<p>Converting between Buffers and JavaScript string objects requires an explicit
encoding method. Here are the different string encodings.
</p>
<ul>
<li><p><code>'ascii'</code> - for 7 bit ASCII data only. This encoding method is very fast, and
will strip the high bit if set.</p>
<p>Note that when converting from string to buffer, this encoding converts a null
character (<code>'\0'</code> or <code>'\u0000'</code>) into <code>0x20</code> (character code of a space). If
you want to convert a null character into <code>0x00</code>, you should use <code>'utf8'</code>.</p>
</li>
<li><p><code>'utf8'</code> - Multibyte encoded Unicode characters. Many web pages and other
document formats use UTF-8.</p>
</li>
<li><p><code>'utf16le'</code> - 2 or 4 bytes, little endian encoded Unicode characters.
Surrogate pairs (U+10000 to U+10FFFF) are supported.</p>
</li>
<li><p><code>'ucs2'</code> - Alias of <code>'utf16le'</code>.</p>
</li>
<li><p><code>'base64'</code> - Base64 string encoding.</p>
</li>
<li><p><code>'binary'</code> - A way of encoding raw binary data into strings by using only
the first 8 bits of each character. This encoding method is deprecated and
should be avoided in favor of <code>Buffer</code> objects where possible. This encoding
will be removed in future versions of Node.</p>
</li>
<li><p><code>'hex'</code> - Encode each byte as two hexadecimal characters.</p>
</li>
</ul>
<p>A <code>Buffer</code> object can also be used with typed arrays. The buffer object is
cloned to an <code>ArrayBuffer</code> that is used as the backing store for the typed
array. The memory of the buffer and the <code>ArrayBuffer</code> is not shared.
</p>
<p>NOTE: Node.js v0.8 simply retained a reference to the buffer in <code>array.buffer</code>
instead of cloning it.
</p>
<p>While more efficient, it introduces subtle incompatibilities with the typed
arrays specification. <code>ArrayBuffer#slice()</code> makes a copy of the slice while
<code>Buffer#slice()</code> creates a view.
</p>
| 34
| 3
| 0
|
{"description": "<p>Pure JavaScript is Unicode friendly but not nice to binary data. When\ndealing with TCP streams or the file system, it's necessary to handle octet\nstreams. Node has several strategies for manipulating, creating, and\nconsuming octet streams.\n\n</p>\n<p>Raw data is stored in instances of the <code>Buffer</code> class. A <code>Buffer</code> is similar\nto an array of integers but corresponds to a raw memory allocation outside\nthe V8 heap. A <code>Buffer</code> cannot be resized.\n\n</p>\n<p>The <code>Buffer</code> class is a global, making it very rare that one would need\nto ever <code>require('buffer')</code>.\n\n</p>\n<p>Converting between Buffers and JavaScript string objects requires an explicit\nencoding method. Here are the different string encodings.\n\n</p>\n<ul>\n<li><p><code>'ascii'</code> - for 7 bit ASCII data only. This encoding method is very fast, and\nwill strip the high bit if set.</p>\n<p>Note that when converting from string to buffer, this encoding converts a null\ncharacter (<code>'\\0'</code> or <code>'\\u0000'</code>) into <code>0x20</code> (character code of a space). If\nyou want to convert a null character into <code>0x00</code>, you should use <code>'utf8'</code>.</p>\n</li>\n<li><p><code>'utf8'</code> - Multibyte encoded Unicode characters. Many web pages and other\ndocument formats use UTF-8.</p>\n</li>\n<li><p><code>'utf16le'</code> - 2 or 4 bytes, little endian encoded Unicode characters.\nSurrogate pairs (U+10000 to U+10FFFF) are supported.</p>\n</li>\n<li><p><code>'ucs2'</code> - Alias of <code>'utf16le'</code>.</p>\n</li>\n<li><p><code>'base64'</code> - Base64 string encoding.</p>\n</li>\n<li><p><code>'binary'</code> - A way of encoding raw binary data into strings by using only\nthe first 8 bits of each character. This encoding method is deprecated and\nshould be avoided in favor of <code>Buffer</code> objects where possible. This encoding\nwill be removed in future versions of Node.</p>\n</li>\n<li><p><code>'hex'</code> - Encode each byte as two hexadecimal characters.</p>\n</li>\n</ul>\n<p>A <code>Buffer</code> object can also be used with typed arrays. The buffer object is\ncloned to an <code>ArrayBuffer</code> that is used as the backing store for the typed\narray. The memory of the buffer and the <code>ArrayBuffer</code> is not shared.\n\n</p>\n<p>NOTE: Node.js v0.8 simply retained a reference to the buffer in <code>array.buffer</code>\ninstead of cloning it.\n\n</p>\n<p>While more efficient, it introduces subtle incompatibilities with the typed\narrays specification. <code>ArrayBuffer#slice()</code> makes a copy of the slice while\n<code>Buffer#slice()</code> creates a view.\n\n</p>\n", "methods": [{"type": "method", "module": "buffer.Buffer", "name": "write", "description": "<p>Writes <code>string</code> to the buffer at <code>offset</code> using the given encoding.\n<code>offset</code> defaults to <code>0</code>, <code>encoding</code> defaults to <code>'utf8'</code>. <code>length</code> is\nthe number of bytes to write. Returns number of octets written. If <code>buffer</code> did\nnot contain enough space to fit the entire string, it will write a partial\namount of the string. <code>length</code> defaults to <code>buffer.length - offset</code>.\nThe method will not write partial characters.\n\n</p>\n<pre><code>buf = new Buffer(256);\nlen = buf.write('\\u00bd + \\u00bc = \\u00be', 0);\nconsole.log(len + " bytes: " + buf.toString('utf8', 0, len));</code></pre>\n<p>The number of characters written (which may be different than the number of\nbytes written) is set in <code>Buffer._charsWritten</code> and will be overwritten the\nnext time <code>buf.write()</code> is called.\n\n\n</p>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`string` String - data to be written to buffer \", \"name\": \"string\", \"desc\": \"String - data to be written to buffer\"}, {\"textRaw\": \"`offset` Number, Optional, Default: 0 \", \"name\": \"offset\", \"desc\": \"Number, Optional, Default: 0\", \"optional\": true}, {\"textRaw\": \"`length` Number, Optional, Default: `buffer.length - offset` \", \"name\": \"length\", \"desc\": \"Number, Optional, Default: `buffer.length - offset`\", \"optional\": true}, {\"textRaw\": \"`encoding` String, Optional, Default: 'utf8' \", \"name\": \"encoding\", \"desc\": \"String, Optional, Default: 'utf8'\", \"optional\": true}]}, {\"params\": [{\"name\": \"string\"}, {\"name\": \"offset\", \"optional\": true}, {\"name\": \"length\", \"optional\": true}, {\"name\": \"encoding\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "toString", "description": "<p>Decodes and returns a string from buffer data encoded with <code>encoding</code>\n(defaults to <code>'utf8'</code>) beginning at <code>start</code> (defaults to <code>0</code>) and ending at\n<code>end</code> (defaults to <code>buffer.length</code>).\n\n</p>\n<p>See <code>buffer.write()</code> example, above.\n\n\n</p>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`encoding` String, Optional, Default: 'utf8' \", \"name\": \"encoding\", \"desc\": \"String, Optional, Default: 'utf8'\", \"optional\": true}, {\"textRaw\": \"`start` Number, Optional, Default: 0 \", \"name\": \"start\", \"desc\": \"Number, Optional, Default: 0\", \"optional\": true}, {\"textRaw\": \"`end` Number, Optional, Default: `buffer.length` \", \"name\": \"end\", \"desc\": \"Number, Optional, Default: `buffer.length`\", \"optional\": true}]}, {\"params\": [{\"name\": \"encoding\", \"optional\": true}, {\"name\": \"start\", \"optional\": true}, {\"name\": \"end\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "toJSON", "description": "<p>Returns a JSON-representation of the Buffer instance, which is identical to the\noutput for JSON Arrays. <code>JSON.stringify</code> implicitly calls this function when\nstringifying a Buffer instance.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code>var buf = new Buffer('test');\nvar json = JSON.stringify(buf);\n\nconsole.log(json);\n// '[116,101,115,116]'\n\nvar copy = new Buffer(JSON.parse(json));\n\nconsole.log(copy);\n// <Buffer 74 65 73 74></code></pre>\n", "signatures": "[{\"params\": []}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "copy", "description": "<p>Does copy between buffers. The source and target regions can be overlapped.\n<code>targetStart</code> and <code>sourceStart</code> default to <code>0</code>.\n<code>sourceEnd</code> defaults to <code>buffer.length</code>.\n\n</p>\n<p>All values passed that are <code>undefined</code>/<code>NaN</code> or are out of bounds are set equal\nto their respective defaults.\n\n</p>\n<p>Example: build two Buffers, then copy <code>buf1</code> from byte 16 through byte 19\ninto <code>buf2</code>, starting at the 8th byte in <code>buf2</code>.\n\n</p>\n<pre><code>buf1 = new Buffer(26);\nbuf2 = new Buffer(26);\n\nfor (var i = 0 ; i < 26 ; i++) {\n buf1[i] = i + 97; // 97 is ASCII a\n buf2[i] = 33; // ASCII !\n}\n\nbuf1.copy(buf2, 8, 16, 20);\nconsole.log(buf2.toString('ascii', 0, 25));\n\n// !!!!!!!!qrst!!!!!!!!!!!!!</code></pre>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`targetBuffer` Buffer object - Buffer to copy into \", \"name\": \"targetBuffer\", \"desc\": \"Buffer object - Buffer to copy into\"}, {\"textRaw\": \"`targetStart` Number, Optional, Default: 0 \", \"name\": \"targetStart\", \"desc\": \"Number, Optional, Default: 0\", \"optional\": true}, {\"textRaw\": \"`sourceStart` Number, Optional, Default: 0 \", \"name\": \"sourceStart\", \"desc\": \"Number, Optional, Default: 0\", \"optional\": true}, {\"textRaw\": \"`sourceEnd` Number, Optional, Default: `buffer.length` \", \"name\": \"sourceEnd\", \"desc\": \"Number, Optional, Default: `buffer.length`\", \"optional\": true}]}, {\"params\": [{\"name\": \"targetBuffer\"}, {\"name\": \"targetStart\", \"optional\": true}, {\"name\": \"sourceStart\", \"optional\": true}, {\"name\": \"sourceEnd\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "slice", "description": "<p>Returns a new buffer which references the same memory as the old, but offset\nand cropped by the <code>start</code> (defaults to <code>0</code>) and <code>end</code> (defaults to\n<code>buffer.length</code>) indexes. Negative indexes start from the end of the buffer.\n\n</p>\n<p><strong>Modifying the new buffer slice will modify memory in the original buffer!</strong>\n\n</p>\n<p>Example: build a Buffer with the ASCII alphabet, take a slice, then modify one\nbyte from the original Buffer.\n\n</p>\n<pre><code>var buf1 = new Buffer(26);\n\nfor (var i = 0 ; i < 26 ; i++) {\n buf1[i] = i + 97; // 97 is ASCII a\n}\n\nvar buf2 = buf1.slice(0, 3);\nconsole.log(buf2.toString('ascii', 0, buf2.length));\nbuf1[0] = 33;\nconsole.log(buf2.toString('ascii', 0, buf2.length));\n\n// abc\n// !bc</code></pre>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`start` Number, Optional, Default: 0 \", \"name\": \"start\", \"desc\": \"Number, Optional, Default: 0\", \"optional\": true}, {\"textRaw\": \"`end` Number, Optional, Default: `buffer.length` \", \"name\": \"end\", \"desc\": \"Number, Optional, Default: `buffer.length`\", \"optional\": true}]}, {\"params\": [{\"name\": \"start\", \"optional\": true}, {\"name\": \"end\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "readUInt8", "description": "<p>Reads an unsigned 8 bit integer from the buffer at the specified offset.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>offset</code>. This means that <code>offset</code>\nmay be beyond the end of the buffer. Defaults to <code>false</code>.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code>var buf = new Buffer(4);\n\nbuf[0] = 0x3;\nbuf[1] = 0x4;\nbuf[2] = 0x23;\nbuf[3] = 0x42;\n\nfor (ii = 0; ii < buf.length; ii++) {\n console.log(buf.readUInt8(ii));\n}\n\n// 0x3\n// 0x4\n// 0x23\n// 0x42</code></pre>\n", "signatures": "[{\"return\": {\"textRaw\": \"Return: Number \", \"name\": \"return\", \"desc\": \"Number\"}, \"params\": [{\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "readUInt16LE", "description": "<p>Reads an unsigned 16 bit integer from the buffer at the specified offset with\nspecified endian format.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>offset</code>. This means that <code>offset</code>\nmay be beyond the end of the buffer. Defaults to <code>false</code>.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code>var buf = new Buffer(4);\n\nbuf[0] = 0x3;\nbuf[1] = 0x4;\nbuf[2] = 0x23;\nbuf[3] = 0x42;\n\nconsole.log(buf.readUInt16BE(0));\nconsole.log(buf.readUInt16LE(0));\nconsole.log(buf.readUInt16BE(1));\nconsole.log(buf.readUInt16LE(1));\nconsole.log(buf.readUInt16BE(2));\nconsole.log(buf.readUInt16LE(2));\n\n// 0x0304\n// 0x0403\n// 0x0423\n// 0x2304\n// 0x2342\n// 0x4223</code></pre>\n", "signatures": "[{\"return\": {\"textRaw\": \"Return: Number \", \"name\": \"return\", \"desc\": \"Number\"}, \"params\": [{\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}, {\"params\": [{\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "readUInt16BE", "description": "<p>Reads an unsigned 16 bit integer from the buffer at the specified offset with\nspecified endian format.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>offset</code>. This means that <code>offset</code>\nmay be beyond the end of the buffer. Defaults to <code>false</code>.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code>var buf = new Buffer(4);\n\nbuf[0] = 0x3;\nbuf[1] = 0x4;\nbuf[2] = 0x23;\nbuf[3] = 0x42;\n\nconsole.log(buf.readUInt16BE(0));\nconsole.log(buf.readUInt16LE(0));\nconsole.log(buf.readUInt16BE(1));\nconsole.log(buf.readUInt16LE(1));\nconsole.log(buf.readUInt16BE(2));\nconsole.log(buf.readUInt16LE(2));\n\n// 0x0304\n// 0x0403\n// 0x0423\n// 0x2304\n// 0x2342\n// 0x4223</code></pre>\n", "signatures": "[{\"return\": {\"textRaw\": \"Return: Number \", \"name\": \"return\", \"desc\": \"Number\"}, \"params\": [{\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "readUInt32LE", "description": "<p>Reads an unsigned 32 bit integer from the buffer at the specified offset with\nspecified endian format.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>offset</code>. This means that <code>offset</code>\nmay be beyond the end of the buffer. Defaults to <code>false</code>.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code>var buf = new Buffer(4);\n\nbuf[0] = 0x3;\nbuf[1] = 0x4;\nbuf[2] = 0x23;\nbuf[3] = 0x42;\n\nconsole.log(buf.readUInt32BE(0));\nconsole.log(buf.readUInt32LE(0));\n\n// 0x03042342\n// 0x42230403</code></pre>\n", "signatures": "[{\"return\": {\"textRaw\": \"Return: Number \", \"name\": \"return\", \"desc\": \"Number\"}, \"params\": [{\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}, {\"params\": [{\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "readUInt32BE", "description": "<p>Reads an unsigned 32 bit integer from the buffer at the specified offset with\nspecified endian format.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>offset</code>. This means that <code>offset</code>\nmay be beyond the end of the buffer. Defaults to <code>false</code>.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code>var buf = new Buffer(4);\n\nbuf[0] = 0x3;\nbuf[1] = 0x4;\nbuf[2] = 0x23;\nbuf[3] = 0x42;\n\nconsole.log(buf.readUInt32BE(0));\nconsole.log(buf.readUInt32LE(0));\n\n// 0x03042342\n// 0x42230403</code></pre>\n", "signatures": "[{\"return\": {\"textRaw\": \"Return: Number \", \"name\": \"return\", \"desc\": \"Number\"}, \"params\": [{\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "readInt8", "description": "<p>Reads a signed 8 bit integer from the buffer at the specified offset.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>offset</code>. This means that <code>offset</code>\nmay be beyond the end of the buffer. Defaults to <code>false</code>.\n\n</p>\n<p>Works as <code>buffer.readUInt8</code>, except buffer contents are treated as two's\ncomplement signed values.\n\n</p>\n", "signatures": "[{\"return\": {\"textRaw\": \"Return: Number \", \"name\": \"return\", \"desc\": \"Number\"}, \"params\": [{\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "readInt16LE", "description": "<p>Reads a signed 16 bit integer from the buffer at the specified offset with\nspecified endian format.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>offset</code>. This means that <code>offset</code>\nmay be beyond the end of the buffer. Defaults to <code>false</code>.\n\n</p>\n<p>Works as <code>buffer.readUInt16*</code>, except buffer contents are treated as two's\ncomplement signed values.\n\n</p>\n", "signatures": "[{\"return\": {\"textRaw\": \"Return: Number \", \"name\": \"return\", \"desc\": \"Number\"}, \"params\": [{\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}, {\"params\": [{\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "readInt16BE", "description": "<p>Reads a signed 16 bit integer from the buffer at the specified offset with\nspecified endian format.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>offset</code>. This means that <code>offset</code>\nmay be beyond the end of the buffer. Defaults to <code>false</code>.\n\n</p>\n<p>Works as <code>buffer.readUInt16*</code>, except buffer contents are treated as two's\ncomplement signed values.\n\n</p>\n", "signatures": "[{\"return\": {\"textRaw\": \"Return: Number \", \"name\": \"return\", \"desc\": \"Number\"}, \"params\": [{\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "readInt32LE", "description": "<p>Reads a signed 32 bit integer from the buffer at the specified offset with\nspecified endian format.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>offset</code>. This means that <code>offset</code>\nmay be beyond the end of the buffer. Defaults to <code>false</code>.\n\n</p>\n<p>Works as <code>buffer.readUInt32*</code>, except buffer contents are treated as two's\ncomplement signed values.\n\n</p>\n", "signatures": "[{\"return\": {\"textRaw\": \"Return: Number \", \"name\": \"return\", \"desc\": \"Number\"}, \"params\": [{\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}, {\"params\": [{\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "readInt32BE", "description": "<p>Reads a signed 32 bit integer from the buffer at the specified offset with\nspecified endian format.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>offset</code>. This means that <code>offset</code>\nmay be beyond the end of the buffer. Defaults to <code>false</code>.\n\n</p>\n<p>Works as <code>buffer.readUInt32*</code>, except buffer contents are treated as two's\ncomplement signed values.\n\n</p>\n", "signatures": "[{\"return\": {\"textRaw\": \"Return: Number \", \"name\": \"return\", \"desc\": \"Number\"}, \"params\": [{\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "readFloatLE", "description": "<p>Reads a 32 bit float from the buffer at the specified offset with specified\nendian format.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>offset</code>. This means that <code>offset</code>\nmay be beyond the end of the buffer. Defaults to <code>false</code>.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code>var buf = new Buffer(4);\n\nbuf[0] = 0x00;\nbuf[1] = 0x00;\nbuf[2] = 0x80;\nbuf[3] = 0x3f;\n\nconsole.log(buf.readFloatLE(0));\n\n// 0x01</code></pre>\n", "signatures": "[{\"return\": {\"textRaw\": \"Return: Number \", \"name\": \"return\", \"desc\": \"Number\"}, \"params\": [{\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}, {\"params\": [{\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "readFloatBE", "description": "<p>Reads a 32 bit float from the buffer at the specified offset with specified\nendian format.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>offset</code>. This means that <code>offset</code>\nmay be beyond the end of the buffer. Defaults to <code>false</code>.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code>var buf = new Buffer(4);\n\nbuf[0] = 0x00;\nbuf[1] = 0x00;\nbuf[2] = 0x80;\nbuf[3] = 0x3f;\n\nconsole.log(buf.readFloatLE(0));\n\n// 0x01</code></pre>\n", "signatures": "[{\"return\": {\"textRaw\": \"Return: Number \", \"name\": \"return\", \"desc\": \"Number\"}, \"params\": [{\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "readDoubleLE", "description": "<p>Reads a 64 bit double from the buffer at the specified offset with specified\nendian format.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>offset</code>. This means that <code>offset</code>\nmay be beyond the end of the buffer. Defaults to <code>false</code>.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code>var buf = new Buffer(8);\n\nbuf[0] = 0x55;\nbuf[1] = 0x55;\nbuf[2] = 0x55;\nbuf[3] = 0x55;\nbuf[4] = 0x55;\nbuf[5] = 0x55;\nbuf[6] = 0xd5;\nbuf[7] = 0x3f;\n\nconsole.log(buf.readDoubleLE(0));\n\n// 0.3333333333333333</code></pre>\n", "signatures": "[{\"return\": {\"textRaw\": \"Return: Number \", \"name\": \"return\", \"desc\": \"Number\"}, \"params\": [{\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}, {\"params\": [{\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "readDoubleBE", "description": "<p>Reads a 64 bit double from the buffer at the specified offset with specified\nendian format.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>offset</code>. This means that <code>offset</code>\nmay be beyond the end of the buffer. Defaults to <code>false</code>.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code>var buf = new Buffer(8);\n\nbuf[0] = 0x55;\nbuf[1] = 0x55;\nbuf[2] = 0x55;\nbuf[3] = 0x55;\nbuf[4] = 0x55;\nbuf[5] = 0x55;\nbuf[6] = 0xd5;\nbuf[7] = 0x3f;\n\nconsole.log(buf.readDoubleLE(0));\n\n// 0.3333333333333333</code></pre>\n", "signatures": "[{\"return\": {\"textRaw\": \"Return: Number \", \"name\": \"return\", \"desc\": \"Number\"}, \"params\": [{\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "writeUInt8", "description": "<p>Writes <code>value</code> to the buffer at the specified offset. Note, <code>value</code> must be a\nvalid unsigned 8 bit integer.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>value</code> and <code>offset</code>. This means\nthat <code>value</code> may be too large for the specific function and <code>offset</code> may be\nbeyond the end of the buffer leading to the values being silently dropped. This\nshould not be used unless you are certain of correctness. Defaults to <code>false</code>.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code>var buf = new Buffer(4);\nbuf.writeUInt8(0x3, 0);\nbuf.writeUInt8(0x4, 1);\nbuf.writeUInt8(0x23, 2);\nbuf.writeUInt8(0x42, 3);\n\nconsole.log(buf);\n\n// <Buffer 03 04 23 42></code></pre>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`value` Number \", \"name\": \"value\", \"desc\": \"Number\"}, {\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"value\"}, {\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "writeUInt16LE", "description": "<p>Writes <code>value</code> to the buffer at the specified offset with specified endian\nformat. Note, <code>value</code> must be a valid unsigned 16 bit integer.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>value</code> and <code>offset</code>. This means\nthat <code>value</code> may be too large for the specific function and <code>offset</code> may be\nbeyond the end of the buffer leading to the values being silently dropped. This\nshould not be used unless you are certain of correctness. Defaults to <code>false</code>.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code>var buf = new Buffer(4);\nbuf.writeUInt16BE(0xdead, 0);\nbuf.writeUInt16BE(0xbeef, 2);\n\nconsole.log(buf);\n\nbuf.writeUInt16LE(0xdead, 0);\nbuf.writeUInt16LE(0xbeef, 2);\n\nconsole.log(buf);\n\n// <Buffer de ad be ef>\n// <Buffer ad de ef be></code></pre>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`value` Number \", \"name\": \"value\", \"desc\": \"Number\"}, {\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"value\"}, {\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}, {\"params\": [{\"name\": \"value\"}, {\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "writeUInt16BE", "description": "<p>Writes <code>value</code> to the buffer at the specified offset with specified endian\nformat. Note, <code>value</code> must be a valid unsigned 16 bit integer.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>value</code> and <code>offset</code>. This means\nthat <code>value</code> may be too large for the specific function and <code>offset</code> may be\nbeyond the end of the buffer leading to the values being silently dropped. This\nshould not be used unless you are certain of correctness. Defaults to <code>false</code>.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code>var buf = new Buffer(4);\nbuf.writeUInt16BE(0xdead, 0);\nbuf.writeUInt16BE(0xbeef, 2);\n\nconsole.log(buf);\n\nbuf.writeUInt16LE(0xdead, 0);\nbuf.writeUInt16LE(0xbeef, 2);\n\nconsole.log(buf);\n\n// <Buffer de ad be ef>\n// <Buffer ad de ef be></code></pre>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`value` Number \", \"name\": \"value\", \"desc\": \"Number\"}, {\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"value\"}, {\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "writeUInt32LE", "description": "<p>Writes <code>value</code> to the buffer at the specified offset with specified endian\nformat. Note, <code>value</code> must be a valid unsigned 32 bit integer.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>value</code> and <code>offset</code>. This means\nthat <code>value</code> may be too large for the specific function and <code>offset</code> may be\nbeyond the end of the buffer leading to the values being silently dropped. This\nshould not be used unless you are certain of correctness. Defaults to <code>false</code>.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code>var buf = new Buffer(4);\nbuf.writeUInt32BE(0xfeedface, 0);\n\nconsole.log(buf);\n\nbuf.writeUInt32LE(0xfeedface, 0);\n\nconsole.log(buf);\n\n// <Buffer fe ed fa ce>\n// <Buffer ce fa ed fe></code></pre>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`value` Number \", \"name\": \"value\", \"desc\": \"Number\"}, {\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"value\"}, {\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}, {\"params\": [{\"name\": \"value\"}, {\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "writeUInt32BE", "description": "<p>Writes <code>value</code> to the buffer at the specified offset with specified endian\nformat. Note, <code>value</code> must be a valid unsigned 32 bit integer.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>value</code> and <code>offset</code>. This means\nthat <code>value</code> may be too large for the specific function and <code>offset</code> may be\nbeyond the end of the buffer leading to the values being silently dropped. This\nshould not be used unless you are certain of correctness. Defaults to <code>false</code>.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code>var buf = new Buffer(4);\nbuf.writeUInt32BE(0xfeedface, 0);\n\nconsole.log(buf);\n\nbuf.writeUInt32LE(0xfeedface, 0);\n\nconsole.log(buf);\n\n// <Buffer fe ed fa ce>\n// <Buffer ce fa ed fe></code></pre>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`value` Number \", \"name\": \"value\", \"desc\": \"Number\"}, {\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"value\"}, {\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "writeInt8", "description": "<p>Writes <code>value</code> to the buffer at the specified offset. Note, <code>value</code> must be a\nvalid signed 8 bit integer.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>value</code> and <code>offset</code>. This means\nthat <code>value</code> may be too large for the specific function and <code>offset</code> may be\nbeyond the end of the buffer leading to the values being silently dropped. This\nshould not be used unless you are certain of correctness. Defaults to <code>false</code>.\n\n</p>\n<p>Works as <code>buffer.writeUInt8</code>, except value is written out as a two's complement\nsigned integer into <code>buffer</code>.\n\n</p>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`value` Number \", \"name\": \"value\", \"desc\": \"Number\"}, {\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"value\"}, {\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "writeInt16LE", "description": "<p>Writes <code>value</code> to the buffer at the specified offset with specified endian\nformat. Note, <code>value</code> must be a valid signed 16 bit integer.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>value</code> and <code>offset</code>. This means\nthat <code>value</code> may be too large for the specific function and <code>offset</code> may be\nbeyond the end of the buffer leading to the values being silently dropped. This\nshould not be used unless you are certain of correctness. Defaults to <code>false</code>.\n\n</p>\n<p>Works as <code>buffer.writeUInt16*</code>, except value is written out as a two's\ncomplement signed integer into <code>buffer</code>.\n\n</p>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`value` Number \", \"name\": \"value\", \"desc\": \"Number\"}, {\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"value\"}, {\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}, {\"params\": [{\"name\": \"value\"}, {\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "writeInt16BE", "description": "<p>Writes <code>value</code> to the buffer at the specified offset with specified endian\nformat. Note, <code>value</code> must be a valid signed 16 bit integer.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>value</code> and <code>offset</code>. This means\nthat <code>value</code> may be too large for the specific function and <code>offset</code> may be\nbeyond the end of the buffer leading to the values being silently dropped. This\nshould not be used unless you are certain of correctness. Defaults to <code>false</code>.\n\n</p>\n<p>Works as <code>buffer.writeUInt16*</code>, except value is written out as a two's\ncomplement signed integer into <code>buffer</code>.\n\n</p>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`value` Number \", \"name\": \"value\", \"desc\": \"Number\"}, {\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"value\"}, {\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "writeInt32LE", "description": "<p>Writes <code>value</code> to the buffer at the specified offset with specified endian\nformat. Note, <code>value</code> must be a valid signed 32 bit integer.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>value</code> and <code>offset</code>. This means\nthat <code>value</code> may be too large for the specific function and <code>offset</code> may be\nbeyond the end of the buffer leading to the values being silently dropped. This\nshould not be used unless you are certain of correctness. Defaults to <code>false</code>.\n\n</p>\n<p>Works as <code>buffer.writeUInt32*</code>, except value is written out as a two's\ncomplement signed integer into <code>buffer</code>.\n\n</p>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`value` Number \", \"name\": \"value\", \"desc\": \"Number\"}, {\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"value\"}, {\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}, {\"params\": [{\"name\": \"value\"}, {\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "writeInt32BE", "description": "<p>Writes <code>value</code> to the buffer at the specified offset with specified endian\nformat. Note, <code>value</code> must be a valid signed 32 bit integer.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>value</code> and <code>offset</code>. This means\nthat <code>value</code> may be too large for the specific function and <code>offset</code> may be\nbeyond the end of the buffer leading to the values being silently dropped. This\nshould not be used unless you are certain of correctness. Defaults to <code>false</code>.\n\n</p>\n<p>Works as <code>buffer.writeUInt32*</code>, except value is written out as a two's\ncomplement signed integer into <code>buffer</code>.\n\n</p>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`value` Number \", \"name\": \"value\", \"desc\": \"Number\"}, {\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"value\"}, {\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "writeFloatLE", "description": "<p>Writes <code>value</code> to the buffer at the specified offset with specified endian\nformat. Note, behavior is unspecified if <code>value</code> is not a 32 bit float.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>value</code> and <code>offset</code>. This means\nthat <code>value</code> may be too large for the specific function and <code>offset</code> may be\nbeyond the end of the buffer leading to the values being silently dropped. This\nshould not be used unless you are certain of correctness. Defaults to <code>false</code>.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code>var buf = new Buffer(4);\nbuf.writeFloatBE(0xcafebabe, 0);\n\nconsole.log(buf);\n\nbuf.writeFloatLE(0xcafebabe, 0);\n\nconsole.log(buf);\n\n// <Buffer 4f 4a fe bb>\n// <Buffer bb fe 4a 4f></code></pre>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`value` Number \", \"name\": \"value\", \"desc\": \"Number\"}, {\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"value\"}, {\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}, {\"params\": [{\"name\": \"value\"}, {\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "writeFloatBE", "description": "<p>Writes <code>value</code> to the buffer at the specified offset with specified endian\nformat. Note, behavior is unspecified if <code>value</code> is not a 32 bit float.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>value</code> and <code>offset</code>. This means\nthat <code>value</code> may be too large for the specific function and <code>offset</code> may be\nbeyond the end of the buffer leading to the values being silently dropped. This\nshould not be used unless you are certain of correctness. Defaults to <code>false</code>.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code>var buf = new Buffer(4);\nbuf.writeFloatBE(0xcafebabe, 0);\n\nconsole.log(buf);\n\nbuf.writeFloatLE(0xcafebabe, 0);\n\nconsole.log(buf);\n\n// <Buffer 4f 4a fe bb>\n// <Buffer bb fe 4a 4f></code></pre>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`value` Number \", \"name\": \"value\", \"desc\": \"Number\"}, {\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"value\"}, {\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "writeDoubleLE", "description": "<p>Writes <code>value</code> to the buffer at the specified offset with specified endian\nformat. Note, <code>value</code> must be a valid 64 bit double.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>value</code> and <code>offset</code>. This means\nthat <code>value</code> may be too large for the specific function and <code>offset</code> may be\nbeyond the end of the buffer leading to the values being silently dropped. This\nshould not be used unless you are certain of correctness. Defaults to <code>false</code>.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code>var buf = new Buffer(8);\nbuf.writeDoubleBE(0xdeadbeefcafebabe, 0);\n\nconsole.log(buf);\n\nbuf.writeDoubleLE(0xdeadbeefcafebabe, 0);\n\nconsole.log(buf);\n\n// <Buffer 43 eb d5 b7 dd f9 5f d7>\n// <Buffer d7 5f f9 dd b7 d5 eb 43></code></pre>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`value` Number \", \"name\": \"value\", \"desc\": \"Number\"}, {\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"value\"}, {\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}, {\"params\": [{\"name\": \"value\"}, {\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "writeDoubleBE", "description": "<p>Writes <code>value</code> to the buffer at the specified offset with specified endian\nformat. Note, <code>value</code> must be a valid 64 bit double.\n\n</p>\n<p>Set <code>noAssert</code> to true to skip validation of <code>value</code> and <code>offset</code>. This means\nthat <code>value</code> may be too large for the specific function and <code>offset</code> may be\nbeyond the end of the buffer leading to the values being silently dropped. This\nshould not be used unless you are certain of correctness. Defaults to <code>false</code>.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code>var buf = new Buffer(8);\nbuf.writeDoubleBE(0xdeadbeefcafebabe, 0);\n\nconsole.log(buf);\n\nbuf.writeDoubleLE(0xdeadbeefcafebabe, 0);\n\nconsole.log(buf);\n\n// <Buffer 43 eb d5 b7 dd f9 5f d7>\n// <Buffer d7 5f f9 dd b7 d5 eb 43></code></pre>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`value` Number \", \"name\": \"value\", \"desc\": \"Number\"}, {\"textRaw\": \"`offset` Number \", \"name\": \"offset\", \"desc\": \"Number\"}, {\"textRaw\": \"`noAssert` Boolean, Optional, Default: false \", \"name\": \"noAssert\", \"desc\": \"Boolean, Optional, Default: false\", \"optional\": true}]}, {\"params\": [{\"name\": \"value\"}, {\"name\": \"offset\"}, {\"name\": \"noAssert\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "buffer.Buffer", "name": "fill", "description": "<p>Fills the buffer with the specified value. If the <code>offset</code> (defaults to <code>0</code>)\nand <code>end</code> (defaults to <code>buffer.length</code>) are not given it will fill the entire\nbuffer.\n\n</p>\n<pre><code>var b = new Buffer(50);\nb.fill("h");</code></pre>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`value` \", \"name\": \"value\"}, {\"textRaw\": \"`offset` Number, Optional \", \"name\": \"offset\", \"optional\": true, \"desc\": \"Number\"}, {\"textRaw\": \"`end` Number, Optional \", \"name\": \"end\", \"optional\": true, \"desc\": \"Number\"}]}, {\"params\": [{\"name\": \"value\"}, {\"name\": \"offset\", \"optional\": true}, {\"name\": \"end\", \"optional\": true}]}]", "stability": null, "stabilityText": null}], "properties": [{"type": "property", "module": "buffer", "name": "INSPECT_MAX_BYTES", "description": "<p>How many bytes will be returned when <code>buffer.inspect()</code> is called. This can\nbe overridden by user modules.\n\n</p>\n<p>Note that this is a property on the buffer module returned by\n<code>require('buffer')</code>, not on the Buffer global, or a buffer instance.\n\n</p>\n", "stability": null, "stabilityText": null}, {"type": "property", "module": "buffer.Buffer", "name": "[index]", "description": "<p>Get and set the octet at <code>index</code>. The values refer to individual bytes,\nso the legal range is between <code>0x00</code> and <code>0xFF</code> hex or <code>0</code> and <code>255</code>.\n\n</p>\n<p>Example: copy an ASCII string into a buffer, one byte at a time:\n\n</p>\n<pre><code>str = "node.js";\nbuf = new Buffer(str.length);\n\nfor (var i = 0; i < str.length ; i++) {\n buf[i] = str.charCodeAt(i);\n}\n\nconsole.log(buf);\n\n// node.js</code></pre>\n", "stability": null, "stabilityText": null}, {"type": "property", "module": "buffer.Buffer", "name": "length", "description": "<p>The size of the buffer in bytes. Note that this is not necessarily the size\nof the contents. <code>length</code> refers to the amount of memory allocated for the\nbuffer object. It does not change when the contents of the buffer are changed.\n\n</p>\n<pre><code>buf = new Buffer(1234);\n\nconsole.log(buf.length);\nbuf.write("some string", 0, "ascii");\nconsole.log(buf.length);\n\n// 1234\n// 1234</code></pre>\n", "stability": null, "stabilityText": null}], "events": []}
|
doc/api/all.markdown
|
stream
|
module
|
<p>A stream is an abstract interface implemented by various objects in
Node. For example a request to an HTTP server is a stream, as is
stdout. Streams are readable, writable, or both. All streams are
instances of [EventEmitter][]
</p>
<p>You can load the Stream base classes by doing <code>require('stream')</code>.
There are base classes provided for Readable streams, Writable
streams, Duplex streams, and Transform streams.
</p>
| 19
| 0
| 10
|
{"description": "<p>A stream is an abstract interface implemented by various objects in\nNode. For example a request to an HTTP server is a stream, as is\nstdout. Streams are readable, writable, or both. All streams are\ninstances of [EventEmitter][]\n\n</p>\n<p>You can load the Stream base classes by doing <code>require('stream')</code>.\nThere are base classes provided for Readable streams, Writable\nstreams, Duplex streams, and Transform streams.\n\n</p>\n", "methods": [{"type": "method", "module": "stream.stream.Readable", "name": "Readable", "description": "<p>In classes that extend the Readable class, make sure to call the\nconstructor so that the buffering settings can be properly\ninitialized.\n\n</p>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`options` {Object} \", \"options\": [{\"textRaw\": \"`highWaterMark` {Number} The maximum number of bytes to store in the internal buffer before ceasing to read from the underlying resource. Default=16kb \", \"name\": \"highWaterMark\", \"type\": \"Number\", \"desc\": \"The maximum number of bytes to store in the internal buffer before ceasing to read from the underlying resource. Default=16kb\"}, {\"textRaw\": \"`encoding` {String} If specified, then buffers will be decoded to strings using the specified encoding. Default=null \", \"name\": \"encoding\", \"type\": \"String\", \"desc\": \"If specified, then buffers will be decoded to strings using the specified encoding. Default=null\"}, {\"textRaw\": \"`objectMode` {Boolean} Whether this stream should behave as a stream of objects. Meaning that stream.read(n) returns a single value instead of a Buffer of size n \", \"name\": \"objectMode\", \"type\": \"Boolean\", \"desc\": \"Whether this stream should behave as a stream of objects. Meaning that stream.read(n) returns a single value instead of a Buffer of size n\"}], \"name\": \"options\", \"type\": \"Object\", \"optional\": true}]}, {\"params\": [{\"name\": \"options\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "stream.stream.Readable", "name": "\\_read", "description": "<p>Note: <strong>This function should NOT be called directly.</strong> It should be\nimplemented by child classes, and called by the internal Readable\nclass methods only.\n\n</p>\n<p>All Readable stream implementations must provide a <code>_read</code> method\nto fetch data from the underlying resource.\n\n</p>\n<p>This method is prefixed with an underscore because it is internal to\nthe class that defines it, and should not be called directly by user\nprograms. However, you <strong>are</strong> expected to override this method in\nyour own extension classes.\n\n</p>\n<p>When data is available, put it into the read queue by calling\n<code>readable.push(chunk)</code>. If <code>push</code> returns false, then you should stop\nreading. When <code>_read</code> is called again, you should start pushing more\ndata.\n\n</p>\n<p>The <code>size</code> argument is advisory. Implementations where a "read" is a\nsingle call that returns data can use this to know how much data to\nfetch. Implementations where that is not relevant, such as TCP or\nTLS, may ignore this argument, and simply provide data whenever it\nbecomes available. There is no need, for example to "wait" until\n<code>size</code> bytes are available before calling <code>stream.push(chunk)</code>.\n\n</p>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`size` {Number} Number of bytes to read asynchronously \", \"name\": \"size\", \"type\": \"Number\", \"desc\": \"Number of bytes to read asynchronously\"}]}, {\"params\": [{\"name\": \"size\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "stream.stream.Readable", "name": "push", "description": "<p>Note: <strong>This function should be called by Readable implementors, NOT\nby consumers of Readable subclasses.</strong> The <code>_read()</code> function will not\nbe called again until at least one <code>push(chunk)</code> call is made. If no\ndata is available, then you MAY call <code>push('')</code> (an empty string) to\nallow a future <code>_read</code> call, without adding any data to the queue.\n\n</p>\n<p>The <code>Readable</code> class works by putting data into a read queue to be\npulled out later by calling the <code>read()</code> method when the <code>'readable'</code>\nevent fires.\n\n</p>\n<p>The <code>push()</code> method will explicitly insert some data into the read\nqueue. If it is called with <code>null</code> then it will signal the end of the\ndata.\n\n</p>\n<p>In some cases, you may be wrapping a lower-level source which has some\nsort of pause/resume mechanism, and a data callback. In those cases,\nyou could wrap the low-level source object by doing something like\nthis:\n\n</p>\n<pre><code class=\"javascript\">// source is an object with readStop() and readStart() methods,\n// and an `ondata` member that gets called when it has data, and\n// an `onend` member that gets called when the data is over.\n\nvar stream = new Readable();\n\nsource.ondata = function(chunk) {\n // if push() returns false, then we need to stop reading from source\n if (!stream.push(chunk))\n source.readStop();\n};\n\nsource.onend = function() {\n stream.push(null);\n};\n\n// _read will be called when the stream wants to pull more data in\n// the advisory size argument is ignored in this case.\nstream._read = function(n) {\n source.readStart();\n};</code></pre>\n", "signatures": "[{\"return\": {\"textRaw\": \"return {Boolean} Whether or not more pushes should be performed \", \"name\": \"return\", \"type\": \"Boolean\", \"desc\": \"Whether or not more pushes should be performed\"}, \"params\": [{\"textRaw\": \"`chunk` {Buffer | null | String} Chunk of data to push into the read queue \", \"name\": \"chunk\", \"type\": \"Buffer | null | String\", \"desc\": \"Chunk of data to push into the read queue\"}]}, {\"params\": [{\"name\": \"chunk\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "stream.stream.Readable", "name": "unshift", "description": "<p>This is the corollary of <code>readable.push(chunk)</code>. Rather than putting\nthe data at the <em>end</em> of the read queue, it puts it at the <em>front</em> of\nthe read queue.\n\n</p>\n<p>This is useful in certain use-cases where a stream is being consumed\nby a parser, which needs to "un-consume" some data that it has\noptimistically pulled out of the source.\n\n</p>\n<pre><code class=\"javascript\">// A parser for a simple data protocol.\n// The "header" is a JSON object, followed by 2 \\n characters, and\n// then a message body.\n//\n// Note: This can be done more simply as a Transform stream. See below.\n\nfunction SimpleProtocol(source, options) {\n if (!(this instanceof SimpleProtocol))\n return new SimpleProtocol(options);\n\n Readable.call(this, options);\n this._inBody = false;\n this._sawFirstCr = false;\n\n // source is a readable stream, such as a socket or file\n this._source = source;\n\n var self = this;\n source.on('end', function() {\n self.push(null);\n });\n\n // give it a kick whenever the source is readable\n // read(0) will not consume any bytes\n source.on('readable', function() {\n self.read(0);\n });\n\n this._rawHeader = [];\n this.header = null;\n}\n\nSimpleProtocol.prototype = Object.create(\n Readable.prototype, { constructor: { value: SimpleProtocol }});\n\nSimpleProtocol.prototype._read = function(n) {\n if (!this._inBody) {\n var chunk = this._source.read();\n\n // if the source doesn't have data, we don't have data yet.\n if (chunk === null)\n return this.push('');\n\n // check if the chunk has a \\n\\n\n var split = -1;\n for (var i = 0; i < chunk.length; i++) {\n if (chunk[i] === 10) { // '\\n'\n if (this._sawFirstCr) {\n split = i;\n break;\n } else {\n this._sawFirstCr = true;\n }\n } else {\n this._sawFirstCr = false;\n }\n }\n\n if (split === -1) {\n // still waiting for the \\n\\n\n // stash the chunk, and try again.\n this._rawHeader.push(chunk);\n this.push('');\n } else {\n this._inBody = true;\n var h = chunk.slice(0, split);\n this._rawHeader.push(h);\n var header = Buffer.concat(this._rawHeader).toString();\n try {\n this.header = JSON.parse(header);\n } catch (er) {\n this.emit('error', new Error('invalid simple protocol data'));\n return;\n }\n // now, because we got some extra data, unshift the rest\n // back into the read queue so that our consumer will see it.\n var b = chunk.slice(split);\n this.unshift(b);\n\n // and let them know that we are done parsing the header.\n this.emit('header', this.header);\n }\n } else {\n // from there on, just provide the data to our consumer.\n // careful not to push(null), since that would indicate EOF.\n var chunk = this._source.read();\n if (chunk) this.push(chunk);\n }\n};\n\n// Usage:\nvar parser = new SimpleProtocol(source);\n// Now parser is a readable stream that will emit 'header'\n// with the parsed header data.</code></pre>\n", "signatures": "[{\"return\": {\"textRaw\": \"return {Boolean} Whether or not more pushes should be performed \", \"name\": \"return\", \"type\": \"Boolean\", \"desc\": \"Whether or not more pushes should be performed\"}, \"params\": [{\"textRaw\": \"`chunk` {Buffer | null | String} Chunk of data to unshift onto the read queue \", \"name\": \"chunk\", \"type\": \"Buffer | null | String\", \"desc\": \"Chunk of data to unshift onto the read queue\"}]}, {\"params\": [{\"name\": \"chunk\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "stream.stream.Readable", "name": "wrap", "description": "<p>If you are using an older Node library that emits <code>'data'</code> events and\nhas a <code>pause()</code> method that is advisory only, then you can use the\n<code>wrap()</code> method to create a Readable stream that uses the old stream\nas its data source.\n\n</p>\n<p>For example:\n\n</p>\n<pre><code class=\"javascript\">var OldReader = require('./old-api-module.js').OldReader;\nvar oreader = new OldReader;\nvar Readable = require('stream').Readable;\nvar myReader = new Readable().wrap(oreader);\n\nmyReader.on('readable', function() {\n myReader.read(); // etc.\n});</code></pre>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`stream` {Stream} An \\\"old style\\\" readable stream \", \"name\": \"stream\", \"type\": \"Stream\", \"desc\": \"An \\\"old style\\\" readable stream\"}]}, {\"params\": [{\"name\": \"stream\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "stream.stream.Readable", "name": "setEncoding", "description": "<p>Makes the <code>'data'</code> event emit a string instead of a <code>Buffer</code>. <code>encoding</code>\ncan be <code>'utf8'</code>, <code>'utf16le'</code> (<code>'ucs2'</code>), <code>'ascii'</code>, or <code>'hex'</code>.\n\n</p>\n<p>The encoding can also be set by specifying an <code>encoding</code> field to the\nconstructor.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"encoding\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "stream.stream.Readable", "name": "read", "description": "<p>Note: <strong>This function SHOULD be called by Readable stream users.</strong>\n\n</p>\n<p>Call this method to consume data once the <code>'readable'</code> event is\nemitted.\n\n</p>\n<p>The <code>size</code> argument will set a minimum number of bytes that you are\ninterested in. If not set, then the entire content of the internal\nbuffer is returned.\n\n</p>\n<p>If there is no data to consume, or if there are fewer bytes in the\ninternal buffer than the <code>size</code> argument, then <code>null</code> is returned, and\na future <code>'readable'</code> event will be emitted when more is available.\n\n</p>\n<p>Calling <code>stream.read(0)</code> will always return <code>null</code>, and will trigger a\nrefresh of the internal buffer, but otherwise be a no-op.\n\n</p>\n", "signatures": "[{\"return\": {\"textRaw\": \"Return: {Buffer | String | null} \", \"name\": \"return\", \"type\": \"Buffer | String | null\"}, \"params\": [{\"textRaw\": \"`size` {Number | null} Optional number of bytes to read. \", \"name\": \"size\", \"type\": \"Number | null\", \"desc\": \"Optional number of bytes to read.\", \"optional\": true}]}, {\"params\": [{\"name\": \"size\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "stream.stream.Readable", "name": "pipe", "description": "<p>Connects this readable stream to <code>destination</code> WriteStream. Incoming\ndata on this stream gets written to <code>destination</code>. Properly manages\nback-pressure so that a slow destination will not be overwhelmed by a\nfast readable stream.\n\n</p>\n<p>This function returns the <code>destination</code> stream.\n\n</p>\n<p>For example, emulating the Unix <code>cat</code> command:\n\n</p>\n<pre><code>process.stdin.pipe(process.stdout);</code></pre>\n<p>By default <code>end()</code> is called on the destination when the source stream\nemits <code>end</code>, so that <code>destination</code> is no longer writable. Pass <code>{ end:\nfalse }</code> as <code>options</code> to keep the destination stream open.\n\n</p>\n<p>This keeps <code>writer</code> open so that "Goodbye" can be written at the\nend.\n\n</p>\n<pre><code>reader.pipe(writer, { end: false });\nreader.on("end", function() {\n writer.end("Goodbye\\n");\n});</code></pre>\n<p>Note that <code>process.stderr</code> and <code>process.stdout</code> are never closed until\nthe process exits, regardless of the specified options.\n\n</p>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`destination` {Writable Stream} \", \"name\": \"destination\", \"type\": \"Writable Stream\"}, {\"textRaw\": \"`options` {Object} Optional \", \"options\": [{\"textRaw\": \"`end` {Boolean} Default=true \", \"name\": \"end\", \"type\": \"Boolean\", \"desc\": \"Default=true\"}], \"name\": \"options\", \"type\": \"Object\", \"optional\": true}]}, {\"params\": [{\"name\": \"destination\"}, {\"name\": \"options\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "stream.stream.Readable", "name": "unpipe", "description": "<p>Undo a previously established <code>pipe()</code>. If no destination is\nprovided, then all previously established pipes are removed.\n\n</p>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`destination` {Writable Stream} Optional \", \"name\": \"destination\", \"type\": \"Writable Stream\", \"optional\": true}]}, {\"params\": [{\"name\": \"destination\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "stream.stream.Readable", "name": "pause", "description": "<p>Switches the readable stream into "old mode", where data is emitted\nusing a <code>'data'</code> event rather than being buffered for consumption via\nthe <code>read()</code> method.\n\n</p>\n<p>Ceases the flow of data. No <code>'data'</code> events are emitted while the\nstream is in a paused state.\n\n</p>\n", "signatures": "[{\"params\": []}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "stream.stream.Readable", "name": "resume", "description": "<p>Switches the readable stream into "old mode", where data is emitted\nusing a <code>'data'</code> event rather than being buffered for consumption via\nthe <code>read()</code> method.\n\n</p>\n<p>Resumes the incoming <code>'data'</code> events after a <code>pause()</code>.\n\n\n</p>\n", "signatures": "[{\"params\": []}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "stream.stream.Writable", "name": "Writable", "description": "<p>In classes that extend the Writable class, make sure to call the\nconstructor so that the buffering settings can be properly\ninitialized.\n\n</p>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`options` {Object} \", \"options\": [{\"textRaw\": \"`highWaterMark` {Number} Buffer level when `write()` starts returning false. Default=16kb \", \"name\": \"highWaterMark\", \"type\": \"Number\", \"desc\": \"Buffer level when `write()` starts returning false. Default=16kb\"}, {\"textRaw\": \"`decodeStrings` {Boolean} Whether or not to decode strings into Buffers before passing them to `_write()`. Default=true \", \"name\": \"decodeStrings\", \"type\": \"Boolean\", \"desc\": \"Whether or not to decode strings into Buffers before passing them to `_write()`. Default=true\"}], \"name\": \"options\", \"type\": \"Object\", \"optional\": true}]}, {\"params\": [{\"name\": \"options\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "stream.stream.Writable", "name": "\\_write", "description": "<p>All Writable stream implementations must provide a <code>_write</code> method to\nsend data to the underlying resource.\n\n</p>\n<p>Note: <strong>This function MUST NOT be called directly.</strong> It should be\nimplemented by child classes, and called by the internal Writable\nclass methods only.\n\n</p>\n<p>Call the callback using the standard <code>callback(error)</code> pattern to\nsignal that the write completed successfully or with an error.\n\n</p>\n<p>If the <code>decodeStrings</code> flag is set in the constructor options, then\n<code>chunk</code> may be a string rather than a Buffer, and <code>encoding</code> will\nindicate the sort of string that it is. This is to support\nimplementations that have an optimized handling for certain string\ndata encodings. If you do not explicitly set the <code>decodeStrings</code>\noption to <code>false</code>, then you can safely ignore the <code>encoding</code> argument,\nand assume that <code>chunk</code> will always be a Buffer.\n\n</p>\n<p>This method is prefixed with an underscore because it is internal to\nthe class that defines it, and should not be called directly by user\nprograms. However, you <strong>are</strong> expected to override this method in\nyour own extension classes.\n\n\n</p>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`chunk` {Buffer | String} The chunk to be written. Will always be a buffer unless the `decodeStrings` option was set to `false`. \", \"name\": \"chunk\", \"type\": \"Buffer | String\", \"desc\": \"The chunk to be written. Will always be a buffer unless the `decodeStrings` option was set to `false`.\"}, {\"textRaw\": \"`encoding` {String} If the chunk is a string, then this is the encoding type. Ignore chunk is a buffer. Note that chunk will **always** be a buffer unless the `decodeStrings` option is explicitly set to `false`. \", \"name\": \"encoding\", \"type\": \"String\", \"desc\": \"If the chunk is a string, then this is the encoding type. Ignore chunk is a buffer. Note that chunk will **always** be a buffer unless the `decodeStrings` option is explicitly set to `false`.\"}, {\"textRaw\": \"`callback` {Function} Call this function (optionally with an error argument) when you are done processing the supplied chunk. \", \"name\": \"callback\", \"type\": \"Function\", \"desc\": \"Call this function (optionally with an error argument) when you are done processing the supplied chunk.\"}]}, {\"params\": [{\"name\": \"chunk\"}, {\"name\": \"encoding\"}, {\"name\": \"callback\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "stream.stream.Writable", "name": "write", "description": "<p>Writes <code>chunk</code> to the stream. Returns <code>true</code> if the data has been\nflushed to the underlying resource. Returns <code>false</code> to indicate that\nthe buffer is full, and the data will be sent out in the future. The\n<code>'drain'</code> event will indicate when the buffer is empty again.\n\n</p>\n<p>The specifics of when <code>write()</code> will return false, is determined by\nthe <code>highWaterMark</code> option provided to the constructor.\n\n</p>\n", "signatures": "[{\"return\": {\"textRaw\": \"Returns {Boolean} \", \"name\": \"return\", \"type\": \"Boolean\"}, \"params\": [{\"textRaw\": \"`chunk` {Buffer | String} Data to be written \", \"name\": \"chunk\", \"type\": \"Buffer | String\", \"desc\": \"Data to be written\"}, {\"textRaw\": \"`encoding` {String} Optional. If `chunk` is a string, then encoding defaults to `'utf8'` \", \"name\": \"encoding\", \"type\": \"String\", \"optional\": true, \"desc\": \"If `chunk` is a string, then encoding defaults to `'utf8'`\"}, {\"textRaw\": \"`callback` {Function} Optional. Called when this chunk is successfully written. \", \"name\": \"callback\", \"type\": \"Function\", \"optional\": true, \"desc\": \"Called when this chunk is successfully written.\"}]}, {\"params\": [{\"name\": \"chunk\"}, {\"name\": \"encoding\", \"optional\": true}, {\"name\": \"callback\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "stream.stream.Writable", "name": "end", "description": "<p>Call this method to signal the end of the data being written to the\nstream.\n\n</p>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`chunk` {Buffer | String} Optional final data to be written \", \"name\": \"chunk\", \"type\": \"Buffer | String\", \"desc\": \"Optional final data to be written\", \"optional\": true}, {\"textRaw\": \"`encoding` {String} Optional. If `chunk` is a string, then encoding defaults to `'utf8'` \", \"name\": \"encoding\", \"type\": \"String\", \"optional\": true, \"desc\": \"If `chunk` is a string, then encoding defaults to `'utf8'`\"}, {\"textRaw\": \"`callback` {Function} Optional. Called when the final chunk is successfully written. \", \"name\": \"callback\", \"type\": \"Function\", \"optional\": true, \"desc\": \"Called when the final chunk is successfully written.\"}]}, {\"params\": [{\"name\": \"chunk\", \"optional\": true}, {\"name\": \"encoding\", \"optional\": true}, {\"name\": \"callback\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "stream.stream.Duplex", "name": "Duplex", "description": "<p>In classes that extend the Duplex class, make sure to call the\nconstructor so that the buffering settings can be properly\ninitialized.\n\n</p>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`options` {Object} Passed to both Writable and Readable constructors. Also has the following fields: \", \"options\": [{\"textRaw\": \"`allowHalfOpen` {Boolean} Default=true. If set to `false`, then the stream will automatically end the readable side when the writable side ends and vice versa. \", \"name\": \"allowHalfOpen\", \"type\": \"Boolean\", \"desc\": \"Default=true. If set to `false`, then the stream will automatically end the readable side when the writable side ends and vice versa.\"}], \"name\": \"options\", \"type\": \"Object\", \"desc\": \"Passed to both Writable and Readable constructors. Also has the following fields:\"}]}, {\"params\": [{\"name\": \"options\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "stream.stream.Transform", "name": "Transform", "description": "<p>In classes that extend the Transform class, make sure to call the\nconstructor so that the buffering settings can be properly\ninitialized.\n\n</p>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`options` {Object} Passed to both Writable and Readable constructors. \", \"name\": \"options\", \"type\": \"Object\", \"desc\": \"Passed to both Writable and Readable constructors.\", \"optional\": true}]}, {\"params\": [{\"name\": \"options\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "stream.stream.Transform", "name": "\\_transform", "description": "<p>Note: <strong>This function MUST NOT be called directly.</strong> It should be\nimplemented by child classes, and called by the internal Transform\nclass methods only.\n\n</p>\n<p>All Transform stream implementations must provide a <code>_transform</code>\nmethod to accept input and produce output.\n\n</p>\n<p><code>_transform</code> should do whatever has to be done in this specific\nTransform class, to handle the bytes being written, and pass them off\nto the readable portion of the interface. Do asynchronous I/O,\nprocess things, and so on.\n\n</p>\n<p>Call <code>transform.push(outputChunk)</code> 0 or more times to generate output\nfrom this input chunk, depending on how much data you want to output\nas a result of this chunk.\n\n</p>\n<p>Call the callback function only when the current chunk is completely\nconsumed. Note that there may or may not be output as a result of any\nparticular input chunk.\n\n</p>\n<p>This method is prefixed with an underscore because it is internal to\nthe class that defines it, and should not be called directly by user\nprograms. However, you <strong>are</strong> expected to override this method in\nyour own extension classes.\n\n</p>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`chunk` {Buffer | String} The chunk to be transformed. Will always be a buffer unless the `decodeStrings` option was set to `false`. \", \"name\": \"chunk\", \"type\": \"Buffer | String\", \"desc\": \"The chunk to be transformed. Will always be a buffer unless the `decodeStrings` option was set to `false`.\"}, {\"textRaw\": \"`encoding` {String} If the chunk is a string, then this is the encoding type. (Ignore if `decodeStrings` chunk is a buffer.) \", \"name\": \"encoding\", \"type\": \"String\", \"desc\": \"If the chunk is a string, then this is the encoding type. (Ignore if `decodeStrings` chunk is a buffer.)\"}, {\"textRaw\": \"`callback` {Function} Call this function (optionally with an error argument) when you are done processing the supplied chunk. \", \"name\": \"callback\", \"type\": \"Function\", \"desc\": \"Call this function (optionally with an error argument) when you are done processing the supplied chunk.\"}]}, {\"params\": [{\"name\": \"chunk\"}, {\"name\": \"encoding\"}, {\"name\": \"callback\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "stream.stream.Transform", "name": "\\_flush", "description": "<p>Note: <strong>This function MUST NOT be called directly.</strong> It MAY be implemented\nby child classes, and if so, will be called by the internal Transform\nclass methods only.\n\n</p>\n<p>In some cases, your transform operation may need to emit a bit more\ndata at the end of the stream. For example, a <code>Zlib</code> compression\nstream will store up some internal state so that it can optimally\ncompress the output. At the end, however, it needs to do the best it\ncan with what is left, so that the data will be complete.\n\n</p>\n<p>In those cases, you can implement a <code>_flush</code> method, which will be\ncalled at the very end, after all the written data is consumed, but\nbefore emitting <code>end</code> to signal the end of the readable side. Just\nlike with <code>_transform</code>, call <code>transform.push(chunk)</code> zero or more\ntimes, as appropriate, and call <code>callback</code> when the flush operation is\ncomplete.\n\n</p>\n<p>This method is prefixed with an underscore because it is internal to\nthe class that defines it, and should not be called directly by user\nprograms. However, you <strong>are</strong> expected to override this method in\nyour own extension classes.\n\n</p>\n<h3>Example: <code>SimpleProtocol</code> parser</h3>\n<p>The example above of a simple protocol parser can be implemented much\nmore simply by using the higher level <code>Transform</code> stream class.\n\n</p>\n<p>In this example, rather than providing the input as an argument, it\nwould be piped into the parser, which is a more idiomatic Node stream\napproach.\n\n</p>\n<pre><code class=\"javascript\">function SimpleProtocol(options) {\n if (!(this instanceof SimpleProtocol))\n return new SimpleProtocol(options);\n\n Transform.call(this, options);\n this._inBody = false;\n this._sawFirstCr = false;\n this._rawHeader = [];\n this.header = null;\n}\n\nSimpleProtocol.prototype = Object.create(\n Transform.prototype, { constructor: { value: SimpleProtocol }});\n\nSimpleProtocol.prototype._transform = function(chunk, encoding, done) {\n if (!this._inBody) {\n // check if the chunk has a \\n\\n\n var split = -1;\n for (var i = 0; i < chunk.length; i++) {\n if (chunk[i] === 10) { // '\\n'\n if (this._sawFirstCr) {\n split = i;\n break;\n } else {\n this._sawFirstCr = true;\n }\n } else {\n this._sawFirstCr = false;\n }\n }\n\n if (split === -1) {\n // still waiting for the \\n\\n\n // stash the chunk, and try again.\n this._rawHeader.push(chunk);\n } else {\n this._inBody = true;\n var h = chunk.slice(0, split);\n this._rawHeader.push(h);\n var header = Buffer.concat(this._rawHeader).toString();\n try {\n this.header = JSON.parse(header);\n } catch (er) {\n this.emit('error', new Error('invalid simple protocol data'));\n return;\n }\n // and let them know that we are done parsing the header.\n this.emit('header', this.header);\n\n // now, because we got some extra data, emit this first.\n this.push(b);\n }\n } else {\n // from there on, just provide the data to our consumer as-is.\n this.push(b);\n }\n done();\n};\n\nvar parser = new SimpleProtocol();\nsource.pipe(parser)\n\n// Now parser is a readable stream that will emit 'header'\n// with the parsed header data.</code></pre>\n", "signatures": "[{\"params\": [{\"textRaw\": \"`callback` {Function} Call this function (optionally with an error argument) when you are done flushing any remaining data. \", \"name\": \"callback\", \"type\": \"Function\", \"desc\": \"Call this function (optionally with an error argument) when you are done flushing any remaining data.\"}]}, {\"params\": [{\"name\": \"callback\"}]}]", "stability": null, "stabilityText": null}], "properties": [], "events": [{"type": "event", "module": "stream.stream.Readable", "name": "readable", "description": "<p>When there is data ready to be consumed, this event will fire.\n\n</p>\n<p>When this event emits, call the <code>read()</code> method to consume the data.\n\n</p>\n", "params": "[]"}, {"type": "event", "module": "stream.stream.Readable", "name": "end", "description": "<p>Emitted when the stream has received an EOF (FIN in TCP terminology).\nIndicates that no more <code>'data'</code> events will happen. If the stream is\nalso writable, it may be possible to continue writing.\n\n</p>\n", "params": "[]"}, {"type": "event", "module": "stream.stream.Readable", "name": "data", "description": "<p>The <code>'data'</code> event emits either a <code>Buffer</code> (by default) or a string if\n<code>setEncoding()</code> was used.\n\n</p>\n<p>Note that adding a <code>'data'</code> event listener will switch the Readable\nstream into "old mode", where data is emitted as soon as it is\navailable, rather than waiting for you to call <code>read()</code> to consume it.\n\n</p>\n", "params": "[]"}, {"type": "event", "module": "stream.stream.Readable", "name": "error", "description": "<p>Emitted if there was an error receiving data.\n\n</p>\n", "params": "[]"}, {"type": "event", "module": "stream.stream.Readable", "name": "close", "description": "<p>Emitted when the underlying resource (for example, the backing file\ndescriptor) has been closed. Not all streams will emit this.\n\n</p>\n", "params": "[]"}, {"type": "event", "module": "stream.stream.Writable", "name": "drain", "description": "<p>Emitted when the stream's write queue empties and it's safe to write\nwithout buffering again. Listen for it when <code>stream.write()</code> returns\n<code>false</code>.\n\n</p>\n", "params": "[]"}, {"type": "event", "module": "stream.stream.Writable", "name": "close", "description": "<p>Emitted when the underlying resource (for example, the backing file\ndescriptor) has been closed. Not all streams will emit this.\n\n</p>\n", "params": "[]"}, {"type": "event", "module": "stream.stream.Writable", "name": "finish", "description": "<p>When <code>end()</code> is called and there are no more chunks to write, this\nevent is emitted.\n\n</p>\n", "params": "[]"}, {"type": "event", "module": "stream.stream.Writable", "name": "pipe", "description": "<p>Emitted when the stream is passed to a readable stream's pipe method.\n\n</p>\n", "params": "[]"}, {"type": "event", "module": "stream.stream.Writable", "name": "unpipe", "description": "<p>Emitted when a previously established <code>pipe()</code> is removed using the\nsource Readable stream's <code>unpipe()</code> method.\n\n</p>\n", "params": "[]"}]}
|
doc/api/all.markdown
|
crypto
|
module
|
<pre><code>Stability: 2 - Unstable; API changes are being discussed for
future versions. Breaking changes will be minimized. See below.</code></pre>
<p>Use <code>require('crypto')</code> to access this module.
</p>
<p>The crypto module offers a way of encapsulating secure credentials to be
used as part of a secure HTTPS net or http connection.
</p>
<p>It also offers a set of wrappers for OpenSSL's hash, hmac, cipher,
decipher, sign and verify methods.
</p>
| 40
| 1
| 0
|
{"description": "<pre><code>Stability: 2 - Unstable; API changes are being discussed for\nfuture versions. Breaking changes will be minimized. See below.</code></pre>\n<p>Use <code>require('crypto')</code> to access this module.\n\n</p>\n<p>The crypto module offers a way of encapsulating secure credentials to be\nused as part of a secure HTTPS net or http connection.\n\n</p>\n<p>It also offers a set of wrappers for OpenSSL's hash, hmac, cipher,\ndecipher, sign and verify methods.\n\n\n</p>\n", "methods": [{"type": "method", "module": "crypto", "name": "getCiphers", "description": "<p>Returns an array with the names of the supported ciphers.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code>var ciphers = crypto.getCiphers();\nconsole.log(ciphers); // ['AES128-SHA', 'AES256-SHA', ...]</code></pre>\n", "signatures": "[{\"params\": []}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto", "name": "getHashes", "description": "<p>Returns an array with the names of the supported hash algorithms.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code>var hashes = crypto.getHashes();\nconsole.log(hashes); // ['sha', 'sha1', 'sha1WithRSAEncryption', ...]</code></pre>\n", "signatures": "[{\"params\": []}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto", "name": "createCredentials", "description": "<p>Creates a credentials object, with the optional details being a\ndictionary with keys:\n\n</p>\n<ul>\n<li><code>pfx</code> : A string or buffer holding the PFX or PKCS12 encoded private\nkey, certificate and CA certificates</li>\n<li><code>key</code> : A string holding the PEM encoded private key</li>\n<li><code>passphrase</code> : A string of passphrase for the private key or pfx</li>\n<li><code>cert</code> : A string holding the PEM encoded certificate</li>\n<li><code>ca</code> : Either a string or list of strings of PEM encoded CA\ncertificates to trust.</li>\n<li><code>crl</code> : Either a string or list of strings of PEM encoded CRLs\n(Certificate Revocation List)</li>\n<li><code>ciphers</code>: A string describing the ciphers to use or exclude.\nConsult\n<a href=\"http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT\">http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT</a>\nfor details on the format.</li>\n</ul>\n<p>If no 'ca' details are given, then node.js will use the default\npublicly trusted list of CAs as given in\n</p>\n<p><a href=\"http://mxr.mozilla.org/mozilla/source/security/nss/lib/ckfw/builtins/certdata.txt\">http://mxr.mozilla.org/mozilla/source/security/nss/lib/ckfw/builtins/certdata.txt</a>.\n\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"details\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto", "name": "createHash", "description": "<p>Creates and returns a hash object, a cryptographic hash with the given\nalgorithm which can be used to generate hash digests.\n\n</p>\n<p><code>algorithm</code> is dependent on the available algorithms supported by the\nversion of OpenSSL on the platform. Examples are <code>'sha1'</code>, <code>'md5'</code>,\n<code>'sha256'</code>, <code>'sha512'</code>, etc. On recent releases, <code>openssl\nlist-message-digest-algorithms</code> will display the available digest\nalgorithms.\n\n</p>\n<p>Example: this program that takes the sha1 sum of a file\n\n</p>\n<pre><code>var filename = process.argv[2];\nvar crypto = require('crypto');\nvar fs = require('fs');\n\nvar shasum = crypto.createHash('sha1');\n\nvar s = fs.ReadStream(filename);\ns.on('data', function(d) {\n shasum.update(d);\n});\n\ns.on('end', function() {\n var d = shasum.digest('hex');\n console.log(d + ' ' + filename);\n});</code></pre>\n", "signatures": "[{\"params\": [{\"name\": \"algorithm\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto", "name": "createHmac", "description": "<p>Creates and returns a hmac object, a cryptographic hmac with the given\nalgorithm and key.\n\n</p>\n<p>It is a <a href=\"stream.html\">stream</a> that is both readable and writable. The\nwritten data is used to compute the hmac. Once the writable side of\nthe stream is ended, use the <code>read()</code> method to get the computed\ndigest. The legacy <code>update</code> and <code>digest</code> methods are also supported.\n\n</p>\n<p><code>algorithm</code> is dependent on the available algorithms supported by\nOpenSSL - see createHash above. <code>key</code> is the hmac key to be used.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"algorithm\"}, {\"name\": \"key\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto", "name": "createCipher", "description": "<p>Creates and returns a cipher object, with the given algorithm and\npassword.\n\n</p>\n<p><code>algorithm</code> is dependent on OpenSSL, examples are <code>'aes192'</code>, etc. On\nrecent releases, <code>openssl list-cipher-algorithms</code> will display the\navailable cipher algorithms. <code>password</code> is used to derive key and IV,\nwhich must be a <code>'binary'</code> encoded string or a <a href=\"buffer.html\">buffer</a>.\n\n</p>\n<p>It is a <a href=\"stream.html\">stream</a> that is both readable and writable. The\nwritten data is used to compute the hash. Once the writable side of\nthe stream is ended, use the <code>read()</code> method to get the computed hash\ndigest. The legacy <code>update</code> and <code>digest</code> methods are also supported.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"algorithm\"}, {\"name\": \"password\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto", "name": "createCipheriv", "description": "<p>Creates and returns a cipher object, with the given algorithm, key and\niv.\n\n</p>\n<p><code>algorithm</code> is the same as the argument to <code>createCipher()</code>. <code>key</code> is\nthe raw key used by the algorithm. <code>iv</code> is an <a href=\"http://en.wikipedia.org/wiki/Initialization_vector\">initialization\nvector</a>.\n\n</p>\n<p><code>key</code> and <code>iv</code> must be <code>'binary'</code> encoded strings or\n<a href=\"buffer.html\">buffers</a>.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"algorithm\"}, {\"name\": \"key\"}, {\"name\": \"iv\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto", "name": "createDecipher", "description": "<p>Creates and returns a decipher object, with the given algorithm and\nkey. This is the mirror of the [createCipher()][] above.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"algorithm\"}, {\"name\": \"password\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto", "name": "createDecipheriv", "description": "<p>Creates and returns a decipher object, with the given algorithm, key\nand iv. This is the mirror of the [createCipheriv()][] above.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"algorithm\"}, {\"name\": \"key\"}, {\"name\": \"iv\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto", "name": "createSign", "description": "<p>Creates and returns a signing object, with the given algorithm. On\nrecent OpenSSL releases, <code>openssl list-public-key-algorithms</code> will\ndisplay the available signing algorithms. Examples are <code>'RSA-SHA256'</code>.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"algorithm\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto", "name": "createVerify", "description": "<p>Creates and returns a verification object, with the given algorithm.\nThis is the mirror of the signing object above.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"algorithm\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto", "name": "createDiffieHellman", "description": "<p>Creates a Diffie-Hellman key exchange object and generates a prime of\nthe given bit length. The generator used is <code>2</code>.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"prime_length\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto", "name": "createDiffieHellman", "description": "<p>Creates a Diffie-Hellman key exchange object using the supplied prime.\nThe generator used is <code>2</code>. Encoding can be <code>'binary'</code>, <code>'hex'</code>, or\n<code>'base64'</code>. If no encoding is specified, then a buffer is expected.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"prime\"}, {\"name\": \"encoding\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto", "name": "getDiffieHellman", "description": "<p>Creates a predefined Diffie-Hellman key exchange object. The\nsupported groups are: <code>'modp1'</code>, <code>'modp2'</code>, <code>'modp5'</code> (defined in [RFC\n2412][]) and <code>'modp14'</code>, <code>'modp15'</code>, <code>'modp16'</code>, <code>'modp17'</code>,\n<code>'modp18'</code> (defined in [RFC 3526][]). The returned object mimics the\ninterface of objects created by [crypto.createDiffieHellman()][]\nabove, but will not allow to change the keys (with\n[diffieHellman.setPublicKey()][] for example). The advantage of using\nthis routine is that the parties don't have to generate nor exchange\ngroup modulus beforehand, saving both processor and communication\ntime.\n\n</p>\n<p>Example (obtaining a shared secret):\n\n</p>\n<pre><code>var crypto = require('crypto');\nvar alice = crypto.getDiffieHellman('modp5');\nvar bob = crypto.getDiffieHellman('modp5');\n\nalice.generateKeys();\nbob.generateKeys();\n\nvar alice_secret = alice.computeSecret(bob.getPublicKey(), null, 'hex');\nvar bob_secret = bob.computeSecret(alice.getPublicKey(), null, 'hex');\n\n/* alice_secret and bob_secret should be the same */\nconsole.log(alice_secret == bob_secret);</code></pre>\n", "signatures": "[{\"params\": [{\"name\": \"group_name\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto", "name": "pbkdf2", "description": "<p>Asynchronous PBKDF2 applies pseudorandom function HMAC-SHA1 to derive\na key of given length from the given password, salt and iterations.\nThe callback gets two arguments <code>(err, derivedKey)</code>.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"password\"}, {\"name\": \"salt\"}, {\"name\": \"iterations\"}, {\"name\": \"keylen\"}, {\"name\": \"callback\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto", "name": "pbkdf2Sync", "description": "<p>Synchronous PBKDF2 function. Returns derivedKey or throws error.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"password\"}, {\"name\": \"salt\"}, {\"name\": \"iterations\"}, {\"name\": \"keylen\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto", "name": "randomBytes", "description": "<p>Generates cryptographically strong pseudo-random data. Usage:\n\n</p>\n<pre><code>// async\ncrypto.randomBytes(256, function(ex, buf) {\n if (ex) throw ex;\n console.log('Have %d bytes of random data: %s', buf.length, buf);\n});\n\n// sync\ntry {\n var buf = crypto.randomBytes(256);\n console.log('Have %d bytes of random data: %s', buf.length, buf);\n} catch (ex) {\n // handle error\n}</code></pre>\n", "signatures": "[{\"params\": [{\"name\": \"size\"}, {\"name\": \"callback\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto", "name": "pseudoRandomBytes", "description": "<p>Generates <em>non</em>-cryptographically strong pseudo-random data. The data\nreturned will be unique if it is sufficiently long, but is not\nnecessarily unpredictable. For this reason, the output of this\nfunction should never be used where unpredictability is important,\nsuch as in the generation of encryption keys.\n\n</p>\n<p>Usage is otherwise identical to <code>crypto.randomBytes</code>.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"size\"}, {\"name\": \"callback\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto.Hash", "name": "update", "description": "<p>Updates the hash content with the given <code>data</code>, the encoding of which\nis given in <code>input_encoding</code> and can be <code>'utf8'</code>, <code>'ascii'</code> or\n<code>'binary'</code>. If no encoding is provided, then a buffer is expected.\n\n</p>\n<p>This can be called many times with new data as it is streamed.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"data\"}, {\"name\": \"input_encoding\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto.Hash", "name": "digest", "description": "<p>Calculates the digest of all of the passed data to be hashed. The\n<code>encoding</code> can be <code>'hex'</code>, <code>'binary'</code> or <code>'base64'</code>. If no encoding\nis provided, then a buffer is returned.\n\n</p>\n<p>Note: <code>hash</code> object can not be used after <code>digest()</code> method been\ncalled.\n\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"encoding\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto.Hmac", "name": "update", "description": "<p>Update the hmac content with the given <code>data</code>. This can be called\nmany times with new data as it is streamed.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"data\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto.Hmac", "name": "digest", "description": "<p>Calculates the digest of all of the passed data to the hmac. The\n<code>encoding</code> can be <code>'hex'</code>, <code>'binary'</code> or <code>'base64'</code>. If no encoding\nis provided, then a buffer is returned.\n\n</p>\n<p>Note: <code>hmac</code> object can not be used after <code>digest()</code> method been\ncalled.\n\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"encoding\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto.Cipher", "name": "update", "description": "<p>Updates the cipher with <code>data</code>, the encoding of which is given in\n<code>input_encoding</code> and can be <code>'utf8'</code>, <code>'ascii'</code> or <code>'binary'</code>. If no\nencoding is provided, then a buffer is expected.\n\n</p>\n<p>The <code>output_encoding</code> specifies the output format of the enciphered\ndata, and can be <code>'binary'</code>, <code>'base64'</code> or <code>'hex'</code>. If no encoding is\nprovided, then a buffer iis returned.\n\n</p>\n<p>Returns the enciphered contents, and can be called many times with new\ndata as it is streamed.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"data\"}, {\"name\": \"input_encoding\", \"optional\": true}, {\"name\": \"output_encoding\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto.Cipher", "name": "final", "description": "<p>Returns any remaining enciphered contents, with <code>output_encoding</code>\nbeing one of: <code>'binary'</code>, <code>'base64'</code> or <code>'hex'</code>. If no encoding is\nprovided, then a buffer is returned.\n\n</p>\n<p>Note: <code>cipher</code> object can not be used after <code>final()</code> method been\ncalled.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"output_encoding\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto.Cipher", "name": "setAutoPadding", "description": "<p>You can disable automatic padding of the input data to block size. If\n<code>auto_padding</code> is false, the length of the entire input data must be a\nmultiple of the cipher's block size or <code>final</code> will fail. Useful for\nnon-standard padding, e.g. using <code>0x0</code> instead of PKCS padding. You\nmust call this before <code>cipher.final</code>.\n\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"auto_padding\", \"default\": \"true\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto.Decipher", "name": "update", "description": "<p>Updates the decipher with <code>data</code>, which is encoded in <code>'binary'</code>,\n<code>'base64'</code> or <code>'hex'</code>. If no encoding is provided, then a buffer is\nexpected.\n\n</p>\n<p>The <code>output_decoding</code> specifies in what format to return the\ndeciphered plaintext: <code>'binary'</code>, <code>'ascii'</code> or <code>'utf8'</code>. If no\nencoding is provided, then a buffer is returned.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"data\"}, {\"name\": \"input_encoding\", \"optional\": true}, {\"name\": \"output_encoding\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto.Decipher", "name": "final", "description": "<p>Returns any remaining plaintext which is deciphered, with\n<code>output_encoding</code> being one of: <code>'binary'</code>, <code>'ascii'</code> or <code>'utf8'</code>. If\nno encoding is provided, then a buffer is returned.\n\n</p>\n<p>Note: <code>decipher</code> object can not be used after <code>final()</code> method been\ncalled.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"output_encoding\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto.Decipher", "name": "setAutoPadding", "description": "<p>You can disable auto padding if the data has been encrypted without\nstandard block padding to prevent <code>decipher.final</code> from checking and\nremoving it. Can only work if the input data's length is a multiple of\nthe ciphers block size. You must call this before streaming data to\n<code>decipher.update</code>.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"auto_padding\", \"default\": \"true\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto.Sign", "name": "update", "description": "<p>Updates the sign object with data. This can be called many times\nwith new data as it is streamed.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"data\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto.Sign", "name": "sign", "description": "<p>Calculates the signature on all the updated data passed through the\nsign. <code>private_key</code> is a string containing the PEM encoded private\nkey for signing.\n\n</p>\n<p>Returns the signature in <code>output_format</code> which can be <code>'binary'</code>,\n<code>'hex'</code> or <code>'base64'</code>. If no encoding is provided, then a buffer is\nreturned.\n\n</p>\n<p>Note: <code>sign</code> object can not be used after <code>sign()</code> method been\ncalled.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"private_key\"}, {\"name\": \"output_format\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto.Verify", "name": "update", "description": "<p>Updates the verifier object with data. This can be called many times\nwith new data as it is streamed.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"data\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto.Verify", "name": "verify", "description": "<p>Verifies the signed data by using the <code>object</code> and <code>signature</code>.\n<code>object</code> is a string containing a PEM encoded object, which can be\none of RSA public key, DSA public key, or X.509 certificate.\n<code>signature</code> is the previously calculated signature for the data, in\nthe <code>signature_format</code> which can be <code>'binary'</code>, <code>'hex'</code> or <code>'base64'</code>.\nIf no encoding is specified, then a buffer is expected.\n\n</p>\n<p>Returns true or false depending on the validity of the signature for\nthe data and public key.\n\n</p>\n<p>Note: <code>verifier</code> object can not be used after <code>verify()</code> method been\ncalled.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"object\"}, {\"name\": \"signature\"}, {\"name\": \"signature_format\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto.DiffieHellman", "name": "generateKeys", "description": "<p>Generates private and public Diffie-Hellman key values, and returns\nthe public key in the specified encoding. This key should be\ntransferred to the other party. Encoding can be <code>'binary'</code>, <code>'hex'</code>,\nor <code>'base64'</code>. If no encoding is provided, then a buffer is returned.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"encoding\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto.DiffieHellman", "name": "computeSecret", "description": "<p>Computes the shared secret using <code>other_public_key</code> as the other\nparty's public key and returns the computed shared secret. Supplied\nkey is interpreted using specified <code>input_encoding</code>, and secret is\nencoded using specified <code>output_encoding</code>. Encodings can be\n<code>'binary'</code>, <code>'hex'</code>, or <code>'base64'</code>. If the input encoding is not\nprovided, then a buffer is expected.\n\n</p>\n<p>If no output encoding is given, then a buffer is returned.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"other_public_key\"}, {\"name\": \"input_encoding\", \"optional\": true}, {\"name\": \"output_encoding\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto.DiffieHellman", "name": "getPrime", "description": "<p>Returns the Diffie-Hellman prime in the specified encoding, which can\nbe <code>'binary'</code>, <code>'hex'</code>, or <code>'base64'</code>. If no encoding is provided,\nthen a buffer is returned.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"encoding\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto.DiffieHellman", "name": "getGenerator", "description": "<p>Returns the Diffie-Hellman prime in the specified encoding, which can\nbe <code>'binary'</code>, <code>'hex'</code>, or <code>'base64'</code>. If no encoding is provided,\nthen a buffer is returned.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"encoding\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto.DiffieHellman", "name": "getPublicKey", "description": "<p>Returns the Diffie-Hellman public key in the specified encoding, which\ncan be <code>'binary'</code>, <code>'hex'</code>, or <code>'base64'</code>. If no encoding is provided,\nthen a buffer is returned.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"encoding\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto.DiffieHellman", "name": "getPrivateKey", "description": "<p>Returns the Diffie-Hellman private key in the specified encoding,\nwhich can be <code>'binary'</code>, <code>'hex'</code>, or <code>'base64'</code>. If no encoding is\nprovided, then a buffer is returned.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"encoding\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto.DiffieHellman", "name": "setPublicKey", "description": "<p>Sets the Diffie-Hellman public key. Key encoding can be <code>'binary'</code>,\n<code>'hex'</code> or <code>'base64'</code>. If no encoding is provided, then a buffer is\nexpected.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"public_key\"}, {\"name\": \"encoding\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "crypto.DiffieHellman", "name": "setPrivateKey", "description": "<p>Sets the Diffie-Hellman private key. Key encoding can be <code>'binary'</code>,\n<code>'hex'</code> or <code>'base64'</code>. If no encoding is provided, then a buffer is\nexpected.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"private_key\"}, {\"name\": \"encoding\", \"optional\": true}]}]", "stability": null, "stabilityText": null}], "properties": [{"type": "property", "module": "crypto", "name": "DEFAULT_ENCODING", "description": "<p>The default encoding to use for functions that can take either strings\nor buffers. The default value is <code>'buffer'</code>, which makes it default\nto using Buffer objects. This is here to make the crypto module more\neasily compatible with legacy programs that expected <code>'binary'</code> to be\nthe default encoding.\n\n</p>\n<p>Note that new programs will probably expect buffers, so only use this\nas a temporary measure.\n\n</p>\n", "stability": null, "stabilityText": null}], "events": []}
|
doc/api/all.markdown
|
tls_(ssl)
|
module
|
<p>Use <code>require('tls')</code> to access this module.
</p>
<p>The <code>tls</code> module uses OpenSSL to provide Transport Layer Security and/or
Secure Socket Layer: encrypted stream communication.
</p>
<p>TLS/SSL is a public/private key infrastructure. Each client and each
server must have a private key. A private key is created like this
</p>
<pre><code>openssl genrsa -out ryans-key.pem 1024</code></pre>
<p>All severs and some clients need to have a certificate. Certificates are public
keys signed by a Certificate Authority or self-signed. The first step to
getting a certificate is to create a "Certificate Signing Request" (CSR)
file. This is done with:
</p>
<pre><code>openssl req -new -key ryans-key.pem -out ryans-csr.pem</code></pre>
<p>To create a self-signed certificate with the CSR, do this:
</p>
<pre><code>openssl x509 -req -in ryans-csr.pem -signkey ryans-key.pem -out ryans-cert.pem</code></pre>
<p>Alternatively you can send the CSR to a Certificate Authority for signing.
</p>
<p>(TODO: docs on creating a CA, for now interested users should just look at
<code>test/fixtures/keys/Makefile</code> in the Node source code)
</p>
<p>To create .pfx or .p12, do this:
</p>
<pre><code>openssl pkcs12 -export -in agent5-cert.pem -inkey agent5-key.pem \
-certfile ca-cert.pem -out agent5.pfx</code></pre>
<ul>
<li><code>in</code>: certificate</li>
<li><code>inkey</code>: private key</li>
<li><code>certfile</code>: all CA certs concatenated in one file like
<code>cat ca1-cert.pem ca2-cert.pem > ca-cert.pem</code></li>
</ul>
| 11
| 8
| 6
|
{"description": "<p>Use <code>require('tls')</code> to access this module.\n\n</p>\n<p>The <code>tls</code> module uses OpenSSL to provide Transport Layer Security and/or\nSecure Socket Layer: encrypted stream communication.\n\n</p>\n<p>TLS/SSL is a public/private key infrastructure. Each client and each\nserver must have a private key. A private key is created like this\n\n</p>\n<pre><code>openssl genrsa -out ryans-key.pem 1024</code></pre>\n<p>All severs and some clients need to have a certificate. Certificates are public\nkeys signed by a Certificate Authority or self-signed. The first step to\ngetting a certificate is to create a "Certificate Signing Request" (CSR)\nfile. This is done with:\n\n</p>\n<pre><code>openssl req -new -key ryans-key.pem -out ryans-csr.pem</code></pre>\n<p>To create a self-signed certificate with the CSR, do this:\n\n</p>\n<pre><code>openssl x509 -req -in ryans-csr.pem -signkey ryans-key.pem -out ryans-cert.pem</code></pre>\n<p>Alternatively you can send the CSR to a Certificate Authority for signing.\n\n</p>\n<p>(TODO: docs on creating a CA, for now interested users should just look at\n<code>test/fixtures/keys/Makefile</code> in the Node source code)\n\n</p>\n<p>To create .pfx or .p12, do this:\n\n</p>\n<pre><code>openssl pkcs12 -export -in agent5-cert.pem -inkey agent5-key.pem \\\n -certfile ca-cert.pem -out agent5.pfx</code></pre>\n<ul>\n<li><code>in</code>: certificate</li>\n<li><code>inkey</code>: private key</li>\n<li><code>certfile</code>: all CA certs concatenated in one file like\n<code>cat ca1-cert.pem ca2-cert.pem > ca-cert.pem</code></li>\n</ul>\n", "methods": [{"type": "method", "module": "tls_(ssl)", "name": "createServer", "description": "<p>Creates a new [tls.Server][]. The <code>connectionListener</code> argument is\nautomatically set as a listener for the [secureConnection][] event. The\n<code>options</code> object has these possibilities:\n\n</p>\n<ul>\n<li><p><code>pfx</code>: A string or <code>Buffer</code> containing the private key, certificate and\nCA certs of the server in PFX or PKCS12 format. (Mutually exclusive with\nthe <code>key</code>, <code>cert</code> and <code>ca</code> options.)</p>\n</li>\n<li><p><code>key</code>: A string or <code>Buffer</code> containing the private key of the server in\nPEM format. (Required)</p>\n</li>\n<li><p><code>passphrase</code>: A string of passphrase for the private key or pfx.</p>\n</li>\n<li><p><code>cert</code>: A string or <code>Buffer</code> containing the certificate key of the server in\nPEM format. (Required)</p>\n</li>\n<li><p><code>ca</code>: An array of strings or <code>Buffer</code>s of trusted certificates. If this is\nomitted several well known "root" CAs will be used, like VeriSign.\nThese are used to authorize connections.</p>\n</li>\n<li><p><code>crl</code> : Either a string or list of strings of PEM encoded CRLs (Certificate\nRevocation List)</p>\n</li>\n<li><p><code>ciphers</code>: A string describing the ciphers to use or exclude.</p>\n<p>To mitigate [BEAST attacks] it is recommended that you use this option in\nconjunction with the <code>honorCipherOrder</code> option described below to\nprioritize the non-CBC cipher.</p>\n<p>Defaults to\n<code>ECDHE-RSA-AES128-SHA256:AES128-GCM-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH</code>.\nConsult the [OpenSSL cipher list format documentation] for details on the\nformat.</p>\n<p><code>ECDHE-RSA-AES128-SHA256</code> and <code>AES128-GCM-SHA256</code> are used when node.js is\nlinked against OpenSSL 1.0.1 or newer and the client speaks TLS 1.2, RC4 is\nused as a secure fallback.</p>\n<p><strong>NOTE</strong>: Previous revisions of this section suggested <code>AES256-SHA</code> as an\nacceptable cipher. Unfortunately, <code>AES256-SHA</code> is a CBC cipher and therefore\nsusceptible to BEAST attacks. Do <em>not</em> use it.</p>\n</li>\n<li><p><code>handshakeTimeout</code>: Abort the connection if the SSL/TLS handshake does not\nfinish in this many milliseconds. The default is 120 seconds.</p>\n<p>A <code>'clientError'</code> is emitted on the <code>tls.Server</code> object whenever a handshake\ntimes out.</p>\n</li>\n<li><p><code>honorCipherOrder</code> : When choosing a cipher, use the server's preferences\ninstead of the client preferences.</p>\n<p>Note that if SSLv2 is used, the server will send its list of preferences\nto the client, and the client chooses the cipher.</p>\n<p>Although, this option is disabled by default, it is <em>recommended</em> that you\nuse this option in conjunction with the <code>ciphers</code> option to mitigate\nBEAST attacks.</p>\n</li>\n<li><p><code>requestCert</code>: If <code>true</code> the server will request a certificate from\nclients that connect and attempt to verify that certificate. Default:\n<code>false</code>.</p>\n</li>\n<li><p><code>rejectUnauthorized</code>: If <code>true</code> the server will reject any connection\nwhich is not authorized with the list of supplied CAs. This option only\nhas an effect if <code>requestCert</code> is <code>true</code>. Default: <code>false</code>.</p>\n</li>\n<li><p><code>NPNProtocols</code>: An array or <code>Buffer</code> of possible NPN protocols. (Protocols\nshould be ordered by their priority).</p>\n</li>\n<li><p><code>SNICallback</code>: A function that will be called if client supports SNI TLS\nextension. Only one argument will be passed to it: <code>servername</code>. And\n<code>SNICallback</code> should return SecureContext instance.\n(You can use <code>crypto.createCredentials(...).context</code> to get proper\nSecureContext). If <code>SNICallback</code> wasn't provided - default callback with\nhigh-level API will be used (see below).</p>\n</li>\n<li><p><code>sessionIdContext</code>: A string containing a opaque identifier for session\nresumption. If <code>requestCert</code> is <code>true</code>, the default is MD5 hash value\ngenerated from command-line. Otherwise, the default is not provided.</p>\n</li>\n</ul>\n<p>Here is a simple example echo server:\n\n</p>\n<pre><code>var tls = require('tls');\nvar fs = require('fs');\n\nvar options = {\n key: fs.readFileSync('server-key.pem'),\n cert: fs.readFileSync('server-cert.pem'),\n\n // This is necessary only if using the client certificate authentication.\n requestCert: true,\n\n // This is necessary only if the client uses the self-signed certificate.\n ca: [ fs.readFileSync('client-cert.pem') ]\n};\n\nvar server = tls.createServer(options, function(cleartextStream) {\n console.log('server connected',\n cleartextStream.authorized ? 'authorized' : 'unauthorized');\n cleartextStream.write("welcome!\\n");\n cleartextStream.setEncoding('utf8');\n cleartextStream.pipe(cleartextStream);\n});\nserver.listen(8000, function() {\n console.log('server bound');\n});</code></pre>\n<p>Or\n\n</p>\n<pre><code>var tls = require('tls');\nvar fs = require('fs');\n\nvar options = {\n pfx: fs.readFileSync('server.pfx'),\n\n // This is necessary only if using the client certificate authentication.\n requestCert: true,\n\n};\n\nvar server = tls.createServer(options, function(cleartextStream) {\n console.log('server connected',\n cleartextStream.authorized ? 'authorized' : 'unauthorized');\n cleartextStream.write("welcome!\\n");\n cleartextStream.setEncoding('utf8');\n cleartextStream.pipe(cleartextStream);\n});\nserver.listen(8000, function() {\n console.log('server bound');\n});</code></pre>\n<p>You can test this server by connecting to it with <code>openssl s_client</code>:\n\n\n</p>\n<pre><code>openssl s_client -connect 127.0.0.1:8000</code></pre>\n", "signatures": "[{\"params\": [{\"name\": \"options\"}, {\"name\": \"secureConnectionListener\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "tls_(ssl)", "name": "connect", "description": "<p>Creates a new client connection to the given <code>port</code> and <code>host</code> (old API) or\n<code>options.port</code> and <code>options.host</code>. (If <code>host</code> is omitted, it defaults to\n<code>localhost</code>.) <code>options</code> should be an object which specifies:\n\n</p>\n<ul>\n<li><p><code>host</code>: Host the client should connect to</p>\n</li>\n<li><p><code>port</code>: Port the client should connect to</p>\n</li>\n<li><p><code>socket</code>: Establish secure connection on a given socket rather than\ncreating a new socket. If this option is specified, <code>host</code> and <code>port</code>\nare ignored.</p>\n</li>\n<li><p><code>pfx</code>: A string or <code>Buffer</code> containing the private key, certificate and\nCA certs of the server in PFX or PKCS12 format.</p>\n</li>\n<li><p><code>key</code>: A string or <code>Buffer</code> containing the private key of the client in\nPEM format.</p>\n</li>\n<li><p><code>passphrase</code>: A string of passphrase for the private key or pfx.</p>\n</li>\n<li><p><code>cert</code>: A string or <code>Buffer</code> containing the certificate key of the client in\nPEM format.</p>\n</li>\n<li><p><code>ca</code>: An array of strings or <code>Buffer</code>s of trusted certificates. If this is\nomitted several well known "root" CAs will be used, like VeriSign.\nThese are used to authorize connections.</p>\n</li>\n<li><p><code>rejectUnauthorized</code>: If <code>true</code>, the server certificate is verified against\nthe list of supplied CAs. An <code>'error'</code> event is emitted if verification\nfails. Default: <code>true</code>.</p>\n</li>\n<li><p><code>NPNProtocols</code>: An array of string or <code>Buffer</code> containing supported NPN\nprotocols. <code>Buffer</code> should have following format: <code>0x05hello0x05world</code>,\nwhere first byte is next protocol name's length. (Passing array should\nusually be much simpler: <code>['hello', 'world']</code>.)</p>\n</li>\n<li><p><code>servername</code>: Servername for SNI (Server Name Indication) TLS extension.</p>\n</li>\n</ul>\n<p>The <code>callback</code> parameter will be added as a listener for the\n['secureConnect'][] event.\n\n</p>\n<p><code>tls.connect()</code> returns a [CleartextStream][] object.\n\n</p>\n<p>Here is an example of a client of echo server as described previously:\n\n</p>\n<pre><code>var tls = require('tls');\nvar fs = require('fs');\n\nvar options = {\n // These are necessary only if using the client certificate authentication\n key: fs.readFileSync('client-key.pem'),\n cert: fs.readFileSync('client-cert.pem'),\n\n // This is necessary only if the server uses the self-signed certificate\n ca: [ fs.readFileSync('server-cert.pem') ]\n};\n\nvar cleartextStream = tls.connect(8000, options, function() {\n console.log('client connected',\n cleartextStream.authorized ? 'authorized' : 'unauthorized');\n process.stdin.pipe(cleartextStream);\n process.stdin.resume();\n});\ncleartextStream.setEncoding('utf8');\ncleartextStream.on('data', function(data) {\n console.log(data);\n});\ncleartextStream.on('end', function() {\n server.close();\n});</code></pre>\n<p>Or\n\n</p>\n<pre><code>var tls = require('tls');\nvar fs = require('fs');\n\nvar options = {\n pfx: fs.readFileSync('client.pfx')\n};\n\nvar cleartextStream = tls.connect(8000, options, function() {\n console.log('client connected',\n cleartextStream.authorized ? 'authorized' : 'unauthorized');\n process.stdin.pipe(cleartextStream);\n process.stdin.resume();\n});\ncleartextStream.setEncoding('utf8');\ncleartextStream.on('data', function(data) {\n console.log(data);\n});\ncleartextStream.on('end', function() {\n server.close();\n});</code></pre>\n", "signatures": "[{\"params\": [{\"name\": \"port\"}, {\"name\": \"host\", \"optional\": true}, {\"name\": \"options\", \"optional\": true}, {\"name\": \"callback\", \"optional\": true}]}, {\"params\": [{\"name\": \"options\"}, {\"name\": \"callback\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "tls_(ssl)", "name": "connect", "description": "<p>Creates a new client connection to the given <code>port</code> and <code>host</code> (old API) or\n<code>options.port</code> and <code>options.host</code>. (If <code>host</code> is omitted, it defaults to\n<code>localhost</code>.) <code>options</code> should be an object which specifies:\n\n</p>\n<ul>\n<li><p><code>host</code>: Host the client should connect to</p>\n</li>\n<li><p><code>port</code>: Port the client should connect to</p>\n</li>\n<li><p><code>socket</code>: Establish secure connection on a given socket rather than\ncreating a new socket. If this option is specified, <code>host</code> and <code>port</code>\nare ignored.</p>\n</li>\n<li><p><code>pfx</code>: A string or <code>Buffer</code> containing the private key, certificate and\nCA certs of the server in PFX or PKCS12 format.</p>\n</li>\n<li><p><code>key</code>: A string or <code>Buffer</code> containing the private key of the client in\nPEM format.</p>\n</li>\n<li><p><code>passphrase</code>: A string of passphrase for the private key or pfx.</p>\n</li>\n<li><p><code>cert</code>: A string or <code>Buffer</code> containing the certificate key of the client in\nPEM format.</p>\n</li>\n<li><p><code>ca</code>: An array of strings or <code>Buffer</code>s of trusted certificates. If this is\nomitted several well known "root" CAs will be used, like VeriSign.\nThese are used to authorize connections.</p>\n</li>\n<li><p><code>rejectUnauthorized</code>: If <code>true</code>, the server certificate is verified against\nthe list of supplied CAs. An <code>'error'</code> event is emitted if verification\nfails. Default: <code>true</code>.</p>\n</li>\n<li><p><code>NPNProtocols</code>: An array of string or <code>Buffer</code> containing supported NPN\nprotocols. <code>Buffer</code> should have following format: <code>0x05hello0x05world</code>,\nwhere first byte is next protocol name's length. (Passing array should\nusually be much simpler: <code>['hello', 'world']</code>.)</p>\n</li>\n<li><p><code>servername</code>: Servername for SNI (Server Name Indication) TLS extension.</p>\n</li>\n</ul>\n<p>The <code>callback</code> parameter will be added as a listener for the\n['secureConnect'][] event.\n\n</p>\n<p><code>tls.connect()</code> returns a [CleartextStream][] object.\n\n</p>\n<p>Here is an example of a client of echo server as described previously:\n\n</p>\n<pre><code>var tls = require('tls');\nvar fs = require('fs');\n\nvar options = {\n // These are necessary only if using the client certificate authentication\n key: fs.readFileSync('client-key.pem'),\n cert: fs.readFileSync('client-cert.pem'),\n\n // This is necessary only if the server uses the self-signed certificate\n ca: [ fs.readFileSync('server-cert.pem') ]\n};\n\nvar cleartextStream = tls.connect(8000, options, function() {\n console.log('client connected',\n cleartextStream.authorized ? 'authorized' : 'unauthorized');\n process.stdin.pipe(cleartextStream);\n process.stdin.resume();\n});\ncleartextStream.setEncoding('utf8');\ncleartextStream.on('data', function(data) {\n console.log(data);\n});\ncleartextStream.on('end', function() {\n server.close();\n});</code></pre>\n<p>Or\n\n</p>\n<pre><code>var tls = require('tls');\nvar fs = require('fs');\n\nvar options = {\n pfx: fs.readFileSync('client.pfx')\n};\n\nvar cleartextStream = tls.connect(8000, options, function() {\n console.log('client connected',\n cleartextStream.authorized ? 'authorized' : 'unauthorized');\n process.stdin.pipe(cleartextStream);\n process.stdin.resume();\n});\ncleartextStream.setEncoding('utf8');\ncleartextStream.on('data', function(data) {\n console.log(data);\n});\ncleartextStream.on('end', function() {\n server.close();\n});</code></pre>\n", "signatures": "[{\"params\": [{\"name\": \"port\"}, {\"name\": \"host\", \"optional\": true}, {\"name\": \"options\", \"optional\": true}, {\"name\": \"callback\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "tls_(ssl)", "name": "createSecurePair", "description": "<p>Creates a new secure pair object with two streams, one of which reads/writes\nencrypted data, and one reads/writes cleartext data.\nGenerally the encrypted one is piped to/from an incoming encrypted data stream,\nand the cleartext one is used as a replacement for the initial encrypted stream.\n\n</p>\n<ul>\n<li><p><code>credentials</code>: A credentials object from crypto.createCredentials( ... )</p>\n</li>\n<li><p><code>isServer</code>: A boolean indicating whether this tls connection should be\nopened as a server or a client.</p>\n</li>\n<li><p><code>requestCert</code>: A boolean indicating whether a server should request a\ncertificate from a connecting client. Only applies to server connections.</p>\n</li>\n<li><p><code>rejectUnauthorized</code>: A boolean indicating whether a server should\nautomatically reject clients with invalid certificates. Only applies to\nservers with <code>requestCert</code> enabled.</p>\n</li>\n</ul>\n<p><code>tls.createSecurePair()</code> returns a SecurePair object with [cleartext][] and\n<code>encrypted</code> stream properties.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"credentials\", \"optional\": true}, {\"name\": \"isServer\", \"optional\": true}, {\"name\": \"requestCert\", \"optional\": true}, {\"name\": \"rejectUnauthorized\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "tls_(ssl).tls.Server", "name": "listen", "description": "<p>Begin accepting connections on the specified <code>port</code> and <code>host</code>. If the\n<code>host</code> is omitted, the server will accept connections directed to any\nIPv4 address (<code>INADDR_ANY</code>).\n\n</p>\n<p>This function is asynchronous. The last parameter <code>callback</code> will be called\nwhen the server has been bound.\n\n</p>\n<p>See <code>net.Server</code> for more information.\n\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"port\"}, {\"name\": \"host\", \"optional\": true}, {\"name\": \"callback\", \"optional\": true}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "tls_(ssl).tls.Server", "name": "close", "description": "<p>Stops the server from accepting new connections. This function is\nasynchronous, the server is finally closed when the server emits a <code>'close'</code>\nevent.\n\n</p>\n", "signatures": "[{\"params\": []}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "tls_(ssl).tls.Server", "name": "address", "description": "<p>Returns the bound address, the address family name and port of the\nserver as reported by the operating system. See [net.Server.address()][] for\nmore information.\n\n</p>\n", "signatures": "[{\"params\": []}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "tls_(ssl).tls.Server", "name": "addContext", "description": "<p>Add secure context that will be used if client request's SNI hostname is\nmatching passed <code>hostname</code> (wildcards can be used). <code>credentials</code> can contain\n<code>key</code>, <code>cert</code> and <code>ca</code>.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"hostname\"}, {\"name\": \"credentials\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "tls_(ssl).tls.CleartextStream", "name": "getPeerCertificate", "description": "<p>Returns an object representing the peer's certificate. The returned object has\nsome properties corresponding to the field of the certificate.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code>{ subject: \n { C: 'UK',\n ST: 'Acknack Ltd',\n L: 'Rhys Jones',\n O: 'node.js',\n OU: 'Test TLS Certificate',\n CN: 'localhost' },\n issuer: \n { C: 'UK',\n ST: 'Acknack Ltd',\n L: 'Rhys Jones',\n O: 'node.js',\n OU: 'Test TLS Certificate',\n CN: 'localhost' },\n valid_from: 'Nov 11 09:52:22 2009 GMT',\n valid_to: 'Nov 6 09:52:22 2029 GMT',\n fingerprint: '2A:7A:C2:DD:E5:F9:CC:53:72:35:99:7A:02:5A:71:38:52:EC:8A:DF' }</code></pre>\n<p>If the peer does not provide a certificate, it returns <code>null</code> or an empty\nobject.\n\n</p>\n", "signatures": "[{\"params\": []}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "tls_(ssl).tls.CleartextStream", "name": "getCipher", "description": "<p>Returns an object representing the cipher name and the SSL/TLS\nprotocol version of the current connection.\n\n</p>\n<p>Example:\n{ name: 'AES256-SHA', version: 'TLSv1/SSLv3' }\n\n</p>\n<p>See SSL_CIPHER_get_name() and SSL_CIPHER_get_version() in\n<a href=\"http://www.openssl.org/docs/ssl/ssl.html#DEALING_WITH_CIPHERS\">http://www.openssl.org/docs/ssl/ssl.html#DEALING_WITH_CIPHERS</a> for more\ninformation.\n\n</p>\n", "signatures": "[{\"params\": []}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "tls_(ssl).tls.CleartextStream", "name": "address", "description": "<p>Returns the bound address, the address family name and port of the\nunderlying socket as reported by the operating system. Returns an\nobject with three properties, e.g.\n<code>{ port: 12346, family: 'IPv4', address: '127.0.0.1' }</code>\n\n</p>\n", "signatures": "[{\"params\": []}]", "stability": null, "stabilityText": null}], "properties": [{"type": "property", "module": "tls_(ssl)", "name": "SLAB_BUFFER_SIZE", "description": "<p>Size of slab buffer used by all tls servers and clients.\nDefault: <code>10 * 1024 * 1024</code>.\n\n\n</p>\n<p>Don't change the defaults unless you know what you are doing.\n\n\n</p>\n", "stability": null, "stabilityText": null}, {"type": "property", "module": "tls_(ssl).tls.Server", "name": "maxConnections", "description": "<p>Set this property to reject connections when the server's connection count\ngets high.\n\n</p>\n", "stability": null, "stabilityText": null}, {"type": "property", "module": "tls_(ssl).tls.Server", "name": "connections", "description": "<p>The number of concurrent connections on the server.\n\n\n</p>\n", "stability": null, "stabilityText": null}, {"type": "property", "module": "tls_(ssl).CryptoStream", "name": "bytesWritten", "description": "<p>A proxy to the underlying socket's bytesWritten accessor, this will return\nthe total bytes written to the socket, <em>including the TLS overhead</em>.\n\n</p>\n", "stability": null, "stabilityText": null}, {"type": "property", "module": "tls_(ssl).tls.CleartextStream", "name": "authorized", "description": "<p>A boolean that is <code>true</code> if the peer certificate was signed by one of the\nspecified CAs, otherwise <code>false</code>\n\n</p>\n", "stability": null, "stabilityText": null}, {"type": "property", "module": "tls_(ssl).tls.CleartextStream", "name": "authorizationError", "description": "<p>The reason why the peer's certificate has not been verified. This property\nbecomes available only when <code>cleartextStream.authorized === false</code>.\n\n</p>\n", "stability": null, "stabilityText": null}, {"type": "property", "module": "tls_(ssl).tls.CleartextStream", "name": "remoteAddress", "description": "<p>The string representation of the remote IP address. For example,\n<code>'74.125.127.100'</code> or <code>'2001:4860:a005::68'</code>.\n\n</p>\n", "stability": null, "stabilityText": null}, {"type": "property", "module": "tls_(ssl).tls.CleartextStream", "name": "remotePort", "description": "<p>The numeric representation of the remote port. For example, <code>443</code>.\n\n</p>\n", "stability": null, "stabilityText": null}], "events": [{"type": "event", "module": "tls_(ssl).SecurePair", "name": "secure", "description": "<p>The event is emitted from the SecurePair once the pair has successfully\nestablished a secure connection.\n\n</p>\n<p>Similarly to the checking for the server 'secureConnection' event,\npair.cleartext.authorized should be checked to confirm whether the certificate\nused properly authorized.\n\n</p>\n", "params": "[]"}, {"type": "event", "module": "tls_(ssl).tls.Server", "name": "secureConnection", "description": "<p><code>function (cleartextStream) {}</code>\n\n</p>\n<p>This event is emitted after a new connection has been successfully\nhandshaked. The argument is a instance of [CleartextStream][]. It has all the\ncommon stream methods and events.\n\n</p>\n<p><code>cleartextStream.authorized</code> is a boolean value which indicates if the\nclient has verified by one of the supplied certificate authorities for the\nserver. If <code>cleartextStream.authorized</code> is false, then\n<code>cleartextStream.authorizationError</code> is set to describe how authorization\nfailed. Implied but worth mentioning: depending on the settings of the TLS\nserver, you unauthorized connections may be accepted.\n<code>cleartextStream.npnProtocol</code> is a string containing selected NPN protocol.\n<code>cleartextStream.servername</code> is a string containing servername requested with\nSNI.\n\n\n</p>\n", "params": "[]"}, {"type": "event", "module": "tls_(ssl).tls.Server", "name": "clientError", "description": "<p><code>function (exception, securePair) { }</code>\n\n</p>\n<p>When a client connection emits an 'error' event before secure connection is\nestablished - it will be forwarded here.\n\n</p>\n<p><code>securePair</code> is the <code>tls.SecurePair</code> that the error originated from.\n\n\n</p>\n", "params": "[]"}, {"type": "event", "module": "tls_(ssl).tls.Server", "name": "newSession", "description": "<p><code>function (sessionId, sessionData) { }</code>\n\n</p>\n<p>Emitted on creation of TLS session. May be used to store sessions in external\nstorage.\n\n\n</p>\n", "params": "[]"}, {"type": "event", "module": "tls_(ssl).tls.Server", "name": "resumeSession", "description": "<p><code>function (sessionId, callback) { }</code>\n\n</p>\n<p>Emitted when client wants to resume previous TLS session. Event listener may\nperform lookup in external storage using given <code>sessionId</code>, and invoke\n<code>callback(null, sessionData)</code> once finished. If session can't be resumed\n(i.e. doesn't exist in storage) one may call <code>callback(null, null)</code>. Calling\n<code>callback(err)</code> will terminate incoming connection and destroy socket.\n\n\n</p>\n", "params": "[]"}, {"type": "event", "module": "tls_(ssl).tls.CleartextStream", "name": "secureConnect", "description": "<p>This event is emitted after a new connection has been successfully handshaked. \nThe listener will be called no matter if the server's certificate was\nauthorized or not. It is up to the user to test <code>cleartextStream.authorized</code>\nto see if the server certificate was signed by one of the specified CAs.\nIf <code>cleartextStream.authorized === false</code> then the error can be found in\n<code>cleartextStream.authorizationError</code>. Also if NPN was used - you can check\n<code>cleartextStream.npnProtocol</code> for negotiated protocol.\n\n</p>\n", "params": "[]"}]}
|
doc/api/all.markdown
|
stringdecoder
|
module
|
<p>To use this module, do <code>require('string_decoder')</code>. StringDecoder decodes a
buffer to a string. It is a simple interface to <code>buffer.toString()</code> but provides
additional support for utf8.
</p>
<pre><code>var StringDecoder = require('string_decoder').StringDecoder;
var decoder = new StringDecoder('utf8');
var cent = new Buffer([0xC2, 0xA2]);
console.log(decoder.write(cent));
var euro = new Buffer([0xE2, 0x82, 0xAC]);
console.log(decoder.write(euro));</code></pre>
| 2
| 0
| 0
|
{"description": "<p>To use this module, do <code>require('string_decoder')</code>. StringDecoder decodes a\nbuffer to a string. It is a simple interface to <code>buffer.toString()</code> but provides\nadditional support for utf8.\n\n</p>\n<pre><code>var StringDecoder = require('string_decoder').StringDecoder;\nvar decoder = new StringDecoder('utf8');\n\nvar cent = new Buffer([0xC2, 0xA2]);\nconsole.log(decoder.write(cent));\n\nvar euro = new Buffer([0xE2, 0x82, 0xAC]);\nconsole.log(decoder.write(euro));</code></pre>\n", "methods": [{"type": "method", "module": "stringdecoder.StringDecoder", "name": "write", "description": "<p>Returns a decoded string.\n\n</p>\n", "signatures": "[{\"params\": [{\"name\": \"buffer\"}]}]", "stability": null, "stabilityText": null}, {"type": "method", "module": "stringdecoder.StringDecoder", "name": "end", "description": "<p>Returns any trailing bytes that were left in the buffer.\n\n</p>\n", "signatures": "[{\"params\": []}]", "stability": null, "stabilityText": null}], "properties": [], "events": []}
|
Node.js API Dataset
Source: Node.js official documentation (JSON variant) Processing Type: Extractive, Hierarchical Flattening.
Overview
This dataset contains a structured representation of the Node.js API, derived from the official nodejs.json distribution. Unlike raw documentation dumps, this dataset has been processed into two distinct formats to serve different machine learning and analytical purposes: Macro-level (Documents) and Micro-level (Granular Items).
This "Dataset-as-a-Repo" approach ensures that the data is not just a transient output of a pipeline but a versioned, maintained artifact suitable for training high-quality code models.
Methodology & Design Choices
1. The "Abstract-to-Concrete" Philosophy
The core design philosophy here is that "code intelligence" requires understanding both the forest (modules, high-level concepts) and the trees (individual function signatures, property types).
- Raw Input: The
nodejs.all.jsonis a massive, nested structure that can be overwhelming for simple sequential models. - Transformation: We "pulled apart" the JSON to create focused training examples.
2. Dual-Format Output
We intentionally avoided a "one-size-fits-all" schema.
- Documents (
nodejs_documents.jsonl): Preserves the cohesiveness of a module. Good for teaching a model "concept association" (e.g., thatfs.readFilebelongs withfs.writeFile). - Granular (
nodejs_granular.jsonl): Isolates every single function and property. Good for "instruction tuning" (e.g., "Write a function signature forhttp.createServer").
3. File Formats
- JSONL: Chosen for its streaming capabilities and human readability. Perfect for NLP pipelines.
- Parquet: Chosen for the "Granular" dataset to allow fast columnar access, filtering, and analysis (e.g., "Find all methods with > 3 arguments").
Dataset Structure
Output Location
All processed files are located in output/:
output/
├── nodejs_documents.jsonl # High-level module data
├── nodejs_granular.jsonl # Individual API items
└── nodejs_granular.parquet # Parquet version of granular data
Schema: Documents (nodejs_documents.jsonl)
Representing a whole Module (e.g., Buffer, http).
| Field | Type | Description |
|---|---|---|
module_name |
string | Name of the module (e.g., fs). |
type |
string | Usually module or global. |
description |
string | Raw HTML/Markdown description of the module. |
content |
json-string | Full nested JSON blob of the module's contents (methods, props). |
Schema: Granular (nodejs_granular.jsonl)
Representing a single API item (Function, Property, Event).
| Field | Type | Description |
|---|---|---|
id |
string | Unique namespaced ID (e.g., fs.readFile). |
parent |
string | Parent module (e.g., fs). |
type |
string | method, property, event, etc. |
name |
string | Short name (e.g., readFile). |
description |
string | Description of just this item. |
metadata |
json-string | Detailed signatures, params, stability indices. |
Use Cases
1. Pre-Training Code Models
Feed nodejs_documents.jsonl into a language model to teach it the general structure and API surface of Node.js. The large context windows of modern LLMs can easily ingest entire modules.
2. Instruction Tuning / RAG
Use nodejs_granular.jsonl to build a Retrieval Augmented Generation (RAG) system.
- Query: "How do I read a file in Node?"
- Retrieval: Search against the
descriptionfield in the granular dataset. - Context: Retrieve the exact
metadata(signature) forfs.readFile.
3. API Analysis
Use nodejs_granular.parquet with Pandas/DuckDB to answer meta-questions:
- Which Node.js APIs are marked as Experimental?
- What is the average number of arguments for
fsmethods vshttpmethods?
Provenance
- Original File:
datasets/raw/nodejs.all.json - Script:
src/process_nodejs.py - Maintainer: Antigravity (Agent) / User
- Downloads last month
- 13