This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const ms = require('ms'); | |
| const c = require('colors'); | |
| class Debugger { | |
| debug(description) { | |
| let prevTime = this.prevTime; | |
| let curr = +new Date(); | |
| let milliseconds = curr - (prevTime || curr); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function toMoney(value) { | |
| value += ''; | |
| x = value.split('.'); | |
| x1 = x[0]; | |
| x2 = ''; | |
| if (x.length > 1 ) { | |
| if (x[1].length < 2) { | |
| x[1] = x[1]+'0'; | |
| } else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { DateTime } = require('luxon') | |
| function eachDays(d1, d2, response = 'DateTime') { | |
| let parse = (date) => { | |
| switch(date.constructor) { | |
| case Date: | |
| return DateTime.fromJSDate(date).startOf('day') | |
| case String: | |
| return DateTime.fromSQL(date).startOf('day') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const currency = (value, decimalPlaces = 2, symbol = true) => { | |
| let formatedValue = parseFloat(value).toFixed(decimalPlaces) | |
| .replace('.', ',') | |
| .replace(/\d(?=(\d{3})+,)/g, '$&.') | |
| return (symbol) ? `R$ ${formatedValue}` : formatedValue | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const MongoClient = require('mongodb').MongoClient | |
| const url = `mongodb://root:mo1542653!@localhost:27017/?authMechanism=SCRAM-SHA-1&authSource=admin` | |
| var _connInstance | |
| const getInstance = async () => { | |
| if (!_connInstance) { | |
| _connInstance = await getConnection() | |
| } | |
| return _connInstance |
OlderNewer