https://github.com/nodef/extra-array-view
An array view is a proxy to an underlying array.
https://github.com/nodef/extra-array-view
array extra from-array view
Last synced: 7 months ago
JSON representation
An array view is a proxy to an underlying array.
- Host: GitHub
- URL: https://github.com/nodef/extra-array-view
- Owner: nodef
- License: mit
- Created: 2020-05-15T08:33:01.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2025-04-08T17:17:02.000Z (over 1 year ago)
- Last Synced: 2025-09-05T00:19:11.262Z (11 months ago)
- Topics: array, extra, from-array, view
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/extra-array-view
- Size: 270 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Citation: CITATION.cff
Awesome Lists containing this project
README
An [array view] is a proxy to an underlying array.
📦 [Node.js](https://www.npmjs.com/package/extra-array-view),
🌐 [Web](https://www.npmjs.com/package/extra-array-view.web),
📜 [Files](https://unpkg.com/extra-array-view/),
📰 [Docs](https://nodef.github.io/extra-array-view/),
📘 [Wiki](https://github.com/nodef/extra-array-view/wiki/).
This package provides a **view** to an underlying array. It is a proxy of the
array, and any changes made to it are reflected in the underlying array. It is
similar to a *slice* of an array, but it does not copy the array. To obtain a
view, use the `fromArray()` function.
With this package, you can simplify the implementation of complex algorithms.
Try it out today! This package is available in *Node.js* and *Web* formats. To
use it on the web, simply use the `extra_array_view` global variable after
loading with a `` tag from the [jsDelivr CDN].
> Stability: [Experimental](https://www.youtube.com/watch?v=L1j93RnIxEo).
[array view]: https://stackoverflow.com/questions/16990064/are-array-views-possible
[jsDelivr CDN]: https://cdn.jsdelivr.net/npm/extra-array-view.web/index.js
<br>
```javascript
const xarrayView = require('extra-array-view');
// import * as xarrayView from "extra-array-view";
// import * as xarrayView from "https://unpkg.com/extra-array-view/index.mjs"; (deno)
var x = [10, 40, 30, 20, 50];
var y = xarrayView.fromArray(x, 1, 4);
y[0];
// → 40
y[1];
// → 30
y.at(-1);
// → 20
y.sort();
x;
// → [ 10, 20, 30, 40, 50 ]
y.reverse();
x;
// → [ 10, 40, 30, 20, 50 ]
y.fill(0);
x;
// → [ 10, 0, 0, 0, 50 ]
```
<br>
<br>
## Index
| Property | Description |
| ---- | ---- |
| [fromArray] | Convert array range to array view. |
<br>
<br>
## References
- [negative-array - npm : Sindre Sorhus](https://www.npmjs.com/package/negative-array)
- [TypedArray : MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)
- [Array : MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
- [Proxy : MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
- [Operator overloading in JavaScript : Saad Quadri](https://www.proposals.es/proposals/Operator%20overloading)
- [How would you overload the [] operator in javascript](https://stackoverflow.com/a/25658975/1413259)
- [Check if value is a Symbol in JavaScript](https://stackoverflow.com/a/46479190/1413259)
- [how to get an array out of a javascript proxy](https://stackoverflow.com/a/71645169/1413259)
<br>
<br>
[](https://www.youtube.com/watch?v=z0ttvjJvh2s)<br>
[](https://nodef.github.io)
[](https://coveralls.io/github/nodef/extra-array-view?branch=master)
[](https://codeclimate.com/github/nodef/extra-array-view/test_coverage)
<!-- [](https://zenodo.org/badge/latestdoi/133759104) -->

[fromArray]: https://github.com/nodef/extra-array-view/wiki/fromArray