Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gfx/array-like-partial-equal

Comparesion of Subarrays of Two Arrays
https://github.com/gfx/array-like-partial-equal

typescript-library

Last synced: 26 days ago
JSON representation

Comparesion of Subarrays of Two Arrays

Awesome Lists containing this project

README

        

## @gfx/array-like-partial-equal

This library checks equality for subarrays of two arrays, not only for `Array` but also for `ArrayLike` in TypeScript.

## Install

```
npm install @gfx/array-like-partial-equal
```

## Synopsis

```typescript
import { arrayLikePartialEqual } from "@gfx/array-like-partial-equal";

const a: ArrayLike = [99, 1, 2, 3, 98];
const b: ArrayLike = [10, 1, 2, 3, 20];

// check if a.subarray(1, 1+3) === b.subarray(1, 1+3) for each item
console.log(arrayLikePartialEqual(a, 1, b, 1, 3)); // true

// check if a.subarray(0, 0+3) === b.subarray(0, 0+3) for each item
console.log(arrayLikePartialEqual(a, 0, b, 0, 3)); // false
```

## Copyright

Copyright (c) FUJI Goro.