Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7c3ac42

Browse filesBrowse files
Sebastien-Ahkrintargos
authored andcommitted
lib: replace Symbol.toPrimitive to SymbolToPrimitive primordials
PR-URL: #30905 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent d1702f5 commit 7c3ac42
Copy full SHA for 7c3ac42

File tree

Expand file treeCollapse file tree

2 files changed

+15
-14
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+15
-14
lines changed
Open diff view settings
Collapse file

‎lib/buffer.js‎

Copy file name to clipboardExpand all lines: lib/buffer.js
+3-2Lines changed: 3 additions & 2 deletions
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
}
Collapse file

‎lib/os.js‎

Copy file name to clipboardExpand all lines: lib/os.js
+12-12Lines changed: 12 additions & 12 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.