forked from
npmx.dev/npmx.dev
[READ-ONLY]
a fast, modern browser for the npm registry
1export function toIsoDateString(date: Date): string {
2 const year = date.getUTCFullYear()
3 const month = String(date.getUTCMonth() + 1).padStart(2, '0')
4 const day = String(date.getUTCDate()).padStart(2, '0')
5 return `${year}-${month}-${day}`
6}
7
8const htmlEntities: Record<string, string> = {
9 '&': '&',
10 '<': '<',
11 '>': '>',
12 '"': '"',
13 ''': "'",
14 ''': "'",
15 ' ': ' ',
16}
17
18export function decodeHtmlEntities(text: string): string {
19 return text.replace(/&(?:amp|lt|gt|quot|apos|nbsp|#39);/g, match => htmlEntities[match] || match)
20}