Skip to content

Commit

Permalink
Update xo
Browse files Browse the repository at this point in the history
  • Loading branch information
jdesboeufs committed Feb 18, 2019
1 parent c05c1c6 commit 9440000
Show file tree
Hide file tree
Showing 7 changed files with 643 additions and 458 deletions.
4 changes: 4 additions & 0 deletions build/download-fimoct.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ async function getDatasetResources() {
if (!result.body && !result.body.resources) {
throw new Error('Unexpected response')
}

return result.body.resources
}

Expand All @@ -27,10 +28,12 @@ async function getLatestFIMOCTArchiveURL() {
if (archives.length === 0) {
throw new Error('No FIMOCT archive found')
}

const latestArchive = getMostRecent(archives)
if (!latestArchive) {
throw new Error('Unable to find the most recent FIMOCT archive')
}

return latestArchive.url
}

Expand All @@ -41,6 +44,7 @@ async function fetchAndExtractFIMOCT(url) {
if (!candidateFile) {
throw new Error('Archive does not contain a FIMOCT file')
}

return candidateFile.data
}

Expand Down
1 change: 1 addition & 0 deletions build/extract-fimoct.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function eachLine(line, enc, cb) {
repetition: borneInferieureRepetition === '' ? undefined : borneInferieureRepetition
}
}

if (borneSuperieure) {
result.borneSuperieure = {
numero: Number.parseInt(borneSuperieure, 10),
Expand Down
6 changes: 3 additions & 3 deletions build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function buildCompact(codesPostaux) {
.value()
}

async function doStuff() {
async function main() {
const buffer = await getCurrentFIMOCTFileBuffer()
const codesPostaux = await extractFromFIMOCT(buffer)
codesPostaux.forEach(e => expandWithCommune(e))
Expand All @@ -45,7 +45,7 @@ async function doStuff() {
await writeAsJSONFile(join(__dirname, '..', 'codes-postaux.json'), codesPostauxCompact)
}

doStuff().catch(err => {
console.error(err)
main().catch(error => {
console.error(error)
process.exit(1)
})
2 changes: 2 additions & 0 deletions full.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function superieurBorneInf(numero, repetition, borneInferieure) {
if (repetition && !borneInferieure.repetition) return true
return repetition >= borneInferieure.repetition
}

if (numero > borneInferieure.numero) return true
if (numero < borneInferieure.numero) return false
}
Expand All @@ -29,6 +30,7 @@ function inferieurBorneSup(numero, repetition, borneSuperieure) {
if (repetition && !borneSuperieure.repetition) return false
return repetition <= borneSuperieure.repetition
}

if (numero > borneSuperieure.numero) return false
if (numero < borneSuperieure.numero) return true
}
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ require('./codes-postaux.json').forEach(entry => {
if (!(entry.codePostal in index)) {
index[entry.codePostal] = []
}

index[entry.codePostal].push(entry)
})

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"into-stream": "^4.0.0",
"split2": "^3.1.0",
"through2": "^3.0.0",
"xo": "^0.20.3"
"xo": "^0.24.0"
},
"xo": {
"semicolon": false,
Expand Down
Loading

0 comments on commit 9440000

Please sign in to comment.