Skip to content

Commit

Permalink
Use ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Mar 11, 2021
1 parent 02f8ed0 commit 907b99e
Show file tree
Hide file tree
Showing 9 changed files with 2,231 additions and 2,223 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
*.log
coverage/
node_modules/
yarn.lock
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
*.json
coverage/
*.md
34 changes: 18 additions & 16 deletions build.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
'use strict'

var fs = require('fs')
var https = require('https')
var concat = require('concat-stream')
var unified = require('unified')
var parse = require('rehype-parse')
var $ = require('hast-util-select')
var toString = require('hast-util-to-string')
import fs from 'fs'
import https from 'https'
import concat from 'concat-stream'
import unified from 'unified'
import parse from 'rehype-parse'
import $ from 'hast-util-select'
import toString from 'hast-util-to-string'

var headerToField = {
'Global Code': 'global',
Expand All @@ -27,8 +25,6 @@ var headerToField = {
'Developed / Developing Countries': 'status'
}

var booleanFields = ['ldc', 'lldc', 'sids']

// From big to small:
var types = ['global', 'region', 'subregion', 'intermediate', 'area']

Expand Down Expand Up @@ -70,7 +66,7 @@ function onconcat(buf) {
throw new Error('Cannot handle superfluous cell: ', cells[index], index)
}

if (booleanFields.includes(field)) {
if (field === 'ldc' || field === 'lldc' || field === 'sids') {
value = /^x$/i.test(value)
}

Expand Down Expand Up @@ -109,8 +105,8 @@ function onconcat(buf) {
} else {
byCode[code] = {
type: kind,
name: name,
code: code,
name,
code,
iso3166: prefix === 'area' ? record.iso3166 : undefined,
stack: stack.concat()
}
Expand All @@ -137,6 +133,12 @@ function onconcat(buf) {
return entry
})

fs.writeFileSync('index.json', JSON.stringify(codes, null, 2) + '\n')
fs.writeFileSync('to-iso-3166.json', JSON.stringify(toIso, null, 2) + '\n')
fs.writeFileSync(
'index.js',
'export var unM49 = ' +
JSON.stringify(codes, null, 2) +
'\n\nexport var toIso3166 = ' +
JSON.stringify(toIso, null, 2) +
'\n'
)
}
Loading

0 comments on commit 907b99e

Please sign in to comment.