@synesthesia-it/syn-node-commons

1.0.1 • Public • Published

syn-node-commons

Utils


createRandomString

Returns a random string with optional prefix
the default optional parameters are:

  • length = 32
  • prefix = ''
const { createRandomString } = require('@synesthesia-it/syn-node-commons/utils');

const randomString = createRandomString(12,'test'); 
// test8ig6Incv

parseBool

Returns the input value parsed to a boolean value,
if the value belongs to this array [0, false, '0', 'false', 'n', 'FALSE', 'N', '', null, undefined] return false

const { parseBool } = require('@synesthesia-it/syn-node-commons/utils');
const parsedValue = parseBool(0); 
// false

getRuntimeInfo

Returns an object with runtime info memory usage in mb

const { getRuntimeInfo } = require('@synesthesia-it/syn-node-commons/utils');
const runTimeInfo = getRuntimeInfo(); 
// {
//     uptime: 0.081,
//     memory: {
//          total: 18,
//         heapTotal: 6,
//          heapUsed: 4,
//     }
// } 

getISOTimeStampFromTimezone

Returns an iso time stamp 'YYYY-MM-DD HH:mm:ss' for the given timezone
the default optional parameters are:

  • timezone = 'Europe/Rome'
  • time = null
const { getISOTimeStampFromTimezone } = require('@synesthesia-it/syn-node-commons/utils');
const isoTimeStamp = getISOTimeStampFromTimezone(); 
// 2019-02-12 12:25:00

Readme

Keywords

none

Package Sidebar

Install

npm i @synesthesia-it/syn-node-commons

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

14.8 kB

Total Files

9

Last publish

Collaborators

  • fabio.pellanda
  • mdnmdn
  • mdnsyn
  • risck256