Skip to content

Commit

Permalink
Clearer variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
madarche committed Mar 26, 2022
1 parent 5eb1314 commit e3173b1
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/convict/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const types = {
// alias
types.integer = types.int

const converters = new Map()
const custom_converters = new Map()

const parsers_registry = {'*': JSON.parse}

Expand Down Expand Up @@ -398,12 +398,11 @@ function getFormat(schema, path) {
}

function coerce(k, v, schema, instance) {
// magic coerceing
const format = getFormat(schema, k)

if (typeof v === 'string') {
if (converters.has(format)) {
return converters.get(format)(v, instance, k)
if (custom_converters.has(format)) {
return custom_converters.get(format)(v, instance, k)
}
switch (format) {
case 'port':
Expand Down Expand Up @@ -727,7 +726,7 @@ convict.addFormat = function(name, validate, coerce) {
}
types[name] = validate
if (coerce) {
converters.set(name, coerce)
custom_converters.set(name, coerce)
}
}

Expand Down

0 comments on commit e3173b1

Please sign in to comment.