Skip to content

Commit

Permalink
packages/cli: Switch from substr (deprecated) to slice (#9849)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe authored Jan 18, 2024
1 parent 6d74a22 commit f16b136
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/cli/src/commands/generate/service/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export const buildScenario = async (model) => {
const value = scenarioData[key]

if (value && typeof value === 'string' && value.match(/^\d+n$/)) {
scenarioData[key] = `${value.substr(0, value.length - 1)}n`
scenarioData[key] = `${value.slice(0, value.length - 1)}n`
}
})

Expand All @@ -141,13 +141,13 @@ export const buildScenario = async (model) => {
export const buildStringifiedScenario = async (model) => {
const scenario = await buildScenario(model)

return JSON.stringify(scenario, (key, value) => {
return JSON.stringify(scenario, (_key, value) => {
if (typeof value === 'bigint') {
return value.toString()
}

if (typeof value === 'string' && value.match(/^\d+n$/)) {
return Number(value.substr(0, value.length - 1))
return Number(value.slice(0, value.length - 1))
}

return value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

// BigInt
if (string.match(/^\"\d+n\"$/)) {
return string.substr(1, string.length - 2)
return string.slice(1, string.length - 1)
}

return string
Expand Down

0 comments on commit f16b136

Please sign in to comment.