# javasetmap.ts

> Java-style Set and Map collections (on `{ hashCode(): int, equals(x: any): boolean}` objects) written in TypeScript.

Latest version **1.1.3** (published 2020-12-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install javasetmap.ts
pnpm add javasetmap.ts
yarn add javasetmap.ts
bun add javasetmap.ts
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2020-12-19 |
| First published | 2017-10-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 56.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Adrian Leonhard |
| Maintainers | narida |
| Keywords | typescript, set, map |

## Links

- npm: https://www.npmjs.com/package/javasetmap.ts
- Repository: https://github.com/NaridaL/javasetmap.ts
- Homepage: https://github.com/NaridaL/javasetmap.ts#readme
- Issues: https://github.com/NaridaL/javasetmap.ts/issues
- npm.io page: https://npm.io/package/javasetmap.ts

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.0.3

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.1.3 (latest) — 2020-12-19
- 1.1.2 — 2020-12-19
- 1.1.1 — 2020-05-30
- 1.1.0 — 2017-10-22
- 1.0.0 — 2017-10-22

## README

<!--- header generated automatically, don't edit --->
[![Travis](https://img.shields.io/travis/NaridaL/javasetmap.ts.svg?style=flat-square)](https://travis-ci.org/NaridaL/javasetmap.ts)
[![npm](https://img.shields.io/npm/v/javasetmap.ts.svg?style=flat-square)](https://www.npmjs.com/package/javasetmap.ts)
[![David](https://img.shields.io/david/expressjs/express.svg?style=flat-square)](https://david-dm.org/NaridaL/javasetmap.ts)

# javasetmap.ts
Java-style Set and Map collections (on `{ hashCode(): int, equals(x: any): boolean}` objects) written in TypeScript.

## Installation
NPM:  `npm install javasetmap.ts --save`
    
In the browser, you can include the [UMD bundle](./dist/bundle.js) in a script tag, and the module will be available under the global `javasetmap_ts` 
    
<!--- CONTENT-START --->
## Usage
```ts
import {JavaMap} from 'javasetmap.ts'
// node: const {JavaMap} = require('javasetmap.ts')
// browser: const {JavaMap} = nla

declare global { // remove this block if not using TypeScript
    interface Array<T> extends Equalable {}
    interface Number extends Equalable {}
}
Array.prototype.equals = function (o) { 
    return this == o || this.length == o.length && this.every((el, i) => el.equals(o[i])) 
}
Array.prototype.hashCode = function () { 
    return this.reduce((acc, current) => acc * 31 + current.hashCode(), 0) 
}
Number.prototype.equals = function (o) { return this == o }
Number.prototype.hashCode = function () { return this | 0 }

const myMap = new JavaMap<[number, number], string>() // new JavaMap() if not using TypeScript

myMap.set([1, 2], "foo")
myMap.has([1, 2]) // === true
myMap.get([1, 2]) // === "foo"
myMap.has([1, 3]) // === false
myMap.get([2, 1]) // === undefined
```



<!--- CONTENT-END --->
<!--- footer generated automatically, don't edit --->
LICENSE
MIT

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