# dynamic-array

> True dynamic array implementation for Node.js providing asymptotically optimal stacks and queues

Latest version **1.0.35** (published 2016-11-28) · 0 weekly downloads

## Install

```sh
npm install dynamic-array
pnpm add dynamic-array
yarn add dynamic-array
bun add dynamic-array
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.35 |
| Published | 2016-11-28 |
| First published | 2014-06-24 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| Maintainers | davidc538 |

## Links

- npm: https://www.npmjs.com/package/dynamic-array
- npm.io page: https://npm.io/package/dynamic-array

## Recent versions

- 1.0.35 (latest) — 2016-11-28
- 1.0.34 — 2016-11-28
- 1.0.33 — 2016-11-02
- 1.0.32 — 2016-09-12
- 1.0.31 — 2016-09-12
- 1.0.30 — 2016-09-12
- 1.0.28 — 2016-09-12
- 1.0.27 — 2016-09-12
- 1.0.26 — 2014-07-13
- 1.0.25 — 2014-06-27
- 1.0.24 — 2014-06-27
- 1.0.23 — 2014-06-27
- 1.0.22 — 2014-06-27
- 1.0.21 — 2014-06-26
- 1.0.20 — 2014-06-26
- … 20 more at https://npm.io/package/dynamic-array/versions

## README

dynamic-array
==================

<a href="https://github.com/davidc538/node_dynamic_array">View on GitHub</a><br>
<a href="https://www.npmjs.org/package/dynamic-array">View on npmjs.org</a><br>
<a href="https://tonicdev.com/davidc538/dynamic-array">View on Tonic</a>

Dynamic array extension for Node.js offering better performance for use as a stack or queue

Purpose:
  This extension wraps a C++ std::deque giving Node.js developers asymptotically optimal queues and stacks.

Requirements:
  Node.js,
  node-gyp,
  gcc and g++
  
Build instructions:
  cd to download directory,
  node-gyp configure,
  node-gyp build

NPM:
  Can be installed from NPM via:
  npm install dynamic-array

Usage:

```
var arr = require('dynamic-array').DynamicArray();

// use as a queue

console.log("Use as a queue");
console.log("Should list 0 - 9");

for (var i = 0; i < 10; i++)
  arr.enqueue(i);

while(arr.size() > 0)
  console.log(arr.dequeue());

// use as a stack

console.log("Use as a stack");
console.log("Should list 9 - 0");

for (var i = 0; i < 10; i++)
  arr.push(i);

while(arr.size() > 0)
  console.log(arr.pop());

// iteration

console.log("Iteration");
console.log("Should list 0 - 9");

for (var i = 0; i < 10; i++)
  arr.push_back(i);

arr.each(function(item) {
  console.log(item);
});

arr.clear();

// sorting

console.log("Sorting");
console.log("Should list 0 - 9");

for (var i = 0; i < 10; i++)
  arr.push_back(i);

arr.each(function(item) {
  console.log(item);
});

console.log("Should now be reversed")

arr.sort(function(a, b) {
  return (a > b);
});

arr.each(function(item) {
  console.log(item);
});

arr.clear();

// assignment

console.log("Assignment");
console.log("Should list 0 - 8, 8");

for(var i = 0; i < 10; i++)
  arr.push_back(i);

arr.assign(9, 8);

arr.each(function(item) {
  console.log(item);
});

// retrieval

console.log("Retrieval");
console.log("Should list 7, 8");

console.log(arr.at(7));
console.log(arr.at(8));

arr.clear();

// bounds checking

console.log("Should throw exceptions for being out of bounds");
console.log("This bounds checking is to prevent memory leaks and other programming errors");

try {
  arr.at(1);
} catch (e) {
  console.log(e);
}

try {
  arr.assign(1, 0);
} catch (e) {
  console.log(e);
}


```


<a href="http://davidcarpenter.herokuapp.com/projects/5/node_dynamic_array">Node dynamic array</a>

---
_Source: https://npm.io/package/dynamic-array · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
