# stringmap

> fast and robust stringmap

Latest version **0.2.2** (published 2013-09-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install stringmap
pnpm add stringmap
yarn add stringmap
bun add stringmap
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2013-09-26 |
| First published | 2013-04-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 35 |
| Author | Olov Lassus |
| Maintainers | olov |
| Keywords | stringmap, hashmap, hash, dict, dictionary, __proto__ |

## Links

- npm: https://www.npmjs.com/package/stringmap
- Repository: https://github.com/olov/stringmap
- npm.io page: https://npm.io/package/stringmap

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 0.2.2 (latest) — 2013-09-26
- 0.2.1 — 2013-04-14
- 0.2.0 — 2013-04-14
- 0.1.1 — 2013-04-14
- 0.1.0 — 2013-04-13

## README

# stringmap.js
A fast and robust stringmap implementation that can hold any string keys,
including `__proto__`, with minimal overhead compared to a plain object.
Works in node and browsers.

The API is created to be as close to the ES6 Map API as possible. Prefer
`sm.remove("key")` for deleting a key. ES6 Map uses `map.delete("key")`
instead and for that reason `sm['delete']("key")` is available as a
stringmap alias as well. Never do `sm.delete("key")` unless you're
certain to be in the land of ES5 or later.



## Examples
Available in `examples.js`

```javascript
var StringMap = require("stringmap");

var sm1 = new StringMap();
sm1.set("greeting", "yoyoma");
sm1.set("check", true);
sm1.set("__proto__", -1);
console.log(sm1.has("greeting")); // true
console.log(sm1.get("__proto__")); // -1
sm1.remove("greeting");
console.log(sm1.keys()); // [ 'check', '__proto__' ]
console.log(sm1.values()); // [ true, -1 ]
console.log(sm1.items()); // [ [ 'check', true ], [ '__proto__', -1 ] ]
console.log(sm1.toString()); // {"check":true,"__proto__":-1}

var sm2 = new StringMap({
    one: 1,
    two: 2,
});
console.log(sm2.map(function(value, key) {
    return value * value;
})); // [ 1, 4 ]
sm2.forEach(function(value, key) {
    // ...
});
console.log(sm2.isEmpty()); // false
console.log(sm2.size()); // 2

var sm3 = sm1.clone();
sm3.merge(sm2);
sm3.setMany({
    a: {},
    b: [],
});
console.log(sm3.toString()); // {"check":true,"one":1,"two":2,"a":{},"b":[],"__proto__":-1}
```



## Installation

### Node
Install using npm

    npm install stringmap

```javascript
var StringMap = require("stringmap");
```

### Browser
Clone the repo and include it in a script tag

    git clone https://github.com/olov/stringmap.git

```html
<script src="stringmap/stringmap.js"></script>
```

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