My personalize node utilities for creating node applications
npm install mnm-node-utilities bash
npm install mnm-node-utilities
`
$3
` bash
npm install mmichaelnorward777/mnm-node-utilities
`
------------------------------------------------------------------------
π Usage
` js
const { getFormattedDateStr, getNumberOfDaysOfMonth, objectToDotNotation, dotNotationToObject } = require("mnm-node-utilities");
// Example
const date = getFormattedDateStr(new Date());
console.log(date); // sample result would be 'January 5, 2025'
let dt = new Date(),
numberOfDaysOfMonth = getNumberOfDaysOfMonth(dt);
console.log(numberOfDaysOfMonth) // 28 || 29 || 30 || 31 depending on the current month of the date object
// objectToDotNotation - good for using objects as query params and converting nested objects into dot notation, which works with mongoose
let person = {
firstName : "John",
lastName : "Doe",
familyMembers : {
spouse : {
firstName : "Jane",
lastName : "Doe",
},
son : {
firstName : "George",
lastName : "Doe"
}
}
},
dotNotatedPerson = objectToDotNotation(person);
console.log(dotNotatedPerson);
/*
this would log:
{
firstName : "John",
lastName : "Doe",
familyMembers.spuse.firstName : "Jane",
familyMembers.spuse.lastName : "Doe",
familyMembers.son.lastName : "George",
familyMembers.spuse.lastName : "Doe",
}
*/
// we can also revert dot notated objects back to its original form (nested objects);
let revertedObject = dotNotationToObject(dotNotatedPerson);
console.log(revertedObject);
/*
this would log:
{
firstName : "John",
lastName : "Doe",
familyMembers : {
spouse : {
firstName : "Jane",
lastName : "Doe",
},
son : {
firstName : "George",
lastName : "Doe"
}
}
}
*/
`
Utilities are grouped logically by category for easier navigation.
------------------------------------------------------------------------
π Available Functions
Below is the full list of exposed functions currently available in the
package.
> Detailed usage documentation will be added over time.\
> For now, this serves as a complete reference list of what you can
> import and use.
------------------------------------------------------------------------
ποΈ Date Functions
- formattedDate
- getFormattedTime
- dateTimeObject
- getTimeElapsed
- createZuluStartDate
- getOffsetMinutesForTimezone
- toISOZeroOffset
- getHourlyDuration
- getDurationInMinutes
- localDateToSelectedTimeZone
- getCurrentMonthByIndex
- getNextMonth
- getPrevMonth
- getNumberOfDaysOfMonth
- getIsoFormattedTime
- getISOFormattedDate
- getFormattedDateStr
- fixTimeStr
- createTzScheduleObject
- checkDateFlow
- getForwardDateRangeObjects
- getBackwardDateRangeObjects
- getDateRangeObjects
- getDateRangeObjectsWithIsoZeroOffset
------------------------------------------------------------------------
π File System Functions
- baseName\
- fileExists\
- isFile\
- isDirectory\
- getFileExt\
- getParentDir\
- readdir\
- readdirSync\
- mkdir\
- mkdirSync\
- deleteDir\
- deleteDirSync\
- readFile\
- readFileSync\
- writeFile\
- writeFileSync\
- deleteFile\
- deleteFileSync\
- isFileEmpty\
- isFileEmptySync\
- isDirectoryEmpty\
- isDirectoryEmptySync\
- getAllFilesFromDirectory\
- getAllFilesFromDirectorySync\
- getAllDirsFromDirectory\
- getAllDirsFromDirectorySync\
- getFileObject\
- getAllFilesRecursively\
- getAllFilesRecursivelySync\
- deleteAllFilesInDirPath\
- deleteAllDirsInDirPath\
- deleteAllInDirPath\
- deleteAllEmptyFilesInDirectory\
- deleteAllEmptyDirsInDirectory\
- getMimeType\
- getFileExtensionsByMimeType\
- getSpecifiedExt\
- getFileSize\
- createSvgFile\
- createDirPath\
- getAppDataDirPath
------------------------------------------------------------------------
π§Ύ JSON Functions
- createJsonFileObject\
- parseValidatedJSON
------------------------------------------------------------------------
βοΈ Node-Related Functions
- spawnOnChildProcess\
- getRequestResult\
- createNodeModule\
- sendDataToMainProcess\
- getAppDataDirPath
------------------------------------------------------------------------
π§© Object & Array Functions
- getValidatedPropValues\
- isObjectInArray\
- getAllObjectKeys\
- sortObjectsByDate\
- objectToString\
- isObjectUnique\
- filterUnlistedObjects\
- shuffleArr\
- sortObjectsByPropName\
- objectCompare\
- assignProps\
- deepObjectAssignment
------------------------------------------------------------------------
π‘ String Functions
- toUrl\
- toCapitalize\
- toCapitalizeAll\
- toNormalString\
- getInitials\
- toCamelCase
------------------------------------------------------------------------
π URL Functions
- urlConstructor\
- objectToQueryString\
- urlToQueryStringObject\
- objectToDotNotation\
- dotNotationToObject\
- queryStringToObject\
- getDomain\
- cleanApiUrl\
- checkSubDomain
------------------------------------------------------------------------
π₯οΈ Web-Page Related Functions
- xhrDetector\
- scrollToBottom\
- scrollToBottomByCondition\
- scrollToElement\
- scrollToTop\
- toggleScroll\
- waitForSelector\
- typeIt\
- createJSONBlob\
- downloadJsonFile\
- downloadAllJsonFiles\
- downloadCsvData\
- readBlobData\
- zipData\
- timedReload\
- detectDOMChanges
------------------------------------------------------------------------
π Web-Requests Functions
- apiRequest\
- postDataObjects\
- verifyUrl\
- dynamicApiRequest\
- getRequestResult
------------------------------------------------------------------------
π§ Miscellaneous Functions
- filterObjectsByMethodName\
- dynamicRequire\
- slowDown\
- getAllCombination\
- rgb2hex\
- pxToPt\
- encodeURILowerCasedSpecialChars
------------------------------------------------------------------------
πΊοΈ Geo-Timezone Functions
- getCoords\
- geoTzLookUp\
- getGeoTzObject\
- mapAddressLookup
------------------------------------------------------------------------
β‘ Process & EventEmitter Utilities
` js
nodeProcess: {
classConstructor: ProcessClass,
classFactory: processClassFactory,
},
nodeEvent: {
classConstructor: EventClass
}
``