Change all occurences of .substr(...) to .substring(...) (#1479)
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
Changes:
|
||||
|
||||
- Optimize `u8aToHex` with direct (non-hex) conversion
|
||||
- Change all occurences of `.substr(...)` to `.substring(...)`
|
||||
|
||||
|
||||
## 9.1.1 Apr 30, 2022
|
||||
|
||||
@@ -33,7 +33,7 @@ export function createDecode ({ coder, ipfs }: Config, validate: ValidateFn): De
|
||||
|
||||
return coder.decode(
|
||||
ipfs && ipfsCompat
|
||||
? value.substr(1)
|
||||
? value.substring(1)
|
||||
: value
|
||||
);
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@ export class DeriveJunction {
|
||||
public static from (value: string): DeriveJunction {
|
||||
const result = new DeriveJunction();
|
||||
const [code, isHard] = value.startsWith('/')
|
||||
? [value.substr(1), true]
|
||||
? [value.substring(1), true]
|
||||
: [value, false];
|
||||
|
||||
result.soft(
|
||||
|
||||
@@ -24,7 +24,7 @@ export function keyExtractPath (derivePath: string): ExtractResult {
|
||||
constructed = parts.join('');
|
||||
|
||||
for (const p of parts) {
|
||||
path.push(DeriveJunction.from(p.substr(1)));
|
||||
path.push(DeriveJunction.from(p.substring(1)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ describe('mnemonicToMiniSecret', (): void => {
|
||||
u8aToHex(mnemonicToMiniSecret(mnemonic, 'Substrate', onlyJs))
|
||||
).toEqual(
|
||||
// mini returned here, only check first 32-bytes (64 hex + 2 prefix)
|
||||
seed.substr(0, 66)
|
||||
seed.substring(0, 66)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ export function formatDecimal (value: string): string {
|
||||
// we rather strip and re-add the negative sign in the output
|
||||
const isNegative = value[0].startsWith('-');
|
||||
const matched = isNegative
|
||||
? value.substr(1).match(NUMBER_REGEX)
|
||||
? value.substring(1).match(NUMBER_REGEX)
|
||||
: value.match(NUMBER_REGEX);
|
||||
|
||||
return matched
|
||||
|
||||
@@ -21,7 +21,7 @@ export function hexStripPrefix (value?: string | null): string {
|
||||
if (!value || value === '0x') {
|
||||
return '';
|
||||
} else if (REGEX_HEX_PREFIXED.test(value)) {
|
||||
return value.substr(2);
|
||||
return value.substring(2);
|
||||
} else if (REGEX_HEX_NOPREFIX.test(value)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -42,11 +42,13 @@ export function hexToU8a (_value?: HexString | string | null, bitLength = -1): U
|
||||
const length = endLength - offset - mod;
|
||||
|
||||
for (let i = 0; i < length; i += 2) {
|
||||
dv.setUint16(i, HEX_TO_U16[value.substr(i * 2, 4)]);
|
||||
const idx = i * 2;
|
||||
|
||||
dv.setUint16(i, HEX_TO_U16[value.substring(idx, idx + 4)]);
|
||||
}
|
||||
|
||||
if (mod) {
|
||||
dv.setUint8(length, HEX_TO_U8[value.substr(value.length - 2, 2)]);
|
||||
dv.setUint8(length, HEX_TO_U8[value.substring(value.length - 2)]);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -59,7 +59,7 @@ function formatWithLength (maxLength: number): (v: unknown) => unknown {
|
||||
|
||||
return r.length < maxLength
|
||||
? v
|
||||
: `${r.substr(0, maxLength)} ...`;
|
||||
: `${r.substring(0, maxLength)} ...`;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -20,5 +20,5 @@ import type { AnyString } from '../types';
|
||||
export function stringShorten (value: AnyString, prefixLength = 6): string {
|
||||
return value.length <= 2 + 2 * prefixLength
|
||||
? value.toString()
|
||||
: `${value.substr(0, prefixLength)}…${value.slice(-prefixLength)}`;
|
||||
: `${value.substring(0, prefixLength)}…${value.slice(-prefixLength)}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user