{"id":16252464,"url":"https://github.com/remarkablemark/matrix-transpose","last_synced_at":"2025-03-19T20:31:19.400Z","repository":{"id":36954802,"uuid":"325124076","full_name":"remarkablemark/matrix-transpose","owner":"remarkablemark","description":"Transposes a matrix by switching the row and column indices of a multidimensional array.","archived":false,"fork":false,"pushed_at":"2024-10-29T09:10:35.000Z","size":789,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-29T11:33:13.690Z","etag":null,"topics":["associative-array","javascript","matrix","nodejs","npm","transpose","typescript"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/matrix-transpose","language":"JavaScript","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/remarkablemark.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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},"funding":{"github":["remarkablemark"],"patreon":"remarkablemark","open_collective":null,"ko_fi":"remarkablemark","tidelift":null,"community_bridge":null,"liberapay":"remarkablemark","issuehunt":null,"otechie":null,"custom":["https://b.remarkabl.org/teespring"]}},"created_at":"2020-12-28T21:50:11.000Z","updated_at":"2024-10-29T09:10:18.000Z","dependencies_parsed_at":"2024-01-15T10:58:40.070Z","dependency_job_id":"8bea5ae3-709b-4378-8afa-5ea2cb21090a","html_url":"https://github.com/remarkablemark/matrix-transpose","commit_stats":{"total_commits":337,"total_committers":3,"mean_commits":"112.33333333333333","dds":"0.10979228486646886","last_synced_commit":"7543ecaa82ef2da603cd5bfb850cd66981befaa9"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkablemark%2Fmatrix-transpose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkablemark%2Fmatrix-transpose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkablemark%2Fmatrix-transpose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkablemark%2Fmatrix-transpose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/remarkablemark","download_url":"https://codeload.github.com/remarkablemark/matrix-transpose/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244501315,"owners_count":20462839,"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":["associative-array","javascript","matrix","nodejs","npm","transpose","typescript"],"created_at":"2024-10-10T15:13:47.276Z","updated_at":"2025-03-19T20:31:18.634Z","avatar_url":"https://github.com/remarkablemark.png","language":"JavaScript","readme":"# matrix-transpose\n\n[![NPM](https://nodei.co/npm/matrix-transpose.png)](https://nodei.co/npm/matrix-transpose/)\n\n[![NPM version](https://img.shields.io/npm/v/matrix-transpose.svg)](https://www.npmjs.com/package/matrix-transpose)\n[![Build Status](https://github.com/remarkablemark/matrix-transpose/workflows/build/badge.svg?branch=master)](https://github.com/remarkablemark/matrix-transpose/actions?query=workflow%3Abuild)\n[![Coverage Status](https://coveralls.io/repos/github/remarkablemark/matrix-transpose/badge.svg?branch=master)](https://coveralls.io/github/remarkablemark/matrix-transpose?branch=master)\n\n[Transposes](https://wikipedia.org/wiki/Transpose) a matrix by switching the row and column indices of a multidimensional array:\n\n```\ntranspose(array)\n```\n\nIn other words, it flips a matrix over its diagonal. Inspired by the [Replit](https://replit.com/@remarkablemark/Swap-array-row-and-column).\n\n#### Example\n\n```js\nconst { transpose } = require('matrix-transpose');\n\ntranspose([\n  [1, 2],\n  [3, 4],\n  [5, 6],\n]);\n```\n\nOutput:\n\n```json\n[\n  [1, 3, 5],\n  [2, 4, 6]\n]\n```\n\n[Replit](https://replit.com/@remarkablemark/matrix-transpose) | [JSFiddle](https://jsfiddle.net/remarkablemark/c5upm1bz/)\n\n## Install\n\n[NPM](https://www.npmjs.com/package/matrix-transpose):\n\n```sh\nnpm install matrix-transpose --save\n```\n\n[Yarn](https://yarnpkg.com/package/matrix-transpose):\n\n```sh\nyarn add matrix-transpose\n```\n\n[CDN](https://unpkg.com/matrix-transpose/):\n\n```html\n\u003cscript src=\"https://unpkg.com/matrix-transpose@latest/umd/matrix-transpose.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  window.MatrixTranspose.transpose(/* array */);\n\u003c/script\u003e\n```\n\n## Usage\n\nImport module:\n\n```js\n// ES Modules\nimport { transpose } from 'matrix-transpose';\n\n// CommonJS\nconst { transpose } = require('matrix-transpose');\n```\n\nTranspose matrix:\n\n```js\ntranspose([\n  [1, 2],\n  [3, 4],\n  [5, 6],\n]);\n```\n\nOutput:\n\n```json\n[\n  [1, 3, 5],\n  [2, 4, 6]\n]\n```\n\nTranspose matrix with inconsistent column lengths:\n\n```js\ntranspose([[1], [2, 3], [4, 5, 6]]);\n```\n\nOutput:\n\n```json\n[\n  [1, 2, 4],\n  [, 3, 5],\n  [, , 6]\n]\n```\n\n### Options\n\n#### excludeEmpty\n\nWhen option `excludeEmpty` is set to `true`, then empty items are excluded:\n\n```js\ntranspose([[1], [2, 3], [4, 5, 6]], { excludeEmpty: true });\n```\n\nOutput:\n\n```json\n[[1, 2, 4], [3, 5], [6]]\n```\n\n## Testing\n\nRun tests with coverage:\n\n```sh\nnpm test\n```\n\nRun tests in watch mode:\n\n```sh\nnpm run test:watch\n```\n\nLint files:\n\n```sh\nnpm run lint\n```\n\nFix lint errors:\n\n```sh\nnpm run lint:fix\n```\n\n## Release\n\nRelease and publish are automated by [Release Please](https://github.com/googleapis/release-please).\n\n## License\n\n[MIT](https://github.com/remarkablemark/matrix-transpose/blob/master/LICENSE)\n","funding_links":["https://github.com/sponsors/remarkablemark","https://patreon.com/remarkablemark","https://ko-fi.com/remarkablemark","https://liberapay.com/remarkablemark","https://b.remarkabl.org/teespring"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremarkablemark%2Fmatrix-transpose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fremarkablemark%2Fmatrix-transpose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremarkablemark%2Fmatrix-transpose/lists"}