This file contains 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
/** | |
* Converts number into formatted currency value. | |
* | |
* @param {Number} val - Integer value | |
* @param {Intl.NumberFormatOptions} options - An object with some or all of the properties of Intl.NumberFormatOptions | |
* @returns formatted value. | |
* | |
* @example | |
* console.log(currencyFormatter(1234567890.1997)); // ₹1,23,45,67,890.20 | |
* console.log(currencyFormatter(1234567890, {locales: "en-US", currency: "USD", maximumFractionDigits: 0})); // $1,234,567,890 |
This file contains 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
/** | |
* Compares all the objects(both key and value) in the given array and returns the unique array. | |
* | |
* @param {Object[]} arr - An array of objects. | |
* @returns unique array of object(s). | |
* | |
* @example uniqueArrayOfObjects([{a: 2}, {a: 2}]); // [{"a": 2}] | |
* @example uniqueArrayOfObjects([{a: {b: 2}}, {a: {b: 2}}]); // [{"a": {"b": 2}}] | |
* @example uniqueArrayOfObjects([{a: 2}, {a: 2, b: 3}]); // [{a: 2}, {a: 2, b: 3}] | |
*/ |
This file contains 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
/** | |
* This method compares both key and value of given objects. This even works for nested objects. | |
* | |
* @param {Object} obj1 | |
* @param {Object} obj2 | |
* @returns boolean | |
* | |
* @example compareObject({a: 2}, {a: 2}); // true | |
* @example compareObject({a: 2}, {a: 23}); // false | |
* @example compareObject({a: {b: 2}}, {a: {b: 2}}); // true |
This file contains 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
/** | |
* Convert an array into given chunk(s). | |
* | |
* @param {any[]} arr - Any type of array | |
* @param {number} n - Number of chunks | |
* @example arrayIntoChunks([1,2,3,4,5,6], 3); | |
* @output [[1,2],[3,4],[5,6]] | |
* | |
* @returns Array of array[s]. | |
*/ |
This file contains 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
/** | |
* Sort array of objects by key(s) | |
* | |
* @param {Object[]} arr - Array of Objects | |
* @param {String[]} keys - Key's to be sorted. [pass hyphen(-) in front of string to order in descending] | |
* @example sortObjectByMultipleKeys(object, ["name", "-date"]) | |
* @example sortObjectByMultipleKeys(object, ["-name", "date"]) | |
* | |
* @returns Sorted array of objects. | |
*/ |
This file contains 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
@Echo Off | |
TASKLIST /FI "IMAGENAME eq node.exe" | |
Echo ================================================================================ | |
Echo: | |
Echo This will stop all running node servers. | |
Echo: | |
Set "#=" | |
Set /P "=Press Y to continue (press any other key to stop) :"<Nul |
This file contains 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
/** | |
* Merges Obj1 data into Obj2. | |
* | |
* @param {Object} obj1 | |
* @param {Object} obj2 | |
* @returns merged object | |
* | |
* @example | |
* const a = {v : [1,2]}; | |
* const b = {v: [3]} |
This file contains 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
/** | |
* Creates table with custom data. | |
* | |
* @param {Object} tableData | |
* @param {Object[]} tableData.data - Array of objects | |
* @param {String[]} tableData.fields - Fields to be shown | |
* @param {String[]} tableData.fieldTitles - Field Names | |
* @param {Object} tableData.tableProps - Field Names | |
* @param {String} tableData.tableProps.id - Table id | |
* @param {String[]} tableData.tableProps.classList - Table custom class list |
This file contains 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
/** | |
* Removes all the key's for which the value is empty. | |
* @param {Object} obj | |
*/ | |
function removeEmptyProperty(obj = {}) { | |
const data = { ...obj }; | |
if (!data) return data; | |
Object.keys(data).forEach((key) => { | |
if (typeof data[key] === "object") data[key] = removeEmptyProperty(data[key]); | |
if (!data[key]) delete data[key]; |
This file contains 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
/** | |
* @param {String} s | |
* @returns number | |
* @example console.log(toNumber("-23.32")) | |
*/ | |
const toNumber = (s, returnStrings = false) => | |
isNaN(Number(s)) ? (returnStrings ? s : console.error(`${s} NaN`)) : Number(s); | |
/** | |
* @param {Array or Object} data - required |