-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtmp.ts
More file actions
28 lines (22 loc) · 770 Bytes
/
tmp.ts
File metadata and controls
28 lines (22 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import alpha2 from './data/iso3166.json'
import iso639 from './data/iso639.json'
const formatArray = (arr: string[], chunkSize = 10) => {
const chunks: string[][] = []
for (let i = 0; i < arr.length; i += chunkSize) {
chunks.push(arr.slice(i, i + chunkSize))
}
const formattedChunks = chunks
.map((chunk) => ` ${chunk.map((item) => `'${item}'`).join(', ')}`)
.join(',\n')
const result = `const output = [\n${formattedChunks}\n];`
// Write the output to a file
console.log(result)
}
const main = () => {
const foo = Object.keys(iso639.fallbacks)
const bar = foo.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
const baz = {}
bar.map(cc => baz[cc] = iso639.fallbacks[cc])
console.log(JSON.stringify(baz))
}
main()