Skip to content

Commit

Permalink
Use key.startsWith('\\')
Browse files Browse the repository at this point in the history
  • Loading branch information
xxczaki authored Oct 31, 2020
1 parent 3b87c03 commit e6b346e
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
* format(new Date(2014, 1, 11), '{yyyy}-{MM}-{dd}') //=> '2014-01-11'
*/
export const format = (date: Date, exp: string): string => exp.replace(/\\?{.*?}/g, key => {
// Using `key.startsWith('\\')` would grow the minzipped size by a few bytes
// eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
if (key[0] === '\\') {
if (key.startsWith('\\')) {
return key.slice(1);
}

Expand Down

0 comments on commit e6b346e

Please sign in to comment.