Skip to content

Commit

Permalink
Add getPositionPriorityByType function
Browse files Browse the repository at this point in the history
  • Loading branch information
GllmR committed Sep 2, 2022
1 parent 1a94076 commit 5af1e41
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const voies = require('./lib/voies')
const {extractNumeroSuffixe, rewriteSuffixes} = require('./lib/numeros')
const {extractNumeroSuffixe, rewriteSuffixes, getPositionPriorityByType} = require('./lib/numeros')
const bal = require('./lib/bal')

module.exports = {
...voies,
...bal,
rewriteSuffixes,
extractNumeroSuffixe
extractNumeroSuffixe,
getPositionPriorityByType
}
21 changes: 20 additions & 1 deletion lib/numeros/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
const {chain} = require('lodash')

const POSITION_TYPES_PRIORITY = {
entrée: 10,
bâtiment: 8,
'cage d’escalier': 7,
logement: 6,
'service technique': 5,
'délivrance postale': 3,
parcelle: 2,
segment: 1
}

function getPositionPriorityByType(type) {
if (!type) {
return 0
}

return POSITION_TYPES_PRIORITY[type] || 0
}

function extractNumeroSuffixe(numeroComplet) {
const result = String(numeroComplet).match(/^(\d+)(.*)$/i)
if (!result) {
Expand Down Expand Up @@ -39,4 +58,4 @@ function rewriteSuffixes(adresses) {
.value()
}

module.exports = {extractNumeroSuffixe, rewriteSuffixes}
module.exports = {extractNumeroSuffixe, rewriteSuffixes, getPositionPriorityByType}

0 comments on commit 5af1e41

Please sign in to comment.