From b80c95fa135de4d77a563930bfb828dfa4f25df3 Mon Sep 17 00:00:00 2001 From: Tobias Speicher Date: Sun, 20 Mar 2022 10:33:03 +0100 Subject: [PATCH] refactor: replace deprecated String.prototype.substr() .substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated Signed-off-by: Tobias Speicher --- scripts/create-legacy-tests-bundle.mjs | 2 +- src/circular-deps-test.conf.js | 2 +- tools/markdown-to-html/docs-marked-renderer.ts | 2 +- tools/region-parser/region-parser.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/create-legacy-tests-bundle.mjs b/scripts/create-legacy-tests-bundle.mjs index 57c9119034c3..42a84a9b1e25 100644 --- a/scripts/create-legacy-tests-bundle.mjs +++ b/scripts/create-legacy-tests-bundle.mjs @@ -152,7 +152,7 @@ async function createResolveEsbuildPlugin() { name: 'ng-resolve-esbuild', setup: build => { build.onResolve({filter: /@angular\//}, async args => { - const pkgName = args.path.substr('@angular/'.length); + const pkgName = args.path.slice('@angular/'.length); let resolvedPath = join(legacyOutputDir, pkgName); let stats = await statGraceful(resolvedPath); diff --git a/src/circular-deps-test.conf.js b/src/circular-deps-test.conf.js index 82446d4e020a..04dbc5b81e6c 100644 --- a/src/circular-deps-test.conf.js +++ b/src/circular-deps-test.conf.js @@ -25,7 +25,7 @@ module.exports = { */ function resolveModule(specifier) { if (specifier.startsWith('@angular/')) { - return path.join(__dirname, specifier.substr('@angular/'.length)); + return path.join(__dirname, specifier.slice('@angular/'.length)); } return null; } diff --git a/tools/markdown-to-html/docs-marked-renderer.ts b/tools/markdown-to-html/docs-marked-renderer.ts index 1348fee1e266..e77c851b6d5a 100644 --- a/tools/markdown-to-html/docs-marked-renderer.ts +++ b/tools/markdown-to-html/docs-marked-renderer.ts @@ -48,7 +48,7 @@ export class DocsMarkdownRenderer extends Renderer { // Keep track of all fragments discovered in a file. if (href.startsWith('#')) { - this._referencedFragments.add(href.substr(1)); + this._referencedFragments.add(href.slice(1)); } return super.link(href, title, text); diff --git a/tools/region-parser/region-parser.ts b/tools/region-parser/region-parser.ts index 81e86f51d590..111430256be2 100644 --- a/tools/region-parser/region-parser.ts +++ b/tools/region-parser/region-parser.ts @@ -126,5 +126,5 @@ function leftAlign(lines: string[]): string[] { indent = Math.min(lineIndent, indent); } }); - return lines.map(line => line.substr(indent)); + return lines.map(line => line.slice(indent)); }