Skip to content

Commit

Permalink
chore: more explicit names
Browse files Browse the repository at this point in the history
  • Loading branch information
jizusun committed Nov 4, 2019
1 parent 0a1d464 commit d04e6d8
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions lib/buffer.js
Expand Up @@ -23,15 +23,15 @@

const {
Object: {
defineProperties,
defineProperty,
setPrototypeOf,
create
defineProperties: ObjectDefineProperties,
defineProperty: ObjectDefineProperty,
setPrototypeOf: ObjectSetPrototypeOf,
create: ObjectCreate
},
Math: {
floor,
trunc,
min
floor: MathFloor,
trunc: MathTrunc,
min: MathMin
}
} = primordials;

Expand Down Expand Up @@ -101,7 +101,7 @@ FastBuffer.prototype.constructor = Buffer;
Buffer.prototype = FastBuffer.prototype;
addBufferPrototypeMethods(Buffer.prototype);

const constants = defineProperties({}, {
const constants = ObjectDefineProperties({}, {
MAX_LENGTH: {
value: kMaxLength,
writable: false,
Expand All @@ -123,7 +123,7 @@ let poolSize, poolOffset, allocPool;
// do not own the ArrayBuffer allocator. Zero fill is always on in that case.
const zeroFill = bindingZeroFill || [0];

const encodingsMap = create(null);
const encodingsMap = ObjectCreate(null);
for (let i = 0; i < encodings.length; ++i)
encodingsMap[encodings[i]] = i;

Expand Down Expand Up @@ -180,7 +180,7 @@ function toInteger(n, defaultVal) {
if (!Number.isNaN(n) &&
n >= Number.MIN_SAFE_INTEGER &&
n <= Number.MAX_SAFE_INTEGER) {
return ((n % 1) === 0 ? n : floor(n));
return ((n % 1) === 0 ? n : MathFloor(n));
}
return defaultVal;
}
Expand Down Expand Up @@ -265,7 +265,7 @@ function Buffer(arg, encodingOrOffset, length) {
return Buffer.from(arg, encodingOrOffset, length);
}

defineProperty(Buffer, Symbol.species, {
ObjectDefineProperty(Buffer, Symbol.species, {
enumerable: false,
configurable: true,
get() { return FastBuffer; }
Expand Down Expand Up @@ -323,7 +323,7 @@ const of = (...items) => {
};
Buffer.of = of;

setPrototypeOf(Buffer, Uint8Array);
ObjectSetPrototypeOf(Buffer, Uint8Array);

// The 'assertSize' method will remove itself from the callstack when an error
// occurs. This is done simply to keep the internal details of the
Expand Down Expand Up @@ -376,8 +376,8 @@ function SlowBuffer(length) {
return createUnsafeBuffer(length);
}

setPrototypeOf(SlowBuffer.prototype, Uint8Array.prototype);
setPrototypeOf(SlowBuffer, Uint8Array);
ObjectSetPrototypeOf(SlowBuffer.prototype, Uint8Array.prototype);
ObjectSetPrototypeOf(SlowBuffer, Uint8Array);

function allocate(size) {
if (size <= 0) {
Expand Down Expand Up @@ -724,15 +724,15 @@ function byteLength(string, encoding) {
Buffer.byteLength = byteLength;

// For backwards compatibility.
defineProperty(Buffer.prototype, 'parent', {
ObjectDefineProperty(Buffer.prototype, 'parent', {
enumerable: true,
get() {
if (!(this instanceof Buffer))
return undefined;
return this.buffer;
}
});
defineProperty(Buffer.prototype, 'offset', {
ObjectDefineProperty(Buffer.prototype, 'offset', {
enumerable: true,
get() {
if (!(this instanceof Buffer))
Expand Down Expand Up @@ -801,7 +801,7 @@ let INSPECT_MAX_BYTES = 50;
// Override how buffers are presented by util.inspect().
Buffer.prototype[customInspectSymbol] = function inspect(recurseTimes, ctx) {
const max = INSPECT_MAX_BYTES;
const actualMax = min(max, this.length);
const actualMax = MathMin(max, this.length);
const remaining = this.length - max;
let str = this.hexSlice(0, actualMax).replace(/(.{2})/g, '$1 ').trim();
if (remaining > 0)
Expand All @@ -814,7 +814,7 @@ Buffer.prototype[customInspectSymbol] = function inspect(recurseTimes, ctx) {
extras = true;
obj[key] = this[key];
return obj;
}, create(null));
}, ObjectCreate(null));
if (extras) {
if (this.length !== 0)
str += ', ';
Expand Down Expand Up @@ -1054,7 +1054,7 @@ Buffer.prototype.toJSON = function toJSON() {
function adjustOffset(offset, length) {
// Use Math.trunc() to convert offset to an integer value that can be larger
// than an Int32. Hence, don't use offset | 0 or similar techniques.
offset = trunc(offset);
offset = MathTrunc(offset);
if (offset === 0) {
return 0;
}
Expand Down Expand Up @@ -1175,7 +1175,7 @@ module.exports = {
kStringMaxLength
};

defineProperties(module.exports, {
ObjectDefineProperties(module.exports, {
constants: {
configurable: false,
enumerable: true,
Expand Down

0 comments on commit d04e6d8

Please sign in to comment.