{"id":22341788,"url":"https://github.com/weaponsforge/jsalgos","last_synced_at":"2025-03-26T09:28:06.228Z","repository":{"id":51686357,"uuid":"218929612","full_name":"weaponsforge/jsalgos","owner":"weaponsforge","description":"A collection of solutions to classic problems using javascript.","archived":false,"fork":false,"pushed_at":"2024-12-10T11:24:32.000Z","size":74,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T10:44:42.364Z","etag":null,"topics":["algorithms","codewars","javascript","mocha"],"latest_commit_sha":null,"homepage":null,"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/weaponsforge.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}},"created_at":"2019-11-01T06:50:59.000Z","updated_at":"2024-12-10T11:24:35.000Z","dependencies_parsed_at":"2023-01-31T13:40:16.050Z","dependency_job_id":null,"html_url":"https://github.com/weaponsforge/jsalgos","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaponsforge%2Fjsalgos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaponsforge%2Fjsalgos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaponsforge%2Fjsalgos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaponsforge%2Fjsalgos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weaponsforge","download_url":"https://codeload.github.com/weaponsforge/jsalgos/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245625232,"owners_count":20646118,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["algorithms","codewars","javascript","mocha"],"created_at":"2024-12-04T08:08:13.039Z","updated_at":"2025-03-26T09:28:06.207Z","avatar_url":"https://github.com/weaponsforge.png","language":"JavaScript","readme":"# jsalgos\r\n\r\n\u003e A collection of solutions to classic problems using javascript.\r\n\u003e A boilterplate for basic javascript nodejs environment and methods testing with [**mocha**](https://mochajs.org/).\r\n\r\n\r\n### Dependecies\r\n\r\n1. NodeJS\r\n\t- version 10.16.3 was used for this project\r\n2. Windows 10 OS 64-bit\r\n3. VS Code\r\n\t- for debugging (breakpoints)\r\n\u003e [!TIP]\r\n\u003e Follow JavaScript programming best practices and patterns from [Clean Code JavaScript](https://github.com/ryanmcdermott/clean-code-javascript) while solving the CodeWars problems.\r\n\r\n### Content\r\n\r\n1. [Scripts](https://github.com/weaponsforge/jsalgos#scripts)\r\n\t- [main scripts](https://github.com/weaponsforge/jsalgos#scripts-1) - **/scripts**\r\n\t- [utility scripts](https://github.com/weaponsforge/jsalgos#scriptsutils) - **/scripts/utils**\r\n2. [Installation](https://github.com/weaponsforge/jsalgos#installation)\r\n3. [Usage](https://github.com/weaponsforge/jsalgos#usage)\r\n\t- [Create New Scripts](https://github.com/weaponsforge/jsalgos#a-create-new-scripts)\r\n\t- [Testing](https://github.com/weaponsforge/jsalgos#b-testing)\r\n\t- [Debugging](https://github.com/weaponsforge/jsalgos#c-debugging)\r\n\r\n\r\n\r\n## Scripts\r\n\r\n### /scripts\r\n\r\nMain methods and functions are saved inside the **/scripts** directory. These are proposed solutions for [codewars](https://www.codewars.com/) problems.\r\n\r\n#### Usage:\r\n\r\n\tconst methods = require('./scripts')\r\n\tmethods.formatDuration(362)\r\n\tmethods.mixedFraction('97/25')\r\n\tmethods.parseInt('one hundred and five')\r\n\t...\r\n\r\n1. **format-duration.js** - [[link]](https://www.codewars.com/kata/52742f58faf5485cae000b9a)\u003cbr\u003e\r\nAccepts time input in seconds and returns a human-readable conversion format.\r\n\r\n2. **mixed-fraction.js** - [[link]](https://www.codewars.com/kata/556b85b433fb5e899200003f)\u003cbr\u003e\r\nConverts a fraction to its lowest terms mixed fraction form.\r\n\r\n3. **parse-string-int.js** - [[link]](https://www.codewars.com/kata/525c7c5ab6aecef16e0001a5)\u003cbr\u003e\r\nConverts an English string of a number to its numerical value.\r\n\r\n4. **sum-by-factors.js** - [[link]](https://www.codewars.com/kata/54d496788776e49e6b00052f)\u003cbr\u003e\r\nGenerate a list of all prime factors from array elements matched with the sum of array element(s) to which it is a prime factor of.\r\n\r\n5. **smallest.js** - [[link]](https://www.codewars.com/kata/find-the-smallest/javascript)\u003cbr\u003e\r\nGet the smallest combination from the input number while moving only (1) digit.\r\n\r\n6. **top-three-words.js** - [[link]](https://www.codewars.com/kata/51e056fe544cf36c410000fb)\u003cbr\u003e\r\nRetrieves the top (3) most used words from a sentence.\r\n\r\n7. **dependency-injection.js** - [[link]](https://www.codewars.com/kata/dependency-injection/train/javascript)\u003cbr\u003e\r\nTesting for [dependency injection](https://medium.com/@maciekprzybylski/dependency-injection-in-javascript-74f8791ba7c8) where the kata's idea is to be able to execute the functions passed as arguments in any specified order.\r\n\r\n6. **array-rotate.js** - [[link]](https://app.codility.com/programmers/lessons/2-arrays/cyclic_rotation/)\u003cbr\u003e\r\nRotate array A K times; that is, each element of A will be shifted to the right K times.\r\n\r\n7. **binary-gap.js** - [[link]](https://app.codility.com/programmers/lessons/1-iterations/binary_gap/)\u003cbr\u003e\r\nFind the largest binary gap - longest streak of consecutive zeroes between 1's in the binary conversion of a Number\r\n\r\n8. **odd-occurrences.js** - [[link]](https://app.codility.com/programmers/lessons/2-arrays/odd_occurrences_in_array/)\r\n   \u003e A non-empty array A consisting of N integers is given. The array contains an odd number of elements, and each element of the array can be paired with another element that has the same value, except for one element that is left unpaired.\r\n   - Goal is to write a function that, given an array A consisting of N integers fulfilling the above conditions, returns the value of the unpaired element.\r\n\r\n9. **mergesort.js**\u003cbr\u003e\r\nClassic javascript implementation of the merge sort method\r\n\r\n### /scripts/utils\r\n\r\nContains various reusable utility scripts. Methods and functions are saved inside the **/scripts/utils** directory.\r\n\r\n#### Usage:\r\n\r\n\r\n\tconst { factors, Binary, findRepeating } = require('./scripts/utils')\r\n\tfactors(25)\r\n\tBinary.toNumber('101')\r\n\tfindRepeating(145614561852)\r\n\t...\r\n\r\n\r\n1. **factors.js**\u003cbr\u003e\r\nReturns an array of a number's factors not including itself.\r\n\r\n2. **binary.js**\r\n`toNumber`: Converts a str\u003cbr\u003eing of binary sequence into its number format.\r\n`toBinary`: Converts a Number into Binary format\r\n\r\n3. **findRepeating.js** (WIP)\u003cbr\u003e\r\nFinds the repeating sequence of a number in `String` format.\r\n\r\n\r\n## Installation\r\n\r\n1. Clone this repository.\r\n`https://github.com/weaponsforge/jsalgos.git`\r\n\r\n2. Install dependencies.\r\n`npm install`\r\n\r\n\r\n\r\n## Usage\r\n\r\n\r\n### A. Create New Scripts\r\n\r\n1. Create a new script for **module.exports** inside **/scripts/\\*.js** following the format `\u003cMETHOD-NAME\u003e.js`\r\n2. Require the newly-created script inside **/scripts/index.js**\r\n3. Refer to the **Testing** and **Debugging** sections to test your new script.\r\n\r\n\r\n\r\n### B. Testing\r\n\r\n1. To run current tests:\u003cbr\u003e\r\n`npm test`\r\n\r\n2. To create or edit new tests:\r\n\t- Edit existing test values from **/test/test-values/\\*.js** that corresponds as input to target functions from **/scripts/\\*.js** For example, `mixedfraction-test.js` are valid test values for `format-duration.js` or\r\n\t- Create new test values following the format `\u003cMETHOD_NAME\u003e-test.js` inside **/test/test-values/\\*.js**. Add it as **modules.exports** to **/test/test-values/index.js**\r\n\r\n3. Use the new or updated tests:\r\n\t- Open **/test/test-values/test.js**. Edit this script as needed for testing.\r\n\t- Write [**mocha**](https://mochajs.org/) tests for the target function available in the `method` object (i.e., `method.formatDuration()`, etc.) using your new test values available in the `tests` object.\r\n\r\n\t\t\ttests.mixedFraction.forEach((item, index) =\u003e {\r\n\t\t\t  it(`Test Passed: Value === ${item.answer}`, () =\u003e {\r\n\t\t\t    assert.equal(method.formatDuration(item.input), item.answer)\r\n\t\t\t  })\r\n\t\t\t})\r\n\r\n\t- Run the tests: `npm test`\r\n\r\n\r\n\r\n### C. Debugging\r\n\r\n**Debug** using VS Code.\r\n\r\n1. Open `jsalgos/index.js`\r\n2. Call the function to evaluate, for example `format-duration.js`\r\n\r\n\t\tconst script = require('./scripts')\r\n\t\tlet a = script.formatDuration(120)\r\n\t\tconsole.log(a)\r\n\r\n3. Set breakpoints in `/scripts/format-duration.js` using VS Code.\r\n4. Start debugging: Press **F5**\r\n\r\n20191101\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweaponsforge%2Fjsalgos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweaponsforge%2Fjsalgos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweaponsforge%2Fjsalgos/lists"}