https://github.com/tylim88/array-cross
cross join 2 arrays
https://github.com/tylim88/array-cross
npm-package typescript
Last synced: 9 months ago
JSON representation
cross join 2 arrays
- Host: GitHub
- URL: https://github.com/tylim88/array-cross
- Owner: tylim88
- License: mit
- Created: 2022-05-05T00:59:53.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-08T18:04:46.000Z (about 3 years ago)
- Last Synced: 2025-03-11T14:26:27.505Z (10 months ago)
- Topics: npm-package, typescript
- Language: TypeScript
- Homepage:
- Size: 313 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# array-cross
## Installation
```bash
npm i array-cross
```
## Usage
return a deeply cloned array
```ts
import { cross } from 'array-cross'
const arr1 = [1, 3, 5, 7]
const arr2 = [2, 4, 6, 8]
const arr3 = [1, 3, 5, 7, 9]
const arr4 = [2, 4, 6, 8, 0]
cross(arr1, arr2) // [1, 2, 3, 4, 5, 6, 7, 8]
cross(arr3, arr2) // [1, 2, 3, 4, 5, 6, 7, 8, 9]
cross(arr1, arr4) // [1, 2, 3, 4, 5, 6, 7, 8, 0]
cross(arr3, arr2, { makeSameLength: true }) // [1, 2, 3, 4, 5, 6, 7, 8]
cross(arr1, arr4, { makeSameLength: true }) // [1, 2, 3, 4, 5, 6, 7, 8]
```
must be same length
```ts
import { cross } from 'array-cross'
const arr2 = [2, 4, 6, 8]
const arr3 = [1, 3, 5, 7, 9]
cross(arr3, arr2, { mustBeSameLength: true }) // throw not same length
```