@6thbridge/utils
v0.2.25
Published
simple interface for the our commonly used functions
Downloads
590
Readme
bridge-utils
bridge-utils - This is a utility package for reused component
Installation
"dependencies": {
"@6thbridge/utils": "^0.2.25" // see the "releases" section
}
npm install @6thbridge/utils
Requirements
const utils = require('bridge-mix');
Phone Number Formatter (Single)
- To format a single phone number
let phoneNumber = '08012345678';
phoneNumber = utils.helpers.formatPhoneNumber(phoneNumber, 'NG');
console.log(phoneNumber); //2348012345678
Phone Number Formatter (Multiple)
- To format an array of phone numbers
let phoneNumbers = ['08012345678', '08012345679'];
phoneNumbers = utils.helpers.formatPhoneNumberArray(phoneNumbers, 'NG');
console.log(phoneNumbers); //['2348012345678','2348012345679']
Remove Empty Fields from Data
- To format an array of phone numbers
let data = {
foo: '',
bar: 'value',
};
data = utils.helpers.removeFieldsWithEmptyValue(data);
console.log(data); //{"bar":"value"}
Logger
- Log data
logger.error('This is an error from the package', { foo: 'bar' }, new Error().stack);
logger.warn('This is an warning message from the package', { foo: 'bar' }, new Error().stack);
logger.debug('This is an debug message from the package', { foo: 'bar' }, new Error().stack);
logger.critical('This is a critical message from the package', { foo: 'bar' }, new Error().stack);
logger.info('This is a info message from the package', { foo: 'bar' }, new Error().stack);
logger.exception(new Error('Custom Error'), { foo: 'bar' }, new Error().stack);
logger.out(new Error('Custom Error'), { foo: 'bar' }, new Error().stack); //to console, only logs out when LOG_OUT=1
Tests
Cli
npm install
npm test