Skip to content

Commit

Permalink
changing obj to value
Browse files Browse the repository at this point in the history
  • Loading branch information
decareano authored and refack committed Sep 16, 2017
1 parent 5a99d31 commit ca12eec
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,50 +212,51 @@ Buffer.from = function from(value, encodingOrOffset, length) {
return Buffer.from(valueOf, encodingOrOffset, length);


// let b = 1; {
// 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
// );
// }
//
let newBuf;
{

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

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

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

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

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


let b;
{
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
);
}



Expand Down

0 comments on commit ca12eec

Please sign in to comment.