# @frui.ts/helpers

> Frui.ts helper functions

Latest version **1.0.0-rc.4** (published 2023-11-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @frui.ts/helpers
pnpm add @frui.ts/helpers
yarn add @frui.ts/helpers
bun add @frui.ts/helpers
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0-rc.4 |
| Published | 2023-11-26 |
| First published | 2020-04-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 30.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Author | Augustin Šulc |
| Maintainers | jindrichskupa, zales, eman.devops, strnadj, gius |
| Keywords | front-end, framework, mvvm, helpers |

## Links

- npm: https://www.npmjs.com/package/@frui.ts/helpers
- Repository: https://github.com/eManPrague/frui.ts
- Issues: https://github.com/eManPrague/frui.ts/issues
- npm.io page: https://npm.io/package/@frui.ts/helpers

## Alternatives

- [@sveltejs/kit](https://npm.io/package/@sveltejs/kit.md) — 2.2M weekly downloads
- [@atlaskit/theme](https://npm.io/package/@atlaskit/theme.md) — 402.0K weekly downloads
- [@tangle-network/brand](https://npm.io/package/@tangle-network/brand.md) — 10.0K weekly downloads
- [seneca](https://npm.io/package/seneca.md) — 7.4K weekly downloads
- [@bsb/base](https://npm.io/package/@bsb/base.md) — 7.2K weekly downloads

## Recent versions

- 1.0.0-rc.4 (latest) — 2023-11-26
- 1.0.0-rc.3 — 2023-09-03
- 1.0.0-rc.2 — 2023-07-26
- 1.0.0-rc.1 — 2023-06-12
- 1.0.0-beta.6 — 2023-02-21
- 1.0.0-beta.5 — 2023-02-14
- 1.0.0-beta.4 — 2022-12-07
- 1.0.0-beta.3 — 2022-12-05
- 1.0.0-beta.2 — 2022-11-24
- 0.17.5 — 2022-07-19
- 1.0.0-beta.1 — 2022-06-30
- 0.17.4 — 2022-04-12
- 1.0.0-alpha.14 — 2022-03-18
- 1.0.0-alpha.13 — 2022-03-18
- 1.0.0-alpha.12 — 2022-03-12
- … 63 more at https://npm.io/package/@frui.ts/helpers/versions

## README

# `@frui.ts/helpers`

Helper functions for various use cases.

## `@bound`

A function decorator that binds context of the function to the parent class. This is useful for direct use of the function as event handler `<Xxx onClick={vm.decoratedFunction} />` so that new anonymous functions are not allocated for each render (compare to `<Xxx onClick={() => vm.decoratedFunction()} />`).

### Usage

```ts
// in view model
class MyViewModel {
  @bound someAction() {
    // you can safely use 'this' here
  }
}

// in view
<button onClick={vm.someAction} />
```

## `createMap`

Helper function for easily creating Maps.

### Usage

```ts
const items = [
  { id: 1, name: "One" },
  { id: 2, name: "Two" },
  { id: 3, name: "Three" },
];

// map of items by key
const itemsById = createMap(items, x => x.id); // Map<number, { id, name }>

// map of values by key
const namesById = createMap(items, x => x.id, x => x.name); // Map<number, string>
```

## `nameof`

Syntactic sugar for creating strings that are also a key of a type.

### Usage

```ts
this.pagingFilter.sortColumn = nameof<User>("login"); // the same as ="login", but checked on compile time that the class 'User' actually has a 'login' field
```


## `ManualPromise`

TODO

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