# thesmo-calc-fields-object

> Collection of calculating fields for manipulating with objects

Latest version **5.0.1** (published 2020-04-19) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install thesmo-calc-fields-object
pnpm add thesmo-calc-fields-object
yarn add thesmo-calc-fields-object
bun add thesmo-calc-fields-object
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 5.0.1 |
| Published | 2020-04-19 |
| First published | 2020-01-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 60.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | revrulb |
| Maintainers | revrulb |
| Keywords | calculating-fields, object, functional, fp, merge, fields, update, data-manipulation, state |

## Links

- npm: https://www.npmjs.com/package/thesmo-calc-fields-object
- Repository: https://github.com/revrulb/thesmo-calc-fields-object
- Homepage: https://github.com/revrulb/thesmo-calc-fields-object#readme
- Issues: https://github.com/revrulb/thesmo-calc-fields-object/issues
- npm.io page: https://npm.io/package/thesmo-calc-fields-object

## Dependencies (1)

- [thesmo-calc-fields-base](https://npm.io/package/thesmo-calc-fields-base.md) ^5.0.0

## Recent versions

- 5.0.1 (latest) — 2020-04-19
- 5.0.0 — 2020-04-12
- 4.1.4 — 2020-03-16
- 4.1.3 — 2020-03-16
- 4.1.2 — 2020-03-16
- 4.1.1 — 2020-03-09
- 4.1.0 — 2020-03-09
- 4.0.16 — 2020-03-03
- 4.0.15 — 2020-03-03
- 4.0.14 — 2020-03-03
- 4.0.13 — 2020-03-02
- 4.0.12 — 2020-03-02
- 4.0.11 — 2020-03-02
- 4.0.10 — 2020-03-02
- 4.0.9 — 2020-02-28
- … 42 more at https://npm.io/package/thesmo-calc-fields-object/versions

## README

<p align="center">
    <img src='https://raw.githubusercontent.com/revrulb/thesmo-calc-fields-object/master/logo.svg?sanitize=true'></img>
</p>

![npm](https://img.shields.io/npm/v/thesmo-calc-fields-object)
![GitHub](https://img.shields.io/github/license/revrulb/thesmo-calc-fields-object)
![GitHub last commit](https://img.shields.io/github/last-commit/revrulb/thesmo-calc-fields-object)
![npm](https://img.shields.io/npm/dm/thesmo-calc-fields-object)
![GitHub top language](https://img.shields.io/github/languages/top/revrulb/thesmo-calc-fields-object)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)


# Summary

This package contains **calculating fields for object source values**.

# Functions

## **getNode**

Generates UnsafeCF for obtaining node from source object
by its' path

```typescript
type Args = {
    nodePath: string;
};

type Signature = ({ nodePath }: Args) => UnsafeCF<unknown>
```

## **getObjectGuarantor**

Generates guarantor for object unsafe calculating fields

```typescript
type Args = {
    convertArrayToArrayLikeObject?: boolean;
    convertNullToEmptyObject?: boolean;
    convertUndefinedToEmptyObject?: boolean;
};

type Signature = ({
    convertArrayToArrayLikeObject = false,
    convertNullToEmptyObject = false,
    convertUndefinedToEmptyObject = false
}: Args) => Guarantor<object>
```

## **getRequiredFieldNames**

Generates UnsafeCF for obtaining names of fields which
satisfy custom check based on their names and values

```typescript
type Args = {
    check: ({ fieldName, fieldValue }: CheckArgs) => boolean;
};

type Signature = ({ check }: Args) => UnsafeCF<string[]>
```

## **merge**

Generates UnsafeCF for objects merging

```typescript
type Args<T> = {
    partToBeMergedWith: T;
};

type Signature = <
    Source extends object,
    MergingPart extends object = Partial<Source>
>({
    partToBeMergedWith
}: Args<MergingPart>) => UnsafeCF<Source & MergingPart>
```

## **updateInClone**

Generates UnsafeCF for updating source object without
changing it (modified copy will be returned)

```typescript
type Args<Source, Result> = {
    nodePath: string;
    calcField: SafeCF<Source, Result>;
};

type Signature = <Source, Result>({
    nodePath,
    calcField
}: Args<Source, Result>): UnsafeCF<object>
```

## **updateWithPattern**

Generates UnsafeCF for updating source with given pattern
(pattern makes possible to change required source fields via
calculating fields)

```typescript
type UpdatingPattern<T extends object> = Partial<
    {
        [K in keyof T]: SafeCF<T[K]>;
    }
>;

type Args<T extends object> = {
    pattern: UpdatingPattern<T>;
};

type Signature = <T extends object>({
    pattern
}: Args<T>): UnsafeCF<T>
```

---
_Source: https://npm.io/package/thesmo-calc-fields-object · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
