Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: edit LTS labels section #24369

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions COLLABORATOR_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -794,8 +794,8 @@ TSC for further discussion.

#### How are LTS Branches Managed?

There are multiple LTS branches, e.g. `v8.x` and `v6.x`. Each of these is paired
with a staging branch: `v8.x-staging` and `v6.x-staging`.
There are multiple LTS branches, e.g. `v10.x, `v8.x` and `v6.x`. Each of these is paired
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
There are multiple LTS branches, e.g. `v10.x, `v8.x` and `v6.x`. Each of these is paired
There are multiple LTS branches, e.g. `v10.x`, `v8.x` and `v6.x`. Each of these is paired

with a staging branch: `v10.x-staging`, `v8.x-staging` and `v6.x-staging`.

As commits land on the master branch, they are cherry-picked back to each
staging branch as appropriate. If the commit applies only to the LTS branch, the
Expand All @@ -817,10 +817,18 @@ on backporting, please see the [backporting guide][].

Several LTS related issue and PR labels have been provided:

* `lts-watch-v10.x` - tells the LTS WG that the issue/PR needs to be considered
for landing in the `v10.x-staging` branch.
* `lts-watch-v8.x` - tells the LTS WG that the issue/PR needs to be considered
for landing in the `v8.x-staging` branch.
* `lts-watch-v6.x` - tells the LTS WG that the issue/PR needs to be considered
for landing in the `v6.x-staging` branch.
* `lts-watch-v4.x` - tells the LTS WG that the issue/PR needs to be considered
for landing in the `v4.x-staging` branch.
* `land-on-v10.x` - tells the release team that the commit should be landed
in a future v10.x release
* `land-on-v8.x` - tells the release team that the commit should be landed
in a future v8.x release
* `land-on-v6.x` - tells the release team that the commit should be landed
in a future v6.x release
* `land-on-v4.x` - tells the release team that the commit should be landed
Expand Down
23 changes: 6 additions & 17 deletions doc/api/util.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Util
# Util

<!--introduced_in=v0.10.0-->

Expand Down Expand Up @@ -421,7 +421,7 @@ changes:
* `depth` {number} Specifies the number of times to recurse while formatting
the `object`. This is useful for inspecting large complicated objects. To
make it recurse up to the maximum call stack size pass `Infinity` or `null`.
**Default:** `20`.
**Default:** `2`.
* `colors` {boolean} If `true`, the output will be styled with ANSI color
codes. Colors are customizable, see [Customizing `util.inspect` colors][].
**Default:** `false`.
Expand Down Expand Up @@ -478,23 +478,12 @@ util.inspect(new Bar()); // 'Bar {}'
util.inspect(baz); // '[foo] {}'
```

The following example limits the inspected output of the `paths` property:
The following example inspects all properties of the `util` object:

```js
const util = require('util');

console.log(util.inspect(module, { depth: 0 }));
// Instead of showing all entries in `paths` `[Array]` is used to limit the
// output for readability:

// Module {
// id: '<repl>',
// exports: {},
// parent: undefined,
// filename: null,
// loaded: false,
// children: [],
// paths: [Array] }
console.log(util.inspect(util, { showHidden: true, depth: null }));
```

The following example highlights the difference with the `compact` option:
Expand All @@ -510,7 +499,7 @@ const o = {
'foo']], 4],
b: new Map([['za', 1], ['zb', 'test']])
};
console.log(util.inspect(o, { compact: true, breakLength: 80 }));
console.log(util.inspect(o, { compact: true, depth: 5, breakLength: 80 }));

// This will print

Expand All @@ -524,7 +513,7 @@ console.log(util.inspect(o, { compact: true, breakLength: 80 }));
// b: Map { 'za' => 1, 'zb' => 'test' } }

// Setting `compact` to false changes the output to be more reader friendly.
console.log(util.inspect(o, { compact: false, breakLength: 80 }));
console.log(util.inspect(o, { compact: false, depth: 5, breakLength: 80 }));

// {
// a: [
Expand Down
3 changes: 3 additions & 0 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const { IncomingMessage } = require('_http_incoming');
const {
ERR_HTTP_HEADERS_SENT,
ERR_HTTP_INVALID_STATUS_CODE,
ERR_INVALID_ARG_TYPE,
ERR_INVALID_CHAR
} = require('internal/errors').codes;
const Buffer = require('buffer').Buffer;
Expand Down Expand Up @@ -281,6 +282,8 @@ function Server(options, requestListener) {
options = {};
} else if (options == null || typeof options === 'object') {
options = util._extend({}, options);
} else {
throw new ERR_INVALID_ARG_TYPE('options', 'object', options);
}

this[kIncomingMessage] = options.IncomingMessage || IncomingMessage;
Expand Down
49 changes: 28 additions & 21 deletions lib/internal/priority_queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,13 @@ module.exports = class PriorityQueue {

insert(value) {
const heap = this[kHeap];
let pos = ++this[kSize];
const pos = ++this[kSize];
heap[pos] = value;

if (heap.length === pos)
heap.length *= 2;

const compare = this[kCompare];
const setPosition = this[kSetPosition];
while (pos > 1) {
const parent = heap[pos / 2 | 0];
if (compare(parent, value) <= 0)
break;
heap[pos] = parent;
if (setPosition !== undefined)
setPosition(parent, pos);
pos = pos / 2 | 0;
}
heap[pos] = value;
if (setPosition !== undefined)
setPosition(value, pos);
this.percolateUp(pos);
}

peek() {
Expand Down Expand Up @@ -77,18 +65,37 @@ module.exports = class PriorityQueue {
setPosition(item, pos);
}

percolateUp(pos) {
const heap = this[kHeap];
const compare = this[kCompare];
const setPosition = this[kSetPosition];
const item = heap[pos];

while (pos > 1) {
const parent = heap[pos / 2 | 0];
if (compare(parent, item) <= 0)
break;
heap[pos] = parent;
if (setPosition !== undefined)
setPosition(parent, pos);
pos = pos / 2 | 0;
}
heap[pos] = item;
if (setPosition !== undefined)
setPosition(item, pos);
}

removeAt(pos) {
const heap = this[kHeap];
const size = --this[kSize];
heap[pos] = heap[size + 1];
heap[size + 1] = undefined;

if (size > 0) {
// If not removing the last item, update the shifted item's position.
if (pos <= size && this[kSetPosition] !== undefined)
this[kSetPosition](heap[pos], pos);

this.percolateDown(1);
if (size > 0 && pos <= size) {
if (pos > 1 && this[kCompare](heap[pos / 2 | 0], heap[pos]) > 0)
this.percolateUp(pos);
else
this.percolateDown(pos);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/internal/util/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const hasOwnProperty = uncurryThis(Object.prototype.hasOwnProperty);

const inspectDefaultOptions = Object.seal({
showHidden: false,
depth: 20,
depth: 2,
colors: false,
customInspect: true,
showProxy: false,
Expand Down
5 changes: 2 additions & 3 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,8 @@ function hasOwnProperty(obj, prop) {
// and it can be overridden by custom print functions, such as `probe` or
// `eyes.js`.
const writer = exports.writer = (obj) => util.inspect(obj, writer.options);
writer.options = Object.assign({},
util.inspect.defaultOptions,
{ showProxy: true, depth: 2 });
writer.options =
Object.assign({}, util.inspect.defaultOptions, { showProxy: true });

exports._builtinLibs = builtinLibs;

Expand Down
14 changes: 6 additions & 8 deletions lib/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,7 @@ Object.defineProperty(Zlib.prototype, 'bytesRead', {
// `params()` function should not happen while a write is currently in progress
// on the threadpool.
function paramsAfterFlushCallback(level, strategy, callback) {
if (!this._handle)
assert(false, 'zlib binding closed');
assert(this._handle, 'zlib binding closed');
this._handle.params(level, strategy);
if (!this._hadError) {
this._level = level;
Expand Down Expand Up @@ -507,8 +506,8 @@ function processChunkSync(self, chunk, flushFlag) {
else
buffers.push(out);
nread += out.byteLength;
} else if (have < 0) {
assert(false, 'have should not go down');
} else {
assert(have === 0, 'have should not go down');
}

// exhausted the output buffer, or used all the input create a new one.
Expand Down Expand Up @@ -545,8 +544,7 @@ function processChunkSync(self, chunk, flushFlag) {

function processChunk(self, chunk, flushFlag, cb) {
var handle = self._handle;
if (!handle)
assert(false, 'zlib binding closed');
assert(handle, 'zlib binding closed');

handle.buffer = chunk;
handle.cb = cb;
Expand Down Expand Up @@ -593,8 +591,8 @@ function processCallback() {
var out = self._outBuffer.slice(self._outOffset, self._outOffset + have);
self._outOffset += have;
self.push(out);
} else if (have < 0) {
assert(false, 'have should not go down');
} else {
assert(have === 0, 'have should not go down');
}

if (self.destroyed) {
Expand Down
8 changes: 8 additions & 0 deletions test/parallel/test-console-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ test({ a: { a: 1, b: 2, c: 3 } }, `
└─────────┴───┴───┴───┘
`);

test({ a: { a: { a: 1, b: 2, c: 3 } } }, `
┌─────────┬──────────┐
│ (index) │ a │
├─────────┼──────────┤
│ a │ [Object] │
└─────────┴──────────┘
`);

test({ a: [1, 2] }, `
┌─────────┬───┬───┐
│ (index) │ 0 │ 1 │
Expand Down
13 changes: 13 additions & 0 deletions test/parallel/test-http-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ const http = require('http');
const url = require('url');
const qs = require('querystring');

// TODO: documentation does not allow Array as an option, so testing that
// should fail, but currently http.Server does not typecheck further than
// if `option` is `typeof object` - so we don't test that here right now
const invalid_options = [ 'foo', 42, true ];

invalid_options.forEach((option) => {
assert.throws(() => {
new http.Server(option);
}, {
code: 'ERR_INVALID_ARG_TYPE'
});
});

let request_number = 0;
let requests_sent = 0;
let server_response = '';
Expand Down
30 changes: 30 additions & 0 deletions test/parallel/test-priority-queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,33 @@ const PriorityQueue = require('internal/priority_queue');

assert.strictEqual(queue.shift(), undefined);
}


{
// Checks that removeAt respects binary heap properties
const queue = new PriorityQueue((a, b) => {
return a.value - b.value;
}, (node, pos) => (node.position = pos));

const i3 = { value: 3, position: null };
const i7 = { value: 7, position: null };
const i8 = { value: 8, position: null };

queue.insert({ value: 1, position: null });
queue.insert({ value: 6, position: null });
queue.insert({ value: 2, position: null });
queue.insert(i7);
queue.insert(i8);
queue.insert(i3);

assert.strictEqual(i7.position, 4);
queue.removeAt(4);

// 3 should percolate up to swap with 6 (up)
assert.strictEqual(i3.position, 2);

queue.removeAt(2);

// 8 should swap places with 6 (down)
assert.strictEqual(i8.position, 4);
}
9 changes: 0 additions & 9 deletions test/parallel/test-stream-buffer-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
require('../common');
const assert = require('assert');
const BufferList = require('internal/streams/buffer_list');
const util = require('util');

// Test empty buffer list.
const emptyList = new BufferList();
Expand Down Expand Up @@ -31,11 +30,3 @@ assert.strictEqual(list.join(','), 'foo');
const shifted = list.shift();
assert.strictEqual(shifted, buf);
assert.deepStrictEqual(list, new BufferList());

const tmp = util.inspect.defaultOptions.colors;
util.inspect.defaultOptions = { colors: true };
assert.strictEqual(
util.inspect(list),
'BufferList { head: \u001b[1mnull\u001b[22m, tail: \u001b[1mnull\u001b[22m,' +
' length: \u001b[33m0\u001b[39m }');
util.inspect.defaultOptions = { colors: tmp };
16 changes: 6 additions & 10 deletions test/parallel/test-util-inspect-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,13 @@ const expected1 = 'Proxy [ {}, {} ]';
const expected2 = 'Proxy [ Proxy [ {}, {} ], {} ]';
const expected3 = 'Proxy [ Proxy [ Proxy [ {}, {} ], {} ], Proxy [ {}, {} ] ]';
const expected4 = 'Proxy [ Proxy [ {}, {} ], Proxy [ Proxy [ {}, {} ], {} ] ]';
const expected5 = 'Proxy [ Proxy [ Proxy [ Proxy [ {}, {} ], {} ],' +
const expected5 = 'Proxy [ Proxy [ Proxy [ Proxy [Array], {} ],' +
' Proxy [ {}, {} ] ],\n Proxy [ Proxy [ {}, {} ]' +
', Proxy [ Proxy [ {}, {} ], {} ] ] ]';
const expected6 = 'Proxy [ Proxy [ Proxy [ Proxy [ Proxy [ {}, {} ], {} ], ' +
'Proxy [ {}, {} ] ],\n' +
' Proxy [ Proxy [ {}, {} ], ' +
'Proxy [ Proxy [ {}, {} ], {} ] ] ],\n' +
' Proxy [ Proxy [ Proxy [ Proxy [ {}, {} ], {} ], ' +
'Proxy [ {}, {} ] ],\n' +
' Proxy [ Proxy [ {}, {} ], ' +
'Proxy [ Proxy [ {}, {} ], {} ] ] ] ]';
', Proxy [ Proxy [Array], {} ] ] ]';
const expected6 = 'Proxy [ Proxy [ Proxy [ Proxy [Array], Proxy [Array]' +
' ],\n Proxy [ Proxy [Array], Proxy [Array] ] ],\n' +
' Proxy [ Proxy [ Proxy [Array], Proxy [Array] ],\n' +
' Proxy [ Proxy [Array], Proxy [Array] ] ] ]';
assert.strictEqual(
util.inspect(proxy1, { showProxy: true, depth: null }),
expected1);
Expand Down
Loading