Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
Merge nodejs/master into xplat
Browse files Browse the repository at this point in the history
Merge 9b73062 as of 2017-06-01.
This is an automatically created merge. For any problems please
contact @kunalspathak.
  • Loading branch information
chakrabot committed Jun 2, 2017
2 parents 11ead4b + 9b73062 commit 8cf4aa9
Show file tree
Hide file tree
Showing 11 changed files with 239 additions and 200 deletions.
16 changes: 9 additions & 7 deletions doc/api/url.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ that an effort will be made to coerce the given values into strings. For
instance:

```js
const myURL = new URL({toString: () => 'https://example.org/'});
const myURL = new URL({ toString: () => 'https://example.org/' });
// https://example.org/
```

Expand Down Expand Up @@ -186,6 +186,7 @@ console.log(myURL.href);
// Prints https://example.org/foo

myURL.href = 'https://example.com/bar';
console.log(myURL.href);
// Prints https://example.com/bar
```

Expand Down Expand Up @@ -332,7 +333,7 @@ console.log(myURL.protocol);

myURL.protocol = 'ftp';
console.log(myURL.href);
// Prints ftp://example.org
// Prints ftp://example.org/
```

Invalid URL protocol values assigned to the `protocol` property are ignored.
Expand Down Expand Up @@ -380,7 +381,7 @@ console.log(myURL.username);

myURL.username = '123';
console.log(myURL.href);
// Prints https://123:xyz@example.com
// Prints https://123:xyz@example.com/
```

Any invalid URL characters appearing in the value assigned the `username`
Expand Down Expand Up @@ -515,7 +516,7 @@ const params = new URLSearchParams({
query: ['first', 'second']
});
console.log(params.getAll('query'));
// Prints ['first,second']
// Prints [ 'first,second' ]
console.log(params.toString());
// Prints 'user=abc&query=first%2Csecond'
```
Expand Down Expand Up @@ -571,7 +572,8 @@ console.log(params.toString());
new URLSearchParams([
['user', 'abc', 'error']
]);
// Throws TypeError: Each query pair must be a name/value tuple
// Throws TypeError [ERR_INVALID_TUPLE]:
// Each query pair must be an iterable [name, value] tuple
```

#### urlSearchParams.append(name, value)
Expand Down Expand Up @@ -816,8 +818,8 @@ console.log(myURL.href);
console.log(myURL.toString());
// Prints https://a:b@xn--6qqa088eba/?abc#foo

console.log(url.format(myURL, {fragment: false, unicode: true, auth: false}));
// Prints 'https://你好你好?abc'
console.log(url.format(myURL, { fragment: false, unicode: true, auth: false }));
// Prints 'https://你好你好/?abc'
```

## Legacy URL API
Expand Down
9 changes: 3 additions & 6 deletions doc/api/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,6 @@ ES6 example using `class` and `extends`
const EventEmitter = require('events');

class MyStream extends EventEmitter {
constructor() {
super();
}
write(data) {
this.emit('data', data);
}
Expand Down Expand Up @@ -329,8 +326,8 @@ class Box {
// Five space padding because that's the size of "Box< ".
const padding = ' '.repeat(5);
const inner = util.inspect(this.value, newOptions)
.replace(/\n/g, '\n' + padding);
return options.stylize('Box', 'special') + '< ' + inner + ' >';
.replace(/\n/g, `\n${padding}`);
return `${options.stylize('Box', 'special')}< ${inner} >`;
}
}

Expand Down Expand Up @@ -392,7 +389,7 @@ option properties directly is also supported.

```js
const util = require('util');
const arr = Array(101);
const arr = Array(101).fill(0);

console.log(arr); // logs the truncated array
util.inspect.defaultOptions.maxArrayLength = null;
Expand Down
12 changes: 12 additions & 0 deletions doc/api/zlib.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ ignored by the decompression classes.
* `strategy` {integer} (compression only)
* `dictionary` {Buffer|TypedArray|DataView} (deflate/inflate only, empty dictionary by
default)
* `info` {boolean} (If `true`, returns an object with `buffer` and `engine`)

See the description of `deflateInit2` and `inflateInit2` at
<http://zlib.net/manual.html#Advanced> for more information on these.
Expand Down Expand Up @@ -385,6 +386,17 @@ added: v0.5.8
Not exported by the `zlib` module. It is documented here because it is the base
class of the compressor/decompressor classes.

### zlib.bytesRead
<!-- YAML
added: REPLACEME
-->

* {number}

The `zlib.bytesRead` property specifies the number of bytes read by the engine
before the bytes are processed (compressed or decompressed, as appropriate for
the derived class).

### zlib.flush([kind], callback)
<!-- YAML
added: v0.5.8
Expand Down
76 changes: 4 additions & 72 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,81 +196,13 @@ function Stats(
this.ino = ino;
this.size = size;
this.blocks = blocks;
this._atim_msec = atim_msec;
this._mtim_msec = mtim_msec;
this._ctim_msec = ctim_msec;
this._birthtim_msec = birthtim_msec;
this.atime = new Date(atim_msec + 0.5);
this.mtime = new Date(mtim_msec + 0.5);
this.ctime = new Date(ctim_msec + 0.5);
this.birthtime = new Date(birthtim_msec + 0.5);
}
fs.Stats = Stats;

// defining the properties in this fashion (explicitly with no loop or factory)
// has been shown to be the most performant on V8 contemp.
// Ref: https://github.com/nodejs/node/pull/12818
// + 0.5 is added to the Dates to protect values from being rounded down
// Ref: https://github.com/nodejs/node/pull/12607
Object.defineProperties(Stats.prototype, {
atime: {
configurable: true,
enumerable: true,
get() {
return this._atime !== undefined ?
this._atime :
(this._atime = new Date(this._atim_msec + 0.5));
},
set(value) { return this._atime = value; }
},
mtime: {
configurable: true,
enumerable: true,
get() {
return this._mtime !== undefined ?
this._mtime :
(this._mtime = new Date(this._mtim_msec + 0.5));
},
set(value) { return this._mtime = value; }
},
ctime: {
configurable: true,
enumerable: true,
get() {
return this._ctime !== undefined ?
this._ctime :
(this._ctime = new Date(this._ctim_msec + 0.5));
},
set(value) { return this._ctime = value; }
},
birthtime: {
configurable: true,
enumerable: true,
get() {
return this._birthtime !== undefined ?
this._birthtime :
(this._birthtime = new Date(this._birthtim_msec + 0.5));
},
set(value) { return this._birthtime = value; }
},
});

Stats.prototype.toJSON = function toJSON() {
return {
dev: this.dev,
mode: this.mode,
nlink: this.nlink,
uid: this.uid,
gid: this.gid,
rdev: this.rdev,
blksize: this.blksize,
ino: this.ino,
size: this.size,
blocks: this.blocks,
atime: this.atime,
ctime: this.ctime,
mtime: this.mtime,
birthtime: this.birthtime
};
};


Stats.prototype._checkModeProperty = function(property) {
return ((this.mode & S_IFMT) === property);
};
Expand Down
15 changes: 13 additions & 2 deletions lib/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ function isInvalidStrategy(strategy) {
// constants.Z_DEFAULT_STRATEGY (0)
}

function responseData(engine, buffer) {
if (engine._opts.info) {
return { buffer, engine };
}
return buffer;
}

function zlibBuffer(engine, buffer, callback) {
// Streams do not support non-Buffer ArrayBufferViews yet. Convert it to a
// Buffer without copying.
Expand Down Expand Up @@ -121,7 +128,7 @@ function zlibBuffer(engine, buffer, callback) {

buffers = [];
engine.close();
callback(err, buf);
callback(err, responseData(engine, buf));
}
}

Expand All @@ -134,7 +141,7 @@ function zlibBufferSync(engine, buffer) {

var flushFlag = engine._finishFlushFlag;

return engine._processChunk(buffer, flushFlag);
return responseData(engine, engine._processChunk(buffer, flushFlag));
}

function zlibOnError(message, errno) {
Expand Down Expand Up @@ -168,6 +175,8 @@ class Zlib extends Transform {
opts = opts || {};
super(opts);

this.bytesRead = 0;

this._opts = opts;
this._chunkSize = opts.chunkSize || constants.Z_DEFAULT_CHUNK;

Expand Down Expand Up @@ -422,6 +431,8 @@ class Zlib extends Transform {
var have = availOutBefore - availOutAfter;
assert(have >= 0, 'have should not go down');

self.bytesRead += availInBefore - availInAfter;

if (have > 0) {
var out = self._buffer.slice(self._offset, self._offset + have);
self._offset += have;
Expand Down
22 changes: 0 additions & 22 deletions test/parallel/test-fs-stat.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,27 +98,5 @@ fs.stat(__filename, common.mustCall(function(err, s) {
console.log(`isSymbolicLink: ${JSON.stringify(s.isSymbolicLink())}`);
assert.strictEqual(false, s.isSymbolicLink());

assert.ok(s.atime instanceof Date);
assert.ok(s.mtime instanceof Date);
assert.ok(s.ctime instanceof Date);
assert.ok(s.birthtime instanceof Date);
}));

fs.stat(__filename, common.mustCall(function(err, s) {
const json = JSON.parse(JSON.stringify(s));
const keys = [
'dev', 'mode', 'nlink', 'uid',
'gid', 'rdev', 'ino',
'size', 'atime', 'mtime',
'ctime', 'birthtime'
];
if (!common.isWindows) {
keys.push('blocks', 'blksize');
}
keys.forEach(function(k) {
assert.ok(
json[k] !== undefined && json[k] !== null,
k + ' should not be null or undefined'
);
});
}));
86 changes: 0 additions & 86 deletions test/parallel/test-net-server-bind.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/parallel/test-readline-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ function isWarned(emitter) {
});

const rl = readline.createInterface({
input: new Readable({ read: common.noop }),
input: new Readable({ read: common.mustCall() }),
output: output,
prompt: '$ ',
terminal: terminal
Expand Down
Loading

0 comments on commit 8cf4aa9

Please sign in to comment.