Skip to content

Commit a326309

Browse files
Sebastien-AhkrinMylesBorins
authored andcommittedDec 17, 2019
lib: replace Symbol.toPrimitive to SymbolToPrimitive primordials
PR-URL: #30905 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent b53e2a8 commit a326309

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed
 

‎lib/buffer.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const {
3535
ObjectDefineProperty,
3636
ObjectSetPrototypeOf,
3737
Symbol,
38+
SymbolToPrimitive,
3839
} = primordials;
3940

4041
const {
@@ -297,8 +298,8 @@ Buffer.from = function from(value, encodingOrOffset, length) {
297298
if (b)
298299
return b;
299300

300-
if (typeof value[Symbol.toPrimitive] === 'function') {
301-
return Buffer.from(value[Symbol.toPrimitive]('string'),
301+
if (typeof value[SymbolToPrimitive] === 'function') {
302+
return Buffer.from(value[SymbolToPrimitive]('string'),
302303
encodingOrOffset,
303304
length);
304305
}

‎lib/os.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
const {
2525
ObjectDefineProperties,
26-
Symbol,
26+
SymbolToPrimitive,
2727
} = primordials;
2828

2929
const { safeGetenv } = internalBinding('credentials');
@@ -73,13 +73,13 @@ const getInterfaceAddresses = getCheckedFunction(_getInterfaceAddresses);
7373
const getOSRelease = getCheckedFunction(_getOSRelease);
7474
const getOSType = getCheckedFunction(_getOSType);
7575

76-
getFreeMem[Symbol.toPrimitive] = () => getFreeMem();
77-
getHostname[Symbol.toPrimitive] = () => getHostname();
78-
getHomeDirectory[Symbol.toPrimitive] = () => getHomeDirectory();
79-
getOSRelease[Symbol.toPrimitive] = () => getOSRelease();
80-
getOSType[Symbol.toPrimitive] = () => getOSType();
81-
getTotalMem[Symbol.toPrimitive] = () => getTotalMem();
82-
getUptime[Symbol.toPrimitive] = () => getUptime();
76+
getFreeMem[SymbolToPrimitive] = () => getFreeMem();
77+
getHostname[SymbolToPrimitive] = () => getHostname();
78+
getHomeDirectory[SymbolToPrimitive] = () => getHomeDirectory();
79+
getOSRelease[SymbolToPrimitive] = () => getOSRelease();
80+
getOSType[SymbolToPrimitive] = () => getOSType();
81+
getTotalMem[SymbolToPrimitive] = () => getTotalMem();
82+
getUptime[SymbolToPrimitive] = () => getUptime();
8383

8484
const kEndianness = isBigEndian ? 'BE' : 'LE';
8585

@@ -117,12 +117,12 @@ function cpus() {
117117
function arch() {
118118
return process.arch;
119119
}
120-
arch[Symbol.toPrimitive] = () => process.arch;
120+
arch[SymbolToPrimitive] = () => process.arch;
121121

122122
function platform() {
123123
return process.platform;
124124
}
125-
platform[Symbol.toPrimitive] = () => process.platform;
125+
platform[SymbolToPrimitive] = () => process.platform;
126126

127127
function tmpdir() {
128128
var path;
@@ -143,12 +143,12 @@ function tmpdir() {
143143

144144
return path;
145145
}
146-
tmpdir[Symbol.toPrimitive] = () => tmpdir();
146+
tmpdir[SymbolToPrimitive] = () => tmpdir();
147147

148148
function endianness() {
149149
return kEndianness;
150150
}
151-
endianness[Symbol.toPrimitive] = () => kEndianness;
151+
endianness[SymbolToPrimitive] = () => kEndianness;
152152

153153
// Returns the number of ones in the binary representation of the decimal
154154
// number.

0 commit comments

Comments
 (0)