Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/node/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ export function getModule(filename: string | undefined): string | undefined {
let n = path.lastIndexOf('/node_modules/');
if (n > -1) {
// /node_modules/ is 14 chars
return `${path.substr(n + 14).replace(/\//g, '.')}:${file}`;
return `${path.slice(n + 14).replace(/\//g, '.')}:${file}`;
}
// Let's see if it's a part of the main module
// To be a part of main module, it has to share the same base
n = `${path}/`.lastIndexOf(base, 0);

if (n === 0) {
let moduleName = path.substr(base.length).replace(/\//g, '.');
let moduleName = path.slice(base.length).replace(/\//g, '.');
if (moduleName) {
moduleName += ':';
}
Expand Down
12 changes: 6 additions & 6 deletions packages/utils/src/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ function trim(arr: string[]): string[] {
/** JSDoc */
export function relative(from: string, to: string): string {
/* eslint-disable no-param-reassign */
from = resolve(from).substr(1);
to = resolve(to).substr(1);
from = resolve(from).slice(1);
to = resolve(to).slice(1);
/* eslint-enable no-param-reassign */

const fromParts = trim(from.split('/'));
Expand Down Expand Up @@ -126,7 +126,7 @@ export function relative(from: string, to: string): string {
/** JSDoc */
export function normalizePath(path: string): string {
const isPathAbsolute = isAbsolute(path);
const trailingSlash = path.substr(-1) === '/';
const trailingSlash = path.slice(-1) === '/';

// Normalize the path
let normalizedPath = normalizeArray(
Expand Down Expand Up @@ -169,7 +169,7 @@ export function dirname(path: string): string {

if (dir) {
// It has a dirname, strip trailing slash
dir = dir.substr(0, dir.length - 1);
dir = dir.slice(0, dir.length - 1);
}

return root + dir;
Expand All @@ -178,8 +178,8 @@ export function dirname(path: string): string {
/** JSDoc */
export function basename(path: string, ext?: string): string {
let f = splitPath(path)[2];
if (ext && f.substr(ext.length * -1) === ext) {
f = f.substr(0, f.length - ext.length);
if (ext && f.slice(ext.length * -1) === ext) {
f = f.slice(0, f.length - ext.length);
}
return f;
}
10 changes: 5 additions & 5 deletions packages/utils/src/stacktrace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ function node(getModule?: GetModuleFn): StackLineParserFn {
}

if (methodStart > 0) {
object = functionName.substr(0, methodStart);
method = functionName.substr(methodStart + 1);
object = functionName.slice(0, methodStart);
method = functionName.slice(methodStart + 1);
const objectEnd = object.indexOf('.Module');
if (objectEnd > 0) {
functionName = functionName.substr(objectEnd + 1);
object = object.substr(0, objectEnd);
functionName = functionName.slice(objectEnd + 1);
object = object.slice(0, objectEnd);
}
}
typeName = undefined;
Expand All @@ -168,7 +168,7 @@ function node(getModule?: GetModuleFn): StackLineParserFn {
functionName = typeName ? `${typeName}.${methodName}` : methodName;
}

const filename = lineMatch[2]?.startsWith('file://') ? lineMatch[2].substr(7) : lineMatch[2];
const filename = lineMatch[2]?.startsWith('file://') ? lineMatch[2].slice(7) : lineMatch[2];
const isNative = lineMatch[5] === 'native';
const isInternal =
isNative || (filename && !filename.startsWith('/') && !filename.startsWith('.') && filename.indexOf(':\\') !== 1);
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function truncate(str: string, max: number = 0): string {
if (typeof str !== 'string' || max === 0) {
return str;
}
return str.length <= max ? str : `${str.substr(0, max)}...`;
return str.length <= max ? str : `${str.slice(0, max)}...`;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/wasm/src/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function registerModule(module: WebAssembly.Module, url: string): void {
code_id: buildId,
code_file: url,
debug_file: debugFile ? new URL(debugFile, url).href : null,
debug_id: `${buildId.padEnd(32, '0').substr(0, 32)}0`,
debug_id: `${buildId.padEnd(32, '0').slice(0, 32)}0`,
});
}
}
Expand Down