# @fightingdreamer/set-intersection

> Missing intersection operation over Set.

Latest version **0.1.1** (published 2023-12-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install @fightingdreamer/set-intersection
pnpm add @fightingdreamer/set-intersection
yarn add @fightingdreamer/set-intersection
bun add @fightingdreamer/set-intersection
```

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2023-12-12 |
| First published | 2023-12-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Patryk Stępień |
| Maintainers | fightingdreamer |
| Keywords | iter, Set |

## Links

- npm: https://www.npmjs.com/package/@fightingdreamer/set-intersection
- Homepage: https://github.com/fightingdreamer/npm-set-intersection
- npm.io page: https://npm.io/package/@fightingdreamer/set-intersection

## Dependencies (3)

- [@fightingdreamer/iter-count](https://npm.io/package/@fightingdreamer/iter-count.md) ^0.1.0
- [@fightingdreamer/iter-reduce](https://npm.io/package/@fightingdreamer/iter-reduce.md) ^0.1.1
- [@fightingdreamer/iter-flatten](https://npm.io/package/@fightingdreamer/iter-flatten.md) ^0.1.0

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2023-12-12
- 0.1.0 — 2023-12-06

## README

# set-intersection

## Description

Missing itersection operation for Set.

Second implementation can do intersection operation between any number of sets.

Third implementation can do intersection operation between any combination of sets.

## Install

```bash
bun add @fightingdreamer/set-intersection
```

## Usage

```js
import {intersection} from '@fightingdreamer/set-intersection'

const a = new Set([1,2,3])
const b = new Set([3,4,5])
const result = intersection(a, b)
const expect = [3]
for (const value of expect) {
  console.assert(result.has(value))
}
```

```js
import {intersectionMany} from '@fightingdreamer/set-intersection'

const sets = [
  new Set([1,2,3]),
  new Set([2,3,4]),
  new Set([3,4,5])
][Symbol.iterator]()
const result = intersectionMany(sets)
const expect = [3]
for (const value of expect) {
  console.assert(result.has(value))
}
```

```js
import {intersectionPartial} from '@fightingdreamer/set-intersection'

const sets = [
  new Set([1,2,3]),
  new Set([2,3,4]),
  new Set([3,4,5])
][Symbol.iterator]()
const result = intersectionPartial(sets, 2)
const expect = [2,3,4]
for (const value of expect) {
  console.assert(result.has(value))
}
```

## Usage (node / commonjs)

```js
const {intersection} = require('@fightingdreamer/set-intersection')

const a = new Set([1,2,3])
const b = new Set([3,4,5])
const result = intersection(a, b)
const expect = [3]
for (const value of expect) {
  assert(result.has(value))
}
```

```js
const {intersectionMany} = require('@fightingdreamer/set-intersection')

const sets = [
  new Set([1,2,3]),
  new Set([2,3,4]),
  new Set([3,4,5])
][Symbol.iterator]()
const result = intersectionMany(sets)
const expect = [3]
for (const value of expect) {
  assert(result.has(value))
}
```


```js
const {intersectionPartial} = require('@fightingdreamer/set-intersection')

const sets = [
  new Set([1,2,3]),
  new Set([2,3,4]),
  new Set([3,4,5])
][Symbol.iterator]()
const result = intersectionPartial(sets, 2)
const expect = [2,3,4]
for (const value of expect) {
  assert(result.has(value))
}
```

## Functions

```js
function intersection<T>(a: Set<T>, b: Set<T>): Set<T>
```

Will return overlapping items from `a` and `b`.

```js
function intersectionMany<T>(sets: Iterable<Set<T>>): Set<T>
```

Will return overlapping items when item exist in every Set.

```js
function intersectionPartial<T>(
  sets: Iterable<Set<T>>,
  minCount: number,
): Set<T>
```

Will return overlapping items when item exist in at least `minCount` number of `sets`.

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