Skip to content

Commit d04e6d8

Browse files
committed
chore: more explicit names
1 parent 0a1d464 commit d04e6d8

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

lib/buffer.js

+20-20
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323

2424
const {
2525
Object: {
26-
defineProperties,
27-
defineProperty,
28-
setPrototypeOf,
29-
create
26+
defineProperties: ObjectDefineProperties,
27+
defineProperty: ObjectDefineProperty,
28+
setPrototypeOf: ObjectSetPrototypeOf,
29+
create: ObjectCreate
3030
},
3131
Math: {
32-
floor,
33-
trunc,
34-
min
32+
floor: MathFloor,
33+
trunc: MathTrunc,
34+
min: MathMin
3535
}
3636
} = primordials;
3737

@@ -101,7 +101,7 @@ FastBuffer.prototype.constructor = Buffer;
101101
Buffer.prototype = FastBuffer.prototype;
102102
addBufferPrototypeMethods(Buffer.prototype);
103103

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

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

@@ -180,7 +180,7 @@ function toInteger(n, defaultVal) {
180180
if (!Number.isNaN(n) &&
181181
n >= Number.MIN_SAFE_INTEGER &&
182182
n <= Number.MAX_SAFE_INTEGER) {
183-
return ((n % 1) === 0 ? n : floor(n));
183+
return ((n % 1) === 0 ? n : MathFloor(n));
184184
}
185185
return defaultVal;
186186
}
@@ -265,7 +265,7 @@ function Buffer(arg, encodingOrOffset, length) {
265265
return Buffer.from(arg, encodingOrOffset, length);
266266
}
267267

268-
defineProperty(Buffer, Symbol.species, {
268+
ObjectDefineProperty(Buffer, Symbol.species, {
269269
enumerable: false,
270270
configurable: true,
271271
get() { return FastBuffer; }
@@ -323,7 +323,7 @@ const of = (...items) => {
323323
};
324324
Buffer.of = of;
325325

326-
setPrototypeOf(Buffer, Uint8Array);
326+
ObjectSetPrototypeOf(Buffer, Uint8Array);
327327

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

379-
setPrototypeOf(SlowBuffer.prototype, Uint8Array.prototype);
380-
setPrototypeOf(SlowBuffer, Uint8Array);
379+
ObjectSetPrototypeOf(SlowBuffer.prototype, Uint8Array.prototype);
380+
ObjectSetPrototypeOf(SlowBuffer, Uint8Array);
381381

382382
function allocate(size) {
383383
if (size <= 0) {
@@ -724,15 +724,15 @@ function byteLength(string, encoding) {
724724
Buffer.byteLength = byteLength;
725725

726726
// For backwards compatibility.
727-
defineProperty(Buffer.prototype, 'parent', {
727+
ObjectDefineProperty(Buffer.prototype, 'parent', {
728728
enumerable: true,
729729
get() {
730730
if (!(this instanceof Buffer))
731731
return undefined;
732732
return this.buffer;
733733
}
734734
});
735-
defineProperty(Buffer.prototype, 'offset', {
735+
ObjectDefineProperty(Buffer.prototype, 'offset', {
736736
enumerable: true,
737737
get() {
738738
if (!(this instanceof Buffer))
@@ -801,7 +801,7 @@ let INSPECT_MAX_BYTES = 50;
801801
// Override how buffers are presented by util.inspect().
802802
Buffer.prototype[customInspectSymbol] = function inspect(recurseTimes, ctx) {
803803
const max = INSPECT_MAX_BYTES;
804-
const actualMax = min(max, this.length);
804+
const actualMax = MathMin(max, this.length);
805805
const remaining = this.length - max;
806806
let str = this.hexSlice(0, actualMax).replace(/(.{2})/g, '$1 ').trim();
807807
if (remaining > 0)
@@ -814,7 +814,7 @@ Buffer.prototype[customInspectSymbol] = function inspect(recurseTimes, ctx) {
814814
extras = true;
815815
obj[key] = this[key];
816816
return obj;
817-
}, create(null));
817+
}, ObjectCreate(null));
818818
if (extras) {
819819
if (this.length !== 0)
820820
str += ', ';
@@ -1054,7 +1054,7 @@ Buffer.prototype.toJSON = function toJSON() {
10541054
function adjustOffset(offset, length) {
10551055
// Use Math.trunc() to convert offset to an integer value that can be larger
10561056
// than an Int32. Hence, don't use offset | 0 or similar techniques.
1057-
offset = trunc(offset);
1057+
offset = MathTrunc(offset);
10581058
if (offset === 0) {
10591059
return 0;
10601060
}
@@ -1175,7 +1175,7 @@ module.exports = {
11751175
kStringMaxLength
11761176
};
11771177

1178-
defineProperties(module.exports, {
1178+
ObjectDefineProperties(module.exports, {
11791179
constants: {
11801180
configurable: false,
11811181
enumerable: true,

0 commit comments

Comments
 (0)