{"id":44863260,"url":"https://github.com/tinwatchman/2d-array-rotation","last_synced_at":"2026-02-17T10:44:36.968Z","repository":{"id":35024837,"uuid":"197877313","full_name":"tinwatchman/2d-array-rotation","owner":"tinwatchman","description":"Rotates two-dimensional arrays clockwise by 90 degrees, 180 degrees, or 270 degrees.","archived":false,"fork":false,"pushed_at":"2023-01-05T16:18:35.000Z","size":2554,"stargazers_count":7,"open_issues_count":4,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-19T02:28:47.296Z","etag":null,"topics":["2d-array","2d-arrays","array","javascript","javascript-library","nodejs","reindex","rotate","rotation"],"latest_commit_sha":null,"homepage":null,"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/tinwatchman.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":"2019-07-20T04:02:37.000Z","updated_at":"2024-06-09T14:03:54.000Z","dependencies_parsed_at":"2023-01-15T12:31:01.863Z","dependency_job_id":null,"html_url":"https://github.com/tinwatchman/2d-array-rotation","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/tinwatchman/2d-array-rotation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinwatchman%2F2d-array-rotation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinwatchman%2F2d-array-rotation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinwatchman%2F2d-array-rotation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinwatchman%2F2d-array-rotation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tinwatchman","download_url":"https://codeload.github.com/tinwatchman/2d-array-rotation/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinwatchman%2F2d-array-rotation/sbom","scorecard":{"id":887434,"data":{"date":"2025-08-11","repo":{"name":"github.com/tinwatchman/2d-array-rotation","commit":"062ce9d62938a08fe9fee5c021f1292516580b9c"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/2 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 28 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"23 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h","Warn: Project is vulnerable to: GHSA-2j2x-2gpw-g8fm","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3","Warn: Project is vulnerable to: MAL-2023-462","Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5","Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-24T10:31:36.952Z","repository_id":35024837,"created_at":"2025-08-24T10:31:36.952Z","updated_at":"2025-08-24T10:31:36.952Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29540359,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T08:11:05.436Z","status":"ssl_error","status_checked_at":"2026-02-17T08:09:38.860Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["2d-array","2d-arrays","array","javascript","javascript-library","nodejs","reindex","rotate","rotation"],"created_at":"2026-02-17T10:44:35.255Z","updated_at":"2026-02-17T10:44:36.947Z","avatar_url":"https://github.com/tinwatchman.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"2d-array-rotation\n=================\n[![Build Status](https://travis-ci.org/tinwatchman/2d-array-rotation.svg?branch=master)](https://travis-ci.org/tinwatchman/2d-array-rotation)\n[![Coverage Status](https://coveralls.io/repos/github/tinwatchman/2d-array-rotation/badge.svg?branch=master)](https://coveralls.io/github/tinwatchman/2d-array-rotation?branch=master)\n\nA collection of functions to rotate the values within a given two-dimensional array (i.e. an `Array` of `Array`s) clockwise by 90, 180 or 270 degrees. Potentially useful for -- say -- manipulating game pieces or sprites, among other possible applications. Provided as an ES6-compatible module.\n\n__Functions__\n- [rotate90](#rotate90arr)\n- [rotate180](#rotate180arr)\n- [rotate270](#rotate270arr)\n- [rotate](#rotatearr-deg)\n- [hflip](#hfliparr)\n- [vflip](#vfliparr)\n\n__Additional Notes__\n- Can handle both square (e.g. 3x3) and rectangular (e.g. 3x5, 4x8) two-dimensional arrays. Just make sure that the rows are all the same length; results may be inconsistent otherwise.\n- Source arrays are not directly modified.\n- Values within rows are re-indexed directly from the source array, not copied or cloned. Object types and references will remain consistent.\n\n## Installation\n\n```sh\nnpm install 2d-array-rotation\n```\n\n## Usage\n\n### Importing\n\n#### Via ES6-style imports\n\n```javascript\nimport {rotate, rotate90} from \"2d-array-rotation\";\n```\n\n#### Via standard node.js requires\n\n```javascript\nconst rotate = require('2d-array-rotation').rotate;\nconst rotate90 = require('2d-array-rotation').rotate90;\n// and so on\n```\n\n### Functions\n\n#### rotate90(arr)\n\nRotates the given two-dimensional array 90 degrees clockwise.\n\n```javascript\nlet i = [\n    [ 1, 2, 3 ],\n    [ 4, 5, 6 ],\n    [ 7, 8, 9 ]\n];\nlet o = rotate90(i);\n/**\n * Result: [\n * [ 7, 4, 1 ],\n * [ 8, 5, 2 ],\n * [ 9, 6, 3 ]\n * ]\n */\n```\n\n##### Parameters\n+ `arr` (`Array`): a two-dimensional array\n\n##### Returns\nA new two-dimensional `Array` that represents the rotated form of the input.\n\n#### rotate180(arr)\n\nRotates the given two-dimensional array 180 degrees clockwise.\n\n```javascript\nlet i = [\n    [1, 2, 3],\n    [4, 5, 6],\n    [7, 8, 9],\n    [10, 11, 12]\n];\nlet o = rotate180(i);\n/**\n * Result: [\n * [12, 11, 10],\n * [ 9,  8,  7],\n * [ 6,  5,  4],\n * [ 3,  2,  1]\n * ]\n */\n```\n\n##### Parameters\n+ `arr` (`Array`): a two-dimensional array\n\n##### Returns\nA new two-dimensional `Array` that represents the rotated form of the input.\n\n#### rotate270(arr)\n\nRotates the given two-dimensional array 270 degrees clockwise.\n\n```javascript\nlet i = [\n    [ 1, 2, 3 ],\n    [ 4, 5, 6 ],\n    [ 7, 8, 9 ]\n];\nlet o = rotate270(i);\n/**\n * Result: [\n * [ 3, 6, 9 ],\n * [ 2, 5, 8 ],\n * [ 1, 4, 7 ]\n * ]\n */\n```\n\n##### Parameters\n+ `arr` (`Array`): a two-dimensional array\n\n##### Returns\nA new two-dimensional `Array` that represents the rotated form of the input.\n\n#### rotate(arr, deg)\n\nRotates the given two-dimensional array by the given number of degrees clockwise. Calls `rotate90`, `rotate180`, or `rotate270`, depending on the input. \n\n```javascript\nlet i = [\n    [1, 2, 3],\n    [4, 5, 6],\n    [7, 8, 9],\n    [10, 11, 12],\n    [13, 14, 15]\n];\nlet o = rotate(i, 90);\n/**\n * Result: [\n * [13, 10, 7, 4, 1],\n * [14, 11, 8, 5, 2],\n * [15, 12, 9, 6, 3]\n * ]\n */\n// note that this function can also handle negative degree values...\nlet o2 = rotate(i, -270); // returns same as above\n// ... and degree values higher than 360\nlet o3 = rotate(i, 450); // returns same as above\n```\n\n##### Parameters\n+ `arr` (`Array`): A two-dimensional array.\n+ `deg` (`Number`): Number of degrees to rotate. Must be a multiple of 90, or an error will be thrown.\n\n##### Returns\nA new two-dimensional `Array` that represents the rotated form of the input; or, if told to rotate by 0 or 360 degrees, the original `arr` itself without any modifications.\n\n#### hflip(arr)\n\nBonus function -- flips the array horizontally.\n\n```javascript\nlet input = [\n    [1, 2, 3],\n    [4, 5, 6],\n    [7, 8, 9],\n    [10, 11, 12]\n];\nlet o = hflip(input);\n/**\n * Result: [\n * [3, 2, 1],\n * [6, 5, 4],\n * [9, 8, 7],\n * [12, 11, 10],\n * ]\n */\n```\n\n#### vflip(arr)\n\nBonus function -- flips the array vertically.\n\n```javascript\nlet input = [\n    [ 1, 2, 3 ],\n    [ 4, 5, 6 ],\n    [ 7, 8, 9 ]\n];\nlet o = vflip(input);\n/**\n * Result: [\n * [ 7, 8, 9 ],\n * [ 4, 5, 6 ],\n * [ 1, 2, 3 ]\n * ]\n */\n```\n\n## Testing\n\n```sh\nnpm test\n```\n\n## Release History\n\n* 2.1.0\n    - updated dependencies\n* 2.1.1\n    - updated dependencies\n\n## Credits and Licensing\n\nCreated by [Jon Stout](http://www.jonstout.net). Licensed under [the MIT license](http://opensource.org/licenses/MIT).\n\n## Special Thanks To\n\nu/Epyo on Reddit.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinwatchman%2F2d-array-rotation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftinwatchman%2F2d-array-rotation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinwatchman%2F2d-array-rotation/lists"}