open-index/open-npm huggingface dataset:
npm package: @helcor/merge-collections
Description: Merge two arrays of objects by identifier
Latest version: 1.0.0-beta.9

![helcor](https://github.com/romelperez/helcor/raw/main/helcor.jpg)

# `@helcor/merge-collections`

<a href="https://npmjs.org/package/@helcor/merge-collections">
  <img src="https://img.shields.io/npm/v/@helcor/merge-collections.svg" alt="version" />
</a>
<a href="https://npmjs.org/package/@helcor/merge-collections">
  <img src="https://img.shields.io/npm/dm/@helcor/merge-collections.svg" alt="downloads" />
</a>

Merge two arrays of objects by identifier.

## API

`mergeCollections(array1, array2, options)`

- `Array array1` - Source collection.
- `Array array2` - Collection to merge.
- `Object options` - Options. (Optional)
  - `string id` - The identifier. Default: `'id'`. (Optional)
  - `boolean shallow` - Shallow extend. Default: `false`. (Optional)
- Returns `Array` - A new collection with the merged items.

## Example

```js
import mergeCollections from '@helcor/merge-collections';

const col1 = [
  { myId: 'x1', v: 'a' },
  { myId: 'x2', v: 'b' },
  { myId: 'x3', v: 'c' }
];
const col2 = [
  { myId: 'x1', v: 'x' },
  { myId: 'x2', v: 'y' },
  { myId: 'x4', v: 'z' }
];
const received = mergeCollections(col1, col2, { id: 'myId' });
const expected = [
  { myId: 'x1', v: 'x' },
  { myId: 'x2', v: 'y' },
  { myId: 'x3', v: 'c' },
  { myId: 'x4', v: 'z' }
];
expect(received).toEqual(expected);
```
npm package: @helcor/move-in-array
Description: Move an item by position in a list of positionated items
Latest version: 1.0.0-beta.9

![helcor](https://github.com/romelperez/helcor/raw/main/helcor.jpg)

# `@helcor/move-in-array`

<a href="https://npmjs.org/package/@helcor/move-in-array">
  <img src="https://img.shields.io/npm/v/@helcor/move-in-array.svg" alt="version" />
</a>
<a href="https://npmjs.org/package/@helcor/move-in-array">
  <img src="https://img.shields.io/npm/dm/@helcor/move-in-array.svg" alt="downloads" />
</a>

Move an item by position in a list of positionated items.

## API

`Array moveInArray(list, opts)`

- `Array list` - Current list of items.
- `Object opts` - Options.
  - `string id` - Element identifier to move.
  - `number to` - Position to move element.
  - `string key` - Optional element identifier key in the list. Default `'id'`.
  - `string positionKey` - Optional element position identifier key in the list.
  Default `'position'`.
- Returns `Array` - A new list with the updated items. If no update was made the
same list is returned.

## Example

Move element by id `'i1'` from position `1` to `3` where the id key is `'_id'` and
the position key is `'pos'`.

```js
const moveInArray = require('@helcor/move-in-array');

const list = [
  { _id: 'i0', pos: 0 },
  { _id: 'i1', pos: 1 },
  { _id: 'i2', pos: 2 },
  { _id: 'i3', pos: 3 },
  { _id: 'i4', pos: 4 }
];
const received = moveInArray(list, {
  id: 'i1',
  to: 3,
  key: '_id',
  positionKey: 'pos'
});
const expected = [
  { _id: 'i0', pos: 0 },
  { _id: 'i1', pos: 3 }, // moved down
  { _id: 'i2', pos: 1 }, // moved up
  { _id: 'i3', pos: 2 }, // moved up
  { _id: 'i4', pos: 4 }
];
expect(received).toEqual(expected);
expect(received).not.toBe(list);
```
npm package: @helcor/throttle
Description: Create rate-limit controlled functions
Latest version: 1.0.0-beta.11

![helcor](https://github.com/romelperez/helcor/raw/main/helcor.jpg)

# `@helcor/throttle`

<a href="https://npmjs.org/package/@helcor/throttle">
  <img src="https://img.shields.io/npm/v/@helcor/throttle.svg" alt="version" />
</a>
<a href="https://npmjs.org/package/@helcor/throttle">
  <img src="https://img.shields.io/npm/dm/@helcor/throttle.svg" alt="downloads" />
</a>

Creates a function that will be called once in a provided interval of time right
away when it is called. If you call the function for the first time, it will be
called, if you call the function between the first time and the end of the interval
of time, the function will not be called until the interval finishes.

## API

`throttle(fn, options)`

- `Function fn` - Function to throttle.
- `Object options` - Options. Optional.
  - `number interval` - Time in milliseconds to regulate. Default `1000`. Optional.
  - `Function gate` - Function to validate the throttle. If it returns `true`,
  we prevent the throttle and function will be called as normal. If not, the normal
  behavior is expected. Optional.
- Returns a function to use as a throttle.

## Example

A function that will feed you only once every 1 second. In total it will feed you
three times within 2 seconds (at 0s, 1s and 2s).

```js
import throttle from '@helcor/throttle';

function feed () {
  // eat something healthy... really
}
const feedRegulated = throttle(feed);

feedRegulated(); // (CALLED) ok, eat an apple
feedRegulated(); // you have just eaten, I'll do it 1s later
feedRegulated(); // nope, you have to wait...

setTimeout(() => {
  // (CALLED) ok, 1s passed, eat an orange
  feedRegulated(); // again, you have just eaten, wait 1 second more
  feedRegulated(); // hey, you'll get fat

  setTimeout(() => {
    // (CALLED) ok, another 1 second passed, eat pizz... no no, eat a banana
  }, 1000);
}, 1000);
```
npm package: @helcor/window-sizes
Description: Browser window dimensions and sizes manipulation.
Latest version: 1.0.0-beta.9

![helcor](https://github.com/romelperez/helcor/raw/main/helcor.jpg)

# `@helcor/window-sizes`

<a href="https://npmjs.org/package/@helcor/window-sizes">
  <img src="https://img.shields.io/npm/v/@helcor/window-sizes.svg" alt="version" />
</a>
<a href="https://npmjs.org/package/@helcor/window-sizes">
  <img src="https://img.shields.io/npm/dm/@helcor/window-sizes.svg" alt="downloads" />
</a>

Browser window dimensions and sizes manipulation.

## `getElementHeight`

Get an `HTMLElement` content height or a provided `window` body content height
in pixels.

### API

```js
import { getElementHeight } from '@helcor/window-sizes';
getElementHeight(element: HTMLElement | Window): number
```

### Examples

```js
// Get the window body content height.
const height = getElementHeight(window);

// Get an element content height.
const element = document.querySelector('#element-id');
const height = getElementHeight(element);
```

## `getViewportSize`

Get the browser viewport width and height in pixels.

### API

```js
import { getViewportSize } from '@helcor/window-sizes';
getViewportSize(
  { wMin, wMax, hMin, hMax }: { wMin: number, wMax: number, hMin: number, hMax: number } = {},
  defaultSize: { width: number, height: number }
): { width: number, height: number }
```

### Example

```js
// Get the raw browser viewport.
const { width, height } = getViewportSize();

// Get the raw browser viewport with minimum of 800x600 pixels.
const { width, height } = getViewportSize({ wMin: 800, hMin: 600 });
```