mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
url,tools,benchmark: replace deprecated substr()
PR-URL: https://github.com/nodejs/node/pull/51546 Refs: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/String/substr Reviewed-By: Jithil P Ponnan <jithil@outlook.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
1 parent
291c1211f2
commit
78dbda1bd3
5 files changed
+10
-6
No files matched your search
@@ -212,6 +212,10 @@ module.exports = {
|
||||
selector: 'ThrowStatement > CallExpression[callee.name=/Error$/]',
|
||||
message: 'Use `new` keyword when throwing an `Error`.',
|
||||
},
|
||||
{
|
||||
selector: "CallExpression[callee.property.name='substr']",
|
||||
message: 'Use String.prototype.slice() or String.prototype.substring() instead of String.prototype.substr()',
|
||||
},
|
||||
{
|
||||
selector: "CallExpression[callee.name='isNaN']",
|
||||
message: 'Use Number.isNaN() instead of the global isNaN() function.',
|
||||
|
||||
@@ -46,7 +46,7 @@ function main({ len, n }) {
|
||||
let header = `GET /hello HTTP/1.1${CRLF}Content-Type: text/plain${CRLF}`;
|
||||
|
||||
for (let i = 0; i < len; i++) {
|
||||
header += `X-Filler${i}: ${Math.random().toString(36).substr(2)}${CRLF}`;
|
||||
header += `X-Filler${i}: ${Math.random().toString(36).substring(2)}${CRLF}`;
|
||||
}
|
||||
header += CRLF;
|
||||
|
||||
|
||||
+1
-1
@@ -958,7 +958,7 @@ Url.prototype.resolveObject = function resolveObject(relative) {
|
||||
srcPath.unshift('');
|
||||
}
|
||||
|
||||
if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
|
||||
if (hasTrailingSlash && (srcPath.join('/').slice(-1) !== '/')) {
|
||||
srcPath.push('');
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -394,8 +394,8 @@ function versionSort(a, b) {
|
||||
b = minVersion(b).trim();
|
||||
let i = 0; // Common prefix length.
|
||||
while (i < a.length && i < b.length && a[i] === b[i]) i++;
|
||||
a = a.substr(i);
|
||||
b = b.substr(i);
|
||||
a = a.substring(i);
|
||||
b = b.substring(i);
|
||||
return +b.match(numberRe)[0] - +a.match(numberRe)[0];
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -320,8 +320,8 @@ function parseSignature(text, sig) {
|
||||
|
||||
const eq = sigParam.indexOf('=');
|
||||
if (eq !== -1) {
|
||||
defaultValue = sigParam.substr(eq + 1);
|
||||
sigParam = sigParam.substr(0, eq);
|
||||
defaultValue = sigParam.substring(eq + 1);
|
||||
sigParam = sigParam.substring(0, eq);
|
||||
}
|
||||
|
||||
// At this point, the name should match. If it doesn't find one that does.
|
||||
|
||||
Reference in new issue
Block a user