Skip to content

Commit

Permalink
formatting fix and scar deleted
Browse files Browse the repository at this point in the history
doc: fix http.ClientRequest method descriptions

fix documentation for methods getHeader, setHeader and removeHeader
for http.ClientRequest class. The documentation said these functions
can be called but they're wasn't describe into the API description yet.

add parameters and general description for each methods.

PR-URL: nodejs#15163
Fixes: nodejs#15048
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>

assert: use Same-value equality in deepStrictEqual

PR-URL: nodejs#15398
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>

formatting fix and scar deleted
  • Loading branch information
decareano committed Sep 22, 2017
1 parent ca12eec commit 5b371f8
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 49 deletions.
86 changes: 37 additions & 49 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,57 +210,50 @@ Buffer.from = function from(value, encodingOrOffset, length) {
const valueOf = value.valueOf && value.valueOf();
if (valueOf !== null && valueOf !== undefined && valueOf !== value)
return Buffer.from(valueOf, encodingOrOffset, length);


//
let newBuf;
{

if (isUint8Array(value)) {
const b = allocate(value.length);
if (b.length === 0)
return b;

_copy(value, b, 0, 0, value.length);
return b;
}

if (value.length !== undefined || isAnyArrayBuffer(value.buffer)) {
if (typeof value.length !== 'number' || value.length !== value.length) {

return new FastBuffer();
}
return fromArrayLike(value);
}

if (value.type === 'Buffer' && Array.isArray(value.data)) {
return fromArrayLike(value.data);
}
};

let newBuf;
{

let b;
{
if (b)
return b;
if (isUint8Array(value)) {
const b = allocate(value.length);
if (b.length === 0)
return b;

if (typeof value[Symbol.toPrimitive] === 'function') {
return Buffer.from(value[Symbol.toPrimitive]('string'),
encodingOrOffset,
length);
}
_copy(value, b, 0, 0, value.length);
return b;
}

throw new errors.TypeError(
'ERR_INVALID_ARG_TYPE',
'first argument',
['string', 'buffer', 'arrayBuffer', 'array', 'array-like object'],
value
);
}
if (value.length !== undefined || isAnyArrayBuffer(value.buffer)) {
if (typeof value.length !== 'number' || value.length !== value.length) {

return new FastBuffer();
}
return fromArrayLike(value);
}

if (value.type === 'Buffer' && Array.isArray(value.data)) {
return fromArrayLike(value.data);
}
}

const b = newBuf;
{
if (b)
return b;

if (typeof value[Symbol.toPrimitive] === 'function') {
return Buffer.from(value[Symbol.toPrimitive]('string'),
encodingOrOffset,
length);
}


throw new errors.TypeError(
'ERR_INVALID_ARG_TYPE',
'first argument',
['string', 'buffer', 'arrayBuffer', 'array', 'array-like object'],
value
);
}
};

Object.setPrototypeOf(Buffer, Uint8Array);
Expand Down Expand Up @@ -427,11 +420,6 @@ function fromArrayBuffer(obj, byteOffset, length) {
return new FastBuffer(obj, byteOffset, length);
}

// function fromObject(obj) { //the body of this function is inline
// //console.error(process.argv.join(' ')); remove this line later

// };

Buffer.isBuffer = function isBuffer(b) {
return b instanceof Buffer;
};
Expand Down
37 changes: 37 additions & 0 deletions syntax_repo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
run `git fetch`
11:33 AM `git checkout test-buffer-edit+

./node tools/eslint/bin/eslint.js --rulesdir=tools/eslint-rules --fix lib/buffer.js

node benchmark/buffers/buffer-from.js
./node test/parallel/test-buffer-from.js
debugger;Buffer.from(new Uint8Array([0x74, 0x65, 0x73, 0x74]));


# Pastebin TyYDdZcH
if (typeof value[Symbol.toPrimitive] === 'function') {
return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length);
}

=>

Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length);

=>

Buffer.from(someFunc('string'), encodingOrOffset, length);

=>

Buffer.from('test', 'utf-8', undefined)

=>

Buffer([0x74, 0x65, 0x73, 0x74])

buffer file: inline for resume

performance was bad
function call was only used once.
opportunity for refactoring
inline function in place of function call.
1 change: 1 addition & 0 deletions test.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"binary", "filename", "configuration", "rate", "time"

0 comments on commit 5b371f8

Please sign in to comment.