Skip to content

Commit

Permalink
replaced substr with substring (#12066)
Browse files Browse the repository at this point in the history
  • Loading branch information
k-rajat19 committed Nov 18, 2021
1 parent 0486a3c commit 7bb400c
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -16,6 +16,8 @@

### Chore & Maintenance

- `[*]` Replaced `substr` method with `substring` ([#12066](https://github.com/facebook/jest/pull/12066))

### Performance

## 27.3.1
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-config/src/utils.ts
Expand Up @@ -65,7 +65,7 @@ export const replaceRootDirInPath = (

return path.resolve(
rootDir,
path.normalize('./' + filePath.substr('<rootDir>'.length)),
path.normalize('./' + filePath.substring('<rootDir>'.length)),
);
};

Expand Down
2 changes: 1 addition & 1 deletion packages/jest-haste-map/src/lib/fast_path.ts
Expand Up @@ -10,7 +10,7 @@ import * as path from 'path';
// rootDir and filename must be absolute paths (resolved)
export function relative(rootDir: string, filename: string): string {
return filename.indexOf(rootDir + path.sep) === 0
? filename.substr(rootDir.length + 1)
? filename.substring(rootDir.length + 1)
: path.relative(rootDir, filename);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/jest-haste-map/src/worker.ts
Expand Up @@ -63,7 +63,7 @@ export async function worker(data: WorkerMessage): Promise<WorkerMetadata> {
} catch (err: any) {
throw new Error(`Cannot parse ${filePath} as JSON: ${err.message}`);
}
} else if (!blacklist.has(filePath.substr(filePath.lastIndexOf('.')))) {
} else if (!blacklist.has(filePath.substring(filePath.lastIndexOf('.')))) {
// Process a random file that is returned as a MODULE.
if (hasteImpl) {
id = hasteImpl.getHasteName(filePath);
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-snapshot/src/index.ts
Expand Up @@ -99,7 +99,7 @@ function stripAddedIndentation(inlineSnapshot: string) {
return inlineSnapshot;
}

lines[i] = lines[i].substr(indentation.length);
lines[i] = lines[i].substring(indentation.length);
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/jest-transform/src/ScriptTransformer.ts
Expand Up @@ -876,9 +876,9 @@ function readCodeCacheFile(cachePath: Config.Path): string | null {
if (content == null) {
return null;
}
const code = content.substr(33);
const code = content.substring(33);
const checksum = createHash('md5').update(code).digest('hex');
if (checksum === content.substr(0, 32)) {
if (checksum === content.substring(0, 32)) {
return code;
}
return null;
Expand Down

0 comments on commit 7bb400c

Please sign in to comment.