{"id":21997723,"url":"https://github.com/osfunapps/os-tools-npm","last_synced_at":"2026-04-18T19:31:50.623Z","repository":{"id":98762396,"uuid":"196209056","full_name":"osfunapps/os-tools-npm","owner":"osfunapps","description":"This module contains fundamental scripts to implement in an npm project","archived":false,"fork":false,"pushed_at":"2021-02-07T15:07:48.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-31T01:30:15.089Z","etag":null,"topics":["filehandle","foundemental","npm","tools","utils"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/osfunapps.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-07-10T13:20:06.000Z","updated_at":"2025-10-04T15:37:18.000Z","dependencies_parsed_at":"2023-05-25T05:30:35.166Z","dependency_job_id":null,"html_url":"https://github.com/osfunapps/os-tools-npm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/osfunapps/os-tools-npm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osfunapps%2Fos-tools-npm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osfunapps%2Fos-tools-npm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osfunapps%2Fos-tools-npm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osfunapps%2Fos-tools-npm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/osfunapps","download_url":"https://codeload.github.com/osfunapps/os-tools-npm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osfunapps%2Fos-tools-npm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31982527,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T17:30:12.329Z","status":"ssl_error","status_checked_at":"2026-04-18T17:29:59.069Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["filehandle","foundemental","npm","tools","utils"],"created_at":"2024-11-29T22:17:53.149Z","updated_at":"2026-04-18T19:31:50.605Z","avatar_url":"https://github.com/osfunapps.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Introduction\n------------\n\nThis module contains fundamental functions to implement in an npm project.\n\n## Installation\nInstall via npm:\n```js\nnpm i os-tools\n```\n\n## Usage       \nRequire tools:\n```js        \nvar tools = require(\"os-tools\")\n```\n\n## Functions and signatures:\n```js\n/**\n * Will wait for a given time\n */\ndelay: function (timeout) {\n    return new Promise((resolve) =\u003e {\n        setTimeout(resolve, timeout);\n    });\n},\n\n/**\n * Will remove everything except numbers from a given string\n */\nonlyNumericFromStr: function (str) {\n    return str.replace(/\\D+/g, '');\n},\n\n/**\n * Will remove everything except alpha from a given string\n */\nonlyAlphaFromStr: function (str) {\n    return str.replace('[\\\\p{Alnum},\\\\s#\\\\-.]');\n},\n\n/**\n * Wll run a cmd command\n */\nrunCmd: function (cmd) {\n    return new Promise(function (resolve) {\n        var exec = require('child_process').exec;\n        var coffeeProcess = exec(cmd);\n\n        coffeeProcess.stdout.on('data', function (data) {\n            console.log(data);\n        });\n\n        coffeeProcess.stdout.on('close', function () {\n            resolve()\n        });\n\n        coffeeProcess.stdout.on('error', function (err) {\n            console.log(\"Error running cmd command: \");\n            throw  err\n        });\n    }.bind())\n},\n\n/**\n * Will prompt the user with a question and return the answer.\n *\n * @param question -\u003e the question to ask the user\n */\npromptUser: function (question) {\n    return new Promise((resolve, reject) =\u003e {\n        const {stdin, stdout} = process;\n\n        stdin.resume();\n        stdout.write(question + \"\\n\");\n\n        stdin.on('data', data =\u003e resolve(data.toString().trim()));\n        stdin.on('error', err =\u003e reject(err));\n    })\n}\n,\n\n\n/**\n * Will return today's date.\n *\n * @param numbersSeparator -\u003e the separator to use between the numbers\n */\ngetTodaysDate: function (numbersSeparator) {\n    const dateObj = new Date();\n    const year = dateObj.getUTCFullYear().toString().substring(2);\n    const month = dateObj.getUTCMonth() + 1;\n    const day = dateObj.getUTCDate();\n    return day + numbersSeparator + month + numbersSeparator + year\n},\n\n/**\n * Will filter a list by val list\n *\n * @param arr -\u003e the list to filter\n * @param remove -\u003e set to true if you want to remove the element found, else false so they will be removed\n * @param vals -\u003e the values to look for\n * @param caseSensitive -\u003e true to case sensitive\n * @return {Array}\n */\nfilterListByVals: function (arr, remove = false, vals = [], caseSensitive = false) {\n    let resArr = [];\n    if (remove) {\n        resArr = arr\n    }\n    for (let i = 0; i \u003c vals.length; i++) {\n        if (remove) {\n            resArr = self.filterListByVal(resArr, remove, vals[i], caseSensitive);\n        } else {\n            let arr2 = self.filterListByVal(arr, remove, vals[i], caseSensitive);\n            resArr = self.mergeArrays([resArr, arr2], true)\n        }\n    }\n\n\n    return resArr\n},\n\n/**\n * Will filter a list by val\n */\nfilterListByVal: function (arr, remove = false, val, caseSensitive = false) {\n    if (caseSensitive) {\n        if (remove) {\n            return arr.filter((data) =\u003e !(data.includes(val)));\n        } else {\n            return arr.filter((data) =\u003e data.includes(val));\n        }\n    } else {\n        if (remove) {\n            return arr.filter((data) =\u003e !(data.toLowerCase().includes(val.toLowerCase())))\n        } else {\n            return arr.filter((data) =\u003e data.toLowerCase().includes(val.toLowerCase()));\n        }\n    }\n},\n\n/**\n * Will replace all char occurrences\n */\nreplaceAll: function (str, find, replace) {\n    return str.replace(new RegExp(find, 'g'), replace);\n},\n\n/**\n * Will return the string representation of an object\n */\ntoStringRepresenation(obj) {\n    return JSON.stringify(obj)\n},\n\n/**\n * Will merge a bunch of arrays together\n */\nmergeArrays: function (arraysList = [], uniqueElements = false) {\n    let finalArr = [];\n    for (let i = 0; i \u003c arraysList.length; i++) {\n        if (uniqueElements) {\n            finalArr = finalArr.filter(value =\u003e -1 === arraysList[i].indexOf(value))\n        } else {\n            finalArr = finalArr.concat(arraysList[i])\n        }\n    }\n    return finalArr\n},\n\n/**\n * Will filter a dictionary by key\n */\nfilterDictByKey: function (dictt, name, remove = false, caseSensitive = false) {\n    if (caseSensitive) {\n        if (remove) {\n            return dictt.filter(o =\u003e !(Object.keys(o).some(k =\u003e o[k].includes(name))));\n        } else {\n            return dictt.filter(o =\u003e Object.keys(o).some(k =\u003e o[k].includes(name)));\n        }\n    } else {\n        if (remove) {\n            return dictt.filter(o =\u003e !(Object.keys(o).some(k =\u003e o[k].toLowerCase().includes(name.toLowerCase()))));\n        } else {\n            return dictt.filter(o =\u003e Object.keys(o).some(k =\u003e o[k].toLowerCase().includes(name.toLowerCase())));\n        }\n    }\n}    \n```\n    \nAnd more...\n\n\n## Links -\u003e see more tools\n* [os-tools-npm](https://github.com/osfunapps/os-tools-npm) -\u003e This module contains fundamental functions to implement in an npm project\n* [os-file-handler-npm](https://github.com/osfunapps/os-file-handler-npm) -\u003e This module contains fundamental files manipulation functions to implement in an npm project\n* [os-file-stream-handler-npm](https://github.com/osfunapps/os-file-stream-handler-npm) -\u003e This module contains read/write and more advanced operations on files\n* [os-xml-handler-npm](https://github.com/osfunapps/os-xml-handler-npm) -\u003e This module will build, read and manipulate an xml file. Other handy stuff is also available, like search for specific nodes\n\n[GitHub - osapps](https://github.com/osfunapps)\n\n\n## Licence\nISC","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosfunapps%2Fos-tools-npm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fosfunapps%2Fos-tools-npm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosfunapps%2Fos-tools-npm/lists"}