# @donnerluetjen/datawell

> Creates and maintains a stack of data to refer to.

Latest version **1.0.5** (published 2023-02-03) · ISC license · 0 weekly downloads

## Install

```sh
npm install @donnerluetjen/datawell
pnpm add @donnerluetjen/datawell
yarn add @donnerluetjen/datawell
bun add @donnerluetjen/datawell
```

## 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.5 |
| Published | 2023-02-03 |
| First published | 2023-01-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 176.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | donnerluetjen |
| Maintainers | donnerluetjen |
| Keywords | datawell, datastore, javascript, stack |

## Links

- npm: https://www.npmjs.com/package/@donnerluetjen/datawell
- Repository: https://github.com/donnerluetjen/datawell
- Homepage: https://github.com/donnerluetjen/datawell#readme
- Issues: https://github.com/donnerluetjen/datawell/issues
- npm.io page: https://npm.io/package/@donnerluetjen/datawell

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 1.0.5 (latest) — 2023-02-03
- 1.0.4 — 2023-02-03
- 1.0.3 — 2023-02-03
- 1.0.2 — 2023-01-27
- 1.0.0 — 2023-01-26

## README

# DataWell

Creates and maintains a stack of data to refer to.

## Requirements and Feature

### Sorted DataWell

- A sorted DataWell will always be sorted ascending and has the following requirements and features:

  - The property to sort on must be of type number.
  - The property to sort on must be present.
  - The property to sort on can be specified, the default is "id".
  - Exisitng data with the same property to sort on will be updated, same properties will be overriden, different properties will be merged.

### Unsorted DataWell

- An unsorted DataWell will never be sorted. It will always push added data to the top of the DataWell.

### Common Features

- The DataWell has a maximum capacity that has to be set during initialization.
- When the DataWell is about to exceed its capacity, data from the bottom will silently be removed.
- Data cannot be deleted manually.
- Data can be pushed to the DataWell as a list or as a single object.

## Examples

### Unsorted DataWell

```javascript
const dataWell = new DataWell(4);

for (let i=0; i < 4; i++) {
  dataWell.push({sample: i});
}
  
dataWell.push([{sample: -4}]);
console.log(dataWell.content();

/*
produces:
[
{ sample: 1 },
{ sample: 2 },
{ sample: 3 },
{ sample: -4}
]
*/
```

### Sorted DataWell

```javascript
const dataWell = new DataWell(4, true);

for (let i=0; i < 4; i++) {
  dataWell.push({sample: i, id: i};
}
  
dataWell.push([{sample: -4, id: 1}]);
console.log(dataWell.content();

/*
produces:
[
{ sample: 0, id: 0 },
{ sample: -4, id: 1 },
{ sample: 2, id: 2 },
{ sample: 3, id: 3 }
]
*/
```

or, with your own property to sort on:

```javascript
const dataWell = new DataWell(4, true, "sortOn");

for (let i=0; i < 4; i++) {
  dataWell.push({sample: i, sortOn: i};
}
  
dataWell.push([{sample: -4, otherData: 42, sortOn: 1}]);
console.log(dataWell.content();

/*
produces:
[
{ sample: 0, sortOn: 0 },
{ sample: -4, otherData: 42, sortOn: 1 },
{ sample: 2, sortOn: 2 },
{ sample: 3, sortOn: 3 }
]
*/
```

## Bugs and Feature Requests

Please open an issue here: https://github.com/donnerluetjen/datawell/issues

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