{"id":15821503,"url":"https://github.com/danakt/multi-array-view","last_synced_at":"2025-10-08T23:07:00.007Z","repository":{"id":32966062,"uuid":"148033103","full_name":"danakt/multi-array-view","owner":"danakt","description":"A small JavaScript library for efficient work with multidimensional arrays","archived":false,"fork":false,"pushed_at":"2023-03-04T04:14:22.000Z","size":174,"stargazers_count":5,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-08T23:06:57.902Z","etag":null,"topics":["array-dimensions","arrays","dimensions","javascript-library","matrix","multidimensional","multidimensional-arrays","nested-arrays","strided-arrays"],"latest_commit_sha":null,"homepage":"","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/danakt.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-09T14:24:46.000Z","updated_at":"2023-10-30T15:07:30.000Z","dependencies_parsed_at":"2024-10-26T12:48:04.680Z","dependency_job_id":"f53ff20e-6c1f-42b7-b235-a901edc40a01","html_url":"https://github.com/danakt/multi-array-view","commit_stats":{"total_commits":34,"total_committers":3,"mean_commits":"11.333333333333334","dds":0.4411764705882353,"last_synced_commit":"2222762e472ec0a0c0dc5af0265e2045186d783e"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/danakt/multi-array-view","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danakt%2Fmulti-array-view","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danakt%2Fmulti-array-view/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danakt%2Fmulti-array-view/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danakt%2Fmulti-array-view/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danakt","download_url":"https://codeload.github.com/danakt/multi-array-view/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danakt%2Fmulti-array-view/sbom","scorecard":{"id":318411,"data":{"date":"2025-08-11","repo":{"name":"github.com/danakt/multi-array-view","commit":"2222762e472ec0a0c0dc5af0265e2045186d783e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"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":"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":"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":"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":"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":"Code-Review","score":0,"reason":"Found 0/19 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":"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":"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":"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":"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":"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":"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 12 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":"14 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-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-fjxv-7rqg-78g4","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-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q"],"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-18T00:49:11.678Z","repository_id":32966062,"created_at":"2025-08-18T00:49:11.678Z","updated_at":"2025-08-18T00:49:11.678Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000730,"owners_count":26082862,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["array-dimensions","arrays","dimensions","javascript-library","matrix","multidimensional","multidimensional-arrays","nested-arrays","strided-arrays"],"created_at":"2024-10-05T07:22:45.584Z","updated_at":"2025-10-08T23:06:59.991Z","avatar_url":"https://github.com/danakt.png","language":"TypeScript","readme":"# MultiArrayView [![NPM](https://img.shields.io/npm/v/multi-array-view.svg?style=flat-square\u0026maxAge=3600)](https://www.npmjs.com/package/multi-array-view) [![Build Status](https://img.shields.io/travis/danakt/multi-array-view.svg?style=flat-square\u0026maxAge=3600)](https://travis-ci.org/danakt/multi-array-view)\n\n\u003cimg align=\"right\" width=\"150\" src=\"https://cdn.rawgit.com/danakt/multi-array-view/74507769/octaplex.svg\" title=\"Octaplex\"\u003e\n\nA small JavaScript library for efficient work with multidimensional arrays.\n\nWhen working with a large data, (for example, in 3d-graphics), working with nested arrays in JavaScript can affect the performance of the code. The more productive analogy of nested arrays is strided arrays—multidimensional data placed in the plane of a one-dimensional array. Unfortunately, working with strided arrays can lead to code repetition, complex operations, and syntactic noise in the code. The MultiArrayView library serves to simplify the work with strided arrays as if it were an ordinary multidimensional array.\n\nA simple 3x3 matrix:\n\n```js\nconst array = [\n  [0, 0, 0],\n  [0, 0, 0],\n  [0, 0, 1]\n]\n\nconst item = arr[2][2] // 1\n```\n\nAnd a similar 3x3 matrix in the form of a one-dimensional strided array wrapped in MultiArrayView:\n\n```js\nconst array = [\n  0, 0, 0,\n  0, 0, 0,\n  0, 0, 1\n]\n\n// Wrapping the strided array\nconst multiArray = MultiArrayView.wrap(arr, [3, 3])\n\nconst unit = multiArray.get(2, 2) // 1\n```\n\n## Getting Started\n\nInstallation using npm:\n\n```\n$ npm install multi-array-view\n```\n\nOr using yarn:\n\n```\n$ yarn add multi-array-view\n```\n\n### Usage\n\nYou can import the package in your node.js-project the following way:\n\n```js\nconst MultiArrayView = require('multi-array-view')\n```\n\nIf your project has ES6 or TypeScript support, use the following import method. The MultiArrayView has full typing support.\n\n```js\nimport MultiArrayView from 'multi-array-view'\n```\n\n## API reference\n\n### Static methods\n\n#### `MultiArrayView.create(shape[, constructor, offset, order])`\nCreates a new array using the specified constructor. If the constructor is not specified, the `Array` is used as the constructor. Returns instance of MultiArrayView class.\n\n- `shape`  \nList of array dimensions.\n  \n- `constructor` _Optional_  \nConstructor for creating the source one-dimensional array.  \nDefaults to `Array`.\n\n- `offset` _Optional_   \nThe starting offset of the array view.  \nDefaults to 0.\n\n- `order` _Optional_  \nOrdering method for storing data. See [ordering methods](#ordering-methods) section for more information.  \nAvailable values:\n  * `MultiArray.C_ORDER` — Row-major order (C-style)  \n  * `MultiArray.F_ORDER` — Column-major (Fortran-style)  \n\nA minimal example\n```js\n// Creates empty 4x4 matrix\nconst multiArray = MultiArrayView.create([4, 4])\n\nconsole.log(multiArray.array) // (16) [empty × 16] \n\n```\n\nWith specified `constructor` and `offset`\n```js\nconst multiArray = MultiArrayView.create([4, 4], Uint8Array, 2)\n\nconsole.log(multiArray.array)\n// Uint8Array(18) [\n//   0, 0,          \u003c— 2 offsetted items\n//   0, 0, 0, 0,    \u003c— matrix start\n//   0, 0, 0, 0,\n//   0, 0, 0, 0,\n//   0, 0, 0, 0\n// ]\n```\n\n#### `MultiArrayView.wrap(array, shape[, offset, order])`\nWraps the readymade strided array in the MultiArrayView class for multi-dimensional viewing. Returns instance of MultiArrayView class.\n\n- `array`  \nThe 1d array to wrap.\n\n- `shape`  \nList of array dimensions.\n\n- `offset` _Optional_   \nThe starting offset of the array view.  \nDefaults to 0.\n\n- `order` _Optional_  \nOrdering method for storing data. See [ordering methods](#ordering-methods) section for more information.  \nAvailable values:\n  * `MultiArray.C_ORDER` — Row-major order (C-style)  \n  * `MultiArray.F_ORDER` — Column-major (Fortran-style)  \n\nSimple example\n```js\nconst shape = [128, 256, 512]\nconst length = shape.reduce((a, b) =\u003e a * b) // Calculation the length of the array\nconst typedArray = new Int32Array(length) \n\n// Wrapping the array\nconst multiArray = MultiArrayView.wrap(typedArray, shape) \n\nconsole.log(multiArray.array) // Int32Array(16777216) [0, 0, 0, 0, 0, ...\n```\n\n### Instance methods\n\n#### `.get(x1 [, x2, ..., xN])`\nReturns the value of the item by the specified path.\n\n- `x1` ... `xN`  \n List of indices for each dimension to obtain an item. The same as indices in a simple multidimensional array.\n\n\n#### `.set(value, x1 [, x2, ..., xN])`\nSets the item value by the specified path.\n\n- `value`  \nThe value to set\n\n- `x1` ... `xN`  \nList of indices for each dimension to set a value to the item. The same as indices in a simple multidimensional array.\n\nExample\n```js\nconst multiArray = MultiArrayView.create([100, 100])\n\nconst value = 1337\nmultiArray.set(value, 90, 10)\n\nconsole.log(multiArray.get(90, 10)) // 1337\n```\n\n#### `.getIndex(x1 [, x2, ..., xN])`\nReturns the real index of source array by the specified path.\n\n- `x1` ... `xN`  \nList of indices for each dimension to get the real index. The same as indices in a simple multidimensional array.\n\n#### `.array`\nThe source array.\n\n#### `.shape`\nShape of the array that was putted when the MultiArrayView instance was created.\n\n#### `.length`\nLength of the source array computed by the shape.\n\n## Ordering methods\n[\u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/4/4d/Row_and_column_major_order.svg/512px-Row_and_column_major_order.svg.png\" width=\"200\" align=\"right\" alt=\"Image from wikipedia\"\u003e](https://en.wikipedia.org/wiki/Row-_and_column-major_order)\n\nThere are two values for the sorting method:\n  * `MultiArray.C_ORDER` — Row-major order (C-style)  \n  * `MultiArray.F_ORDER` — Column-major (Fortran-style)  \n  \nThey differ in the way of storing data in the source array.\n\n\nSimple 3x3 matrix:  \n```js\nconst matrix3x3 = [\n  [1, 2, 3],\n  [4, 5, 6],\n  [7, 8, 9],\n]\n```\n\nAnd flat representation of the matrix above after applying different-ordered arrays:\n```js\n// Default row-major ordered array\nconst cOrdered = MultiArrayView.create([3, 3], Uint8Array, 0, MultiArrayView.C_ORDER)\n\n// Column-major ordered array\nconst fOrdered = MultiArrayView.create([3, 3], Uint8Array, 0, MultiArrayView.F_ORDER)\n\n// Applying matrix to arrays\nfor (let x = 0; x \u003c matrix3x3.length; x++) {\n  for (let y = 0; y \u003c matrix3x3[x].length; y++) {\n    const value = matrix3x3[x][y]\n    \n    cOrdered.set(value, x, y)\n    fOrdered.set(value, x, y)\n  }\n}\n\n// Row-major source array representation\nconsole.log(cOrdered.array)\n// [1, 2, 3, 4, 5, 6, 7, 8, 9]\n\n\n// Column-major source array representation\nconsole.log(fOrdered.array)\n// [1, 4, 7, 2, 5, 8, 3, 6, 9]\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanakt%2Fmulti-array-view","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanakt%2Fmulti-array-view","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanakt%2Fmulti-array-view/lists"}