{"id":21874557,"url":"https://github.com/smoren/array-view-ts","last_synced_at":"2025-04-15T01:24:14.966Z","repository":{"id":226174806,"uuid":"767961161","full_name":"Smoren/array-view-ts","owner":"Smoren","description":"Create array views for easy data manipulation, select elements using Python-like slice notation, enable efficient selection of elements using index lists and boolean masks.","archived":false,"fork":false,"pushed_at":"2024-03-24T16:21:56.000Z","size":547,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T14:40:23.636Z","etag":null,"topics":["array","array-view","array-viewer","collection","mask","python-like","selector","slice","typescript","view"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/array-view","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/Smoren.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2024-03-06T08:07:28.000Z","updated_at":"2025-03-30T23:44:46.000Z","dependencies_parsed_at":"2024-03-24T17:31:02.827Z","dependency_job_id":null,"html_url":"https://github.com/Smoren/array-view-ts","commit_stats":null,"previous_names":["smoren/collections-view-ts","smoren/array-view-ts"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smoren%2Farray-view-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smoren%2Farray-view-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smoren%2Farray-view-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smoren%2Farray-view-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Smoren","download_url":"https://codeload.github.com/Smoren/array-view-ts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248986858,"owners_count":21194134,"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":["array","array-view","array-viewer","collection","mask","python-like","selector","slice","typescript","view"],"created_at":"2024-11-28T07:12:41.989Z","updated_at":"2025-04-15T01:24:14.922Z","avatar_url":"https://github.com/Smoren.png","language":"TypeScript","readme":"# Array View for TypeScript and JavaScript\n\n[![npm](https://img.shields.io/npm/v/array-view.svg)](https://www.npmjs.com/package/array-view)\n[![npm](https://img.shields.io/npm/dm/array-view.svg?style=flat)](https://www.npmjs.com/package/array-view)\n[![Coverage Status](https://coveralls.io/repos/github/Smoren/array-view-ts/badge.svg?branch=master\u0026rand=123)](https://coveralls.io/github/Smoren/array-view-ts?branch=master)\n![Build and test](https://github.com/Smoren/array-view-ts/actions/workflows/test.yml/badge.svg)\n[![Minified Size](https://badgen.net/bundlephobia/minzip/array-view)](https://bundlephobia.com/result?p=array-view)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n![Array View Logo](docs/images/logo.png)\n\n**Array View** is a TypeScript library that provides a powerful set of utilities for working with arrays in\na versatile and efficient manner. These classes enable developers to create views of arrays, manipulate data with ease,\nand select specific elements using index lists, masks, and slice parameters.\n\nArray View offers a Python-like slicing experience for efficient data manipulation and selection of array elements.\n\n## Features\n- Create array views for easy data manipulation.\n- Select elements using [Python-like slice notation](https://www.geeksforgeeks.org/python-list-slicing/).\n- Handle array slicing operations with ease.\n- Enable efficient selection of elements using index lists and boolean masks.\n\n## Installation\n```bash\nnpm install array-view\n```\n\n## Quick examples\n### Slicing\n```typescript\nimport { view } from \"array-view\";\n\nconst originalArray = [1, 2, 3, 4, 5, 6, 7, 8, 9];\nconst originalView = view(originalArray);\n\noriginalView.loc['1:7:2']; // [2, 4, 6]\noriginalView.loc[':3']; // [1, 2, 3]\noriginalView.loc['::-1']; // [9, 8, 7, 6, 5, 4, 3, 2, 1]\n\noriginalView.loc[2]; // 3\noriginalView.loc[4]; // 5\noriginalView.loc[-1]; // 9\noriginalView.loc[-2]; // 8\n\noriginalView.loc['1:7:2'] = [22, 44, 66];\noriginalArray; // [1, 22, 3, 44, 5, 66, 7, 8, 9]\n```\n\n### Subviews\n```typescript\nimport { view, mask, select, slice } from \"array-view\";\n\nconst originalArray = [1, 2, 3, 4, 5];\nconst originalView = view(originalArray);\n\noriginalView.subview(mask([true, false, true, false, true])).toArray(); // [1, 3, 5]\noriginalView.subview(select([1, 2, 4])).toArray(); // [2, 3, 5]\noriginalView.subview(slice('::-1')).toArray(); // [5, 4, 3, 2, 1]\noriginalView.subview(slice([,,-1])).toArray(); // [5, 4, 3, 2, 1]\n\noriginalView.subview(mask([true, false, true, false, true])).apply((x: number) =\u003e x * 10);\noriginalArray; // [10, 2, 30, 4, 50]\n```\n\n### Combining subviews\n```typescript\nimport { view, mask, select, slice } from \"array-view\";\n\nconst originalArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n\nconst subview = view(originalArray)\n  .subview('::2')                                 // [1, 3, 5, 7, 9]\n  .subview(mask([true, false, true, true, true])) // [1, 5, 7, 9]\n  .subview(select([0, 1, 2]))                     // [1, 5, 7]\n  .subview('1:')                                  // [5, 7]\n\nsubview.loc[':'] = [55, 77];\noriginalArray; // [1, 2, 3, 4, 55, 6, 77, 8, 9, 10]\n```\n\n### Mask example\n```typescript\nimport { view, mask } from \"array-view\";\n\nconst array1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\nconst array2 = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10];\n\nconst mask = view(array1).is((x: number) =\u003e x % 3 === 0);\n// MaskSelector([false, false, true, false, false, true, false, false, true, false])\n\nview(array2)\n  .subview(mask)\n  .applyWith(\n    view(array1).subview(mask),\n    (lhs: number, rhs: number) =\u003e lhs + rhs,\n  )\n  .toArray();\n// [-1, -2, 0, -4, -5, 0, -7, -8, 0, -10]);\n```\n\n## Contributing\nContributions are welcome! Feel free to open an issue or submit a pull request on the [GitHub repository](https://github.com/Smoren/array-view-ts).\n\n## License\nArray View TS is released under the MIT License.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmoren%2Farray-view-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmoren%2Farray-view-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmoren%2Farray-view-ts/lists"}