{"id":19755045,"url":"https://github.com/ybribri/matrix","last_synced_at":"2026-05-11T01:33:13.882Z","repository":{"id":61394000,"uuid":"550897168","full_name":"ybribri/matrix","owner":"ybribri","description":"class for two dimension array","archived":false,"fork":false,"pushed_at":"2022-10-21T11:29:40.000Z","size":140,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-11T06:05:23.673Z","etag":null,"topics":["2d","2darrays","array-manipulations","class","matrix","node-js","pure-javascript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ybribri.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":"2022-10-13T14:00:08.000Z","updated_at":"2022-10-18T13:52:30.000Z","dependencies_parsed_at":"2023-01-20T09:18:27.061Z","dependency_job_id":null,"html_url":"https://github.com/ybribri/matrix","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ybribri%2Fmatrix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ybribri%2Fmatrix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ybribri%2Fmatrix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ybribri%2Fmatrix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ybribri","download_url":"https://codeload.github.com/ybribri/matrix/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241086216,"owners_count":19907266,"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":["2d","2darrays","array-manipulations","class","matrix","node-js","pure-javascript"],"created_at":"2024-11-12T03:08:05.949Z","updated_at":"2026-05-11T01:33:13.830Z","avatar_url":"https://github.com/ybribri.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Matrix - class for two dimension array\n\n\u003e V1.20 : methods for math added. Refer to the function list below.\n\n* Easy as original Javascript prototype functions\n* All the same prototype functions of array for two dimensional arrays with adjusted arguments\n* Added functions only for this class\n\u003chr style=\"height: 2px;\"\u003e\n\n### \u003c Install \u003e\nneeded only for node.js\n\n```bash\n$ npm i class-matrix    \n```\n\n### \u003c Use - node.js \u003e\n* *common JS*\n```javascript\nconst Matrix = require('class-matrix');\n````\n\n* *ESM*\n```javascript\nimport Matrix from 'class-matrix';\n```\n\u003chr style=\"height: 2px;\"\u003e\n\n### \u003c Use - browser \u003e\n\n* *Link in \\\u003chead\\\u003e tag*\n```html\n\u003cscript src=\"./matrix-js-link.min.js\"\u003e\u003c/script\u003e\n```\n\n* *import in a module file*\n  \n```javascript\nimport { Matrix } from './matrix-js-module.min.js';\n```\n\u003chr style=\"height: 2px;\"\u003e\n\n## \u003c Methods \u003e\n\n* **INIT \u0026 VALUE**\n\n```javascript\nnew Matrix\n.row\n.column\ngetter value\nsetter value\ngetValueOf()\nsetValueOf()   \n```\n* **CHECK \u0026 FIND**\n\n```javascript\nMatrix.isMatrix()\nat()\nfind()\nfindLast()\nfindIndex()\nfindLastIndex()\nindexOf()\nlastIndexOf()\nincludes()\n```\n* **NEW STRUCTURE**\n\n```javascript\nconcat()\nflat()\njoin()\ntoString()\nslice()\n```\n* **ITERATE**\n\n```javascript\nforEach()\nmap()\nreduce()\nreduceRight()\nfilter()\nevery()\nsome()\n```\n* **CHANGE IN PLACE**\n\n```javascript\nfill()\npop()\npush()\nshift()\nunshift()\nsplice()\nsort()\nreverse()\ncopyWithin()\n```\n* **CHANGE IN PLACE**\n\n```javascript\nfill()\npop()\npush()\nshift()\nunshift()\nsplice()\nsort()\nreverse()\ncopyWithin()\n```\n* **GENERATOR**\n\n```javascript\nkeys()\nvalues()\nentries()\n```\n\n* **MATH**\n\n```javascript\ndet()\ncofactors()\ntranspose()\nadjoint()\ninverse()\nadd()\nsubtract()\nmultiply()\ndivide()\n```\n  \n  \n\u003e All the prototype functions are rebuilt for this class.\\\n\u003e In most cases, an index in callback function is seperated into a row index and a column index\\\n\u003e Some prototype functions are added only for matrix class\n\n\u003chr style=\"height: 2px;\"\u003e\n\n## \u003c EXAMPLE \u003e\n  \n```javascript\nlet matrixA = new Matrix(3,3).fill((el,[i,j])=\u003ei+j);\n```\n  \n| 0 | 1 | 2 |\n|---|---|---|\n| **1** | **2** | **3** |\n| **2** | **3** | **4** |\n  \n  \n```javascript\nconsole.log(matrixA.getValueOf([2,2]));\n```\n\n4\n\n  \n```javascript\nmatrixA.setValueOf([2,2],9);\nconsole.log(matrixA.value);\n```\n  \n| 0 | 1 | 2 |\n|---|---|---|\n| **1** | **2** | **3** |\n| **2** | **3** | **9** |\n  \n  \n\n```javascript\nmatrixA.value = [[0,1],[2,3],[4,5]];\nconsole.log(matrixA.value);\nconsole.log(`row = ${matrixA.row}, column = ${matrixA.column}`);\n\n// if you set value directly, it would change the structure of the matrix\n```\n  \n| 0 | 1 |\n|---|---|\n| **2** | **3** |\n| **4** | **5** |\n\nrow = 2, column = 2\n  \n  \n```javascript\nmatrixA.forEach((el, [i,j])=\u003e{\n    console.log(`[${i},${j}] = ${el}`);\n});\n```\n  \n[0,0] = 0  \n[0,1] = 1  \n[0,2] = 2  \n[1,0] = 1  \n[1,1] = 2  \n[1,2] = 3  \n[2,0] = 2  \n[2,1] = 3  \n[2,2] = 4  \n  \n## [Click here for more details of each methods!](https://ybrians.cafe24.com/matrix/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fybribri%2Fmatrix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fybribri%2Fmatrix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fybribri%2Fmatrix/lists"}