◐ Shell
clean mode source ↗

test_runner: replace native methods with primordials · nodejs/node@243e6b2

Original file line numberDiff line numberDiff line change

@@ -9,6 +9,7 @@ const {

99

SafeMap,

1010

String,

1111

StringPrototypeReplaceAll,

12+

StringPrototypeSlice,

1213

} = primordials;

1314

const {

1415

codes: {

@@ -291,7 +292,7 @@ function validateFunctionArray(fns, name) {

291292

}

292293
293294

function escapeSnapshotKey(str) {

294-

let result = JSONStringify(str, null, 2).slice(1, -1);

295+

let result = StringPrototypeSlice(JSONStringify(str, null, 2), 1, -1);

295296

result = StringPrototypeReplaceAll(result, '`', '\\`');

296297

result = StringPrototypeReplaceAll(result, '${', '\\${');

297298

return result;