Skip to content

Commit 7bb400c

Browse files
authored
replaced substr with substring (#12066)
1 parent 0486a3c commit 7bb400c

File tree

6 files changed

+8
-6
lines changed

6 files changed

+8
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
### Chore & Maintenance
1818

19+
- `[*]` Replaced `substr` method with `substring` ([#12066](https://github.com/facebook/jest/pull/12066))
20+
1921
### Performance
2022

2123
## 27.3.1

packages/jest-config/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export const replaceRootDirInPath = (
6565

6666
return path.resolve(
6767
rootDir,
68-
path.normalize('./' + filePath.substr('<rootDir>'.length)),
68+
path.normalize('./' + filePath.substring('<rootDir>'.length)),
6969
);
7070
};
7171

packages/jest-haste-map/src/lib/fast_path.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as path from 'path';
1010
// rootDir and filename must be absolute paths (resolved)
1111
export function relative(rootDir: string, filename: string): string {
1212
return filename.indexOf(rootDir + path.sep) === 0
13-
? filename.substr(rootDir.length + 1)
13+
? filename.substring(rootDir.length + 1)
1414
: path.relative(rootDir, filename);
1515
}
1616

packages/jest-haste-map/src/worker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export async function worker(data: WorkerMessage): Promise<WorkerMetadata> {
6363
} catch (err: any) {
6464
throw new Error(`Cannot parse ${filePath} as JSON: ${err.message}`);
6565
}
66-
} else if (!blacklist.has(filePath.substr(filePath.lastIndexOf('.')))) {
66+
} else if (!blacklist.has(filePath.substring(filePath.lastIndexOf('.')))) {
6767
// Process a random file that is returned as a MODULE.
6868
if (hasteImpl) {
6969
id = hasteImpl.getHasteName(filePath);

packages/jest-snapshot/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function stripAddedIndentation(inlineSnapshot: string) {
9999
return inlineSnapshot;
100100
}
101101

102-
lines[i] = lines[i].substr(indentation.length);
102+
lines[i] = lines[i].substring(indentation.length);
103103
}
104104
}
105105

packages/jest-transform/src/ScriptTransformer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -876,9 +876,9 @@ function readCodeCacheFile(cachePath: Config.Path): string | null {
876876
if (content == null) {
877877
return null;
878878
}
879-
const code = content.substr(33);
879+
const code = content.substring(33);
880880
const checksum = createHash('md5').update(code).digest('hex');
881-
if (checksum === content.substr(0, 32)) {
881+
if (checksum === content.substring(0, 32)) {
882882
return code;
883883
}
884884
return null;

0 commit comments

Comments
 (0)