Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace deprecated String.prototype.substr() #1836

Merged
merged 1 commit into from
Apr 14, 2022
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
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class Dayjs {
weekdays, months, meridiem
} = locale
const getShort = (arr, index, full, length) => (
(arr && (arr[index] || arr(this, str))) || full[index].substr(0, length)
(arr && (arr[index] || arr(this, str))) || full[index].slice(0, length)
)
const get$H = num => (
Utils.s($H % 12 || 12, num, '0')
Expand Down
4 changes: 2 additions & 2 deletions src/plugin/customParseFormat/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const expressions = {
MMM: [matchWord, function (input) {
const months = getLocalePart('months')
const monthsShort = getLocalePart('monthsShort')
const matchIndex = (monthsShort || months.map(_ => _.substr(0, 3))).indexOf(input) + 1
const matchIndex = (monthsShort || months.map(_ => _.slice(0, 3))).indexOf(input) + 1
if (matchIndex < 1) {
throw new Error()
}
Expand Down Expand Up @@ -161,7 +161,7 @@ function makeParser(format) {
start += token.length
} else {
const { regex, parser } = token
const part = input.substr(start)
const part = input.slice(start)
const match = regex.exec(part)
const value = match[0]
parser.call(time, value)
Expand Down
2 changes: 1 addition & 1 deletion src/plugin/localeData/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default (o, c, dayjs) => { // locale needed later
const locale = ins.name ? ins : ins.$locale()
const targetLocale = getLocalePart(locale[target])
const fullLocale = getLocalePart(locale[full])
const result = targetLocale || fullLocale.map(f => f.substr(0, num))
const result = targetLocale || fullLocale.map(f => f.slice(0, num))
if (!localeOrder) return result
const { weekStart } = locale
return result.map((_, index) => (result[(index + (weekStart || 0)) % 7]))
Expand Down