Skip to content

Commit

Permalink
Use ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Mar 26, 2021
1 parent e00ff52 commit 8a04321
Show file tree
Hide file tree
Showing 15 changed files with 49,345 additions and 49,328 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.DS_Store
*.log
coverage/
node_modules/
archive.zip
iso-639-3.js
iso-639-3.min.js
yarn.lock
4 changes: 0 additions & 4 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
.nyc_output/
coverage/
iso-639-3.js
iso-639-3.min.js
*.md
*.json
52 changes: 31 additions & 21 deletions build.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
'use strict'

var fs = require('fs')
var path = require('path')
var https = require('https')
var concat = require('concat-stream')
var yauzl = require('yauzl')
var dsv = require('d3-dsv')
var bail = require('bail')
import fs from 'fs'
import path from 'path'
import https from 'https'
import concat from 'concat-stream'
import yauzl from 'yauzl'
import dsv from 'd3-dsv'
import {bail} from 'bail'

var other = []
var found = false
Expand Down Expand Up @@ -85,7 +83,7 @@ function onend() {
}

function onconcat(body) {
var data = dsv.tsvParse(String(body)).map(map)
var data = dsv.tsvParse(String(body)).map((d) => map(d))
var toB = {}
var toT = {}
var to1 = {}
Expand All @@ -99,14 +97,26 @@ function onconcat(body) {
if (d.iso6391) to1[d.iso6393] = d.iso6391
}

write('index', data)
write('to-1', to1)
write('to-2b', toB)
write('to-2t', toT)

function write(name, data) {
fs.writeFile(name + '.json', JSON.stringify(data, null, 2) + '\n', bail)
}
fs.writeFile(
'iso6393.js',
'export var iso6393 = ' + JSON.stringify(data, null, 2) + '\n',
bail
)
fs.writeFile(
'iso6393-to-1.js',
'export var iso6393To1 = ' + JSON.stringify(to1, null, 2) + '\n',
bail
)
fs.writeFile(
'iso6393-to-2b.js',
'export var iso6393To2B = ' + JSON.stringify(toB, null, 2) + '\n',
bail
)
fs.writeFile(
'iso6393-to-2t.js',
'export var iso6393To2T = ' + JSON.stringify(toT, null, 2) + '\n',
bail
)
}

function map(d) {
Expand All @@ -132,9 +142,9 @@ function map(d) {
}

return {
name: name,
type: type,
scope: scope,
name,
type,
scope,
iso6393: id,
iso6392B: d.Part2B || undefined,
iso6392T: d.Part2T || undefined,
Expand Down
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export {iso6393} from './iso6393.js'
export {iso6393To1} from './iso6393-to-1.js'
export {iso6393To2B} from './iso6393-to-2b.js'
export {iso6393To2T} from './iso6393-to-2t.js'
Loading

0 comments on commit 8a04321

Please sign in to comment.