Skip to content

Commit

Permalink
Merge pull request #2 from rmrantunes/main
Browse files Browse the repository at this point in the history
refactor: função retorna um objeto para ser mais consistente
  • Loading branch information
paulohenriquesn authored Apr 7, 2021
2 parents 955fada + 8359336 commit def1c60
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ Um pacote para descobrir se um determinado dia é feriado nacional 📅
```js

const eFeriado = require('eferiado')
const natal = eFeriado('25/12') // [true,{"nome": "Natal"}]
const _25deDezembro = eFeriado('25/12') // { "eFeriado": true, "nome": "Natal" }

if(natal[0]) {
alert(`É ${natal[1].nome} hoje!`)
if(_25deDezembro.eFeriado) {
alert(`É ${_25deDezembro.nome} hoje!`)
}

```
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const IsADateHoliday = (date) => {
date = date.match(/(\d\d\/\d\d)+/)[0];
const findHoliday = feriados.find(x => x.data == date)
if (findHoliday) {
return [true, { nome: findHoliday.nome }];
return { eFeriado: true, nome: findHoliday.nome };
}
return [false];
return { eFeriado: false, nome: null };
}

module.exports = IsADateHoliday;

0 comments on commit def1c60

Please sign in to comment.