Skip to content

Commit

Permalink
refactor(utils): esm convertion
Browse files Browse the repository at this point in the history
Signed-off-by: Chawye Hsu <[email protected]>
  • Loading branch information
chawyehsu committed Aug 24, 2023
1 parent 8ed52c6 commit 4b55394
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// @ts-check
/**
* @param {string} relative - The relative path of a file
*/
module.exports = relative => {
export default (relative: string) => {
if (relative.startsWith('_posts/')) {
return 'post'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable */

const UNITS = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']

/*
Expand All @@ -8,18 +6,17 @@ Formats the given number using `Number#toLocaleString`.
- If locale is true, the system default locale is used for translation.
- If no value for locale is specified, the number is returned unmodified.
*/
const toLocaleString = (number, locale) => {
let result = number
const toLocaleString = (number: number, locale?: string | boolean) => {
if (typeof locale === 'string') {
result = number.toLocaleString(locale)
return number.toLocaleString(locale)
} else if (locale === true) {
result = number.toLocaleString()
return number.toLocaleString()
}

return result
return number.toString()
}

module.exports = (number, options) => {
export default (number: number, options?: any) => {
if (!Number.isFinite(number)) {
throw new TypeError(
`Expected a finite number, got ${typeof number}: ${number}`
Expand Down

0 comments on commit 4b55394

Please sign in to comment.