{"id":17988178,"url":"https://github.com/program-spiritual/algorithminjs","last_synced_at":"2025-04-04T03:24:41.674Z","repository":{"id":57175974,"uuid":"150121824","full_name":"program-spiritual/algorithmInJS","owner":"program-spiritual","description":"😎Encapsulate the collection of commonly used algorithms for node.js 😎","archived":false,"fork":false,"pushed_at":"2018-12-23T07:23:53.000Z","size":97,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-12T09:40:46.034Z","etag":null,"topics":["algo","algorithm","algorithm-challenges","algorithm-library","algorithms-implemented","nodejs"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/algorithminjs","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/program-spiritual.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-24T15:07:46.000Z","updated_at":"2019-01-28T01:52:18.000Z","dependencies_parsed_at":"2022-09-04T11:01:43.888Z","dependency_job_id":null,"html_url":"https://github.com/program-spiritual/algorithmInJS","commit_stats":null,"previous_names":["yiyandaoren/algorithminjs","program-spiritual/algorithminjs","xiaomiwujiecao/algorithminjs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/program-spiritual%2FalgorithmInJS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/program-spiritual%2FalgorithmInJS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/program-spiritual%2FalgorithmInJS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/program-spiritual%2FalgorithmInJS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/program-spiritual","download_url":"https://codeload.github.com/program-spiritual/algorithmInJS/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247114485,"owners_count":20885944,"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":["algo","algorithm","algorithm-challenges","algorithm-library","algorithms-implemented","nodejs"],"created_at":"2024-10-29T19:10:53.822Z","updated_at":"2025-04-04T03:24:41.659Z","avatar_url":"https://github.com/program-spiritual.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n[![Travis (.org)](https://img.shields.io/travis/xiaomiwujiecao/algorithmInJS.svg)](https://travis-ci.org/xiaomiwujiecao/algorithmInJS)\n\n\n\n# algorithmInJS\n\n- A collection of commonly used algorithms for encapsulating node.js\n\n- Written in TypeScript for easy writing of smooth code\n\n## Description\n\n- Long-term maintenance of the library, in order to achieve a variety of more common algorithms, but also to witness the charm of JS\n\n- This library is only suitable for self-learning and discussion, please do not use in production environment\n\n- This library uses the MIT protocol, welcome to submit a pull Request\n\n\n\n## start using\n\n- If you want to use and test in the form of npm package\n\n```\nnpm i algorithminjs -D\n\n```\nUsed in node\n\n```javascript\nlet algorithminjs = require('algorithminjs')\n\n // import form\nimport algorithmInJS from 'algorithminjs'\n\n```\n\n\n### Document ( [中文](./README_CN.md))\n\n\n\u003e Using ArrayQueue.ts array queue\n\n```TypeScript\nlet {ArrayQueue} = require('../index')\nlet arrayQueue = new ArrayQueue(8)\n//enqueue\nconsole.log('enqueue::', arrayQueue.enqueue('a'))\nconsole.log('arrayQueue:', arrayQueue)\nconsole.log('enqueue::', arrayQueue.enqueue('b'))\nconsole.log('arrayQueue:', arrayQueue)\n// dequeue\nconsole.log('dequeue:', arrayQueue.dequeue())\nconsole.log('dequeue show :', arrayQueue)\n```\n\n\n\u003e Using ArrayStack.ts array stack\n\n```TypeScript\nlet {ArrayStack} = require('../index')\nlet arrayStack = new ArrayStack(5)\nconsole.log(arrayStack.push(4))\nconsole.log(arrayStack.items)\nexpect(arrayStack.items).to.be.a('array')\n```\n\n\u003e Using BinarySearch.ts binary search\n\n```TypeScript\nlet {BinarySearch} = require('../index')\nlet a = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1].reverse()\nlet n = a.length\nlet val = 8\nlet bs = new BinarySearch()\nconsole.log('bs', bs)\nlet result = bs.bsearchInternally(a, 0, n - 1, val)\nconsole.log('result:', result)\n```\n\n\u003e Using CircleQueue.ts Loop Queue\n\n```TypeScript\nlet {CircleQueue} = require('../index')\nlet circleQueue = new CircleQueue(8)\nconsole.log('circleQueue:', circleQueue.enqueue('jame'))\nconsole.log('circleQueue:', circleQueue.enqueue('tom'))\nconsole.log('circleQueue:', circleQueue.enqueue('jerry'))\nconsole.log('circleQueue:', circleQueue)\n```\n\n\u003e Sorting by CountingSort.ts Count\n\n```TypeScript\nlet {CountingSort} = require('../index')\n// let mergeSort = new MergeSort()\nvar a = [11,10,9,8,7,6,5,4,3,2,1]\nvar n = a.length\nConsole.time('countingSort')\nCountingSort.countingSort(a,n)\n// quickSort.mergeSortInternally(a, 0)\nconsole.timeEnd('countingSort')\nconsole.log('array:', a)\n```\n\n\n\u003e Implementation using the Heap.ts heap algorithm\n\n```\n\n\n```\n\n\u003e MergeSort.ts merge sort algorithm\n\n```TypeScript\nlet {MergeSort} = require('../index')\n// let mergeSort = new MergeSort()\nvar a = [1, 23, 45, 56, 2, 3, 34, 22]\nvar n = a.length\nConsole.time('mergeSort')\nvar mergeSort = new MergeSort(a, n)\nmergeSort.mergeSortInternally(a, 0)\nconsole.timeEnd('mergeSort')\nconsole.log('array:', a)\n```\n\n\u003e Implemented using the Nodes.ts binary tree node algorithm\n\n```TypeScript\nlet {Nodes} = require('../index')\nvar node1 = new Nodes(5)\nNode1.insert(2)\nNode1.insert(4)\nconsole.log(node1)\n\n// delete\nConsole.time('delete')\nNode1.delete(3)\nconsole.timeEnd('delete')\nconsole.log('deleted::',node1)\n```\n\n\u003e Implemented using the QuickSort.ts quick sort algorithm\n\n```TypeScript\nlet {QuickSort} = require('../index')\n// let mergeSort = new MergeSort()\nvar a = [11,10,9,8,7,6,5,4,3,2,1]\nvar n = a.length\nConsole.time('mergeSort')\nvar quickSort = new QuickSort(a, n)\n// quickSort.mergeSortInternally(a, 0)\nconsole.timeEnd('mergeSort')\nconsole.log('array:', a)\n```\n\n\u003e Implemented with SyncPromise.ts asynchronous logic synchronous queue algorithm\n\n```TypeScript\nlet {SyncPromise} = require('../index')\nlet syncPromise = new SyncPromise()\nconsole.log(syncPromise)\nlet self = this\nConst a = (option) =\u003e {\nReturn new Promise((resolve, reject) =\u003e {\nconsole.log(option)\nResolve(option)\n}\n)\n}\n\nlet ids = [1, 2, 3, 4, 5, 6, 7, 8, 9]\n\nFunction method(option) {\nReturn (callback) =\u003e {\na(option).then(data =\u003e {\nCallback(null, data)\n})\n}\n}\n\nlet arrayOfCallback = ids.map(id =\u003e {\nReturn method(id)\n})\nsyncPromise.seriesOfArray(arrayOfCallback)\nexpect(arrayOfCallback).to.be.a('array')\n```\n\n\u003e Using the Util.ts helper function\n\n```TypeScript\nlet {Util} = require('../index')\nlet testUrl = 'https://translate.google.com/?view=home\u0026op=translate\u0026sl=en\u0026tl=zh-CN\u0026text=what%20i%20want%20to%20do%20is%20that'\nlet getJSON = Util.url2json(testUrl)\nconsole.log(\"getJSON:\",getJSON)\nexpect(getJSON).to.be.a('object')\n```\n\n\n```TypeScript\nlet {Util} = require('../index')\nlet testObj = {\nView: 'home',\nOp: 'translate',\nSl: 'en',\nTl: 'zh-CN',\nText: 'what i want to do is that'\n}\nlet getUrl = Util.json2url(testObj)\nconsole.log('getUrl::',getUrl)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogram-spiritual%2Falgorithminjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprogram-spiritual%2Falgorithminjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogram-spiritual%2Falgorithminjs/lists"}