Skip to content

Commit

Permalink
fix: Remove replaceAll with replace(/.../g,... for ES2019 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech committed Feb 27, 2023
1 parent 18baeaa commit d9ce852
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/ssz/src/util/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
export const Case = {
snake: (field: string): string =>
field
.replaceAll(/[^0-z]/g, "")
.replaceAll(/[a-z][A-Z]|[0-9][A-Z]/g, (substr) => substr[0] + "_" + substr[1].toLowerCase()),
.replace(/[^0-z]/g, "")
.replace(/[a-z][A-Z]|[0-9][A-Z]/g, (substr) => substr[0] + "_" + substr[1].toLowerCase()),
constant: (field: string): string =>
field
.replaceAll(/[^0-z]/g, "")
.replaceAll(/[a-z][A-Z]|[0-9][A-Z]/g, (substr) => substr[0] + "_" + substr[1])
.replace(/[^0-z]/g, "")
.replace(/[a-z][A-Z]|[0-9][A-Z]/g, (substr) => substr[0] + "_" + substr[1])
.toUpperCase(),
pascal: (field: string): string => {
const first = field[0].toUpperCase();
return (first + field.slice(1)).replaceAll(/[^0-z]/g, "");
return (first + field.slice(1)).replace(/[^0-z]/g, "");
},
camel: (field: string): string => {
return field[0].toLowerCase() + field.slice(1);
Expand All @@ -23,8 +23,8 @@ export const Case = {
first +
field
.slice(1)
.replaceAll(/[^0-z]/g, "")
.replaceAll(/[a-z][A-Z]|[0-9][A-Z]/g, (substr) => substr[0] + "-" + substr[1])
.replace(/[^0-z]/g, "")
.replace(/[a-z][A-Z]|[0-9][A-Z]/g, (substr) => substr[0] + "-" + substr[1])
);
},
eth2: (field: string): string => Case.snake(field).replace(/(\d)$/, "_$1"),
Expand Down

0 comments on commit d9ce852

Please sign in to comment.