5.0.1 • Published 4 years ago

thesmo-calc-fields-object v5.0.1

Weekly downloads
21
License
MIT
Repository
github
Last release
4 years ago

npm GitHub GitHub last commit npm GitHub top language code style: prettier

Summary

This package contains calculating fields for object source values.

Functions

getNode

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

type Args = {
    nodePath: string;
};

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

getObjectGuarantor

Generates guarantor for object unsafe calculating fields

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

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

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

merge

Generates UnsafeCF for objects merging

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)

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)

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>
5.0.1

4 years ago

5.0.0

4 years ago

4.1.4

4 years ago

4.1.3

4 years ago

4.1.2

4 years ago

4.1.1

4 years ago

4.1.0

4 years ago

4.0.16

4 years ago

4.0.15

4 years ago

4.0.14

4 years ago

4.0.13

4 years ago

4.0.12

4 years ago

4.0.11

4 years ago

4.0.10

4 years ago

4.0.9

4 years ago

4.0.8

4 years ago

4.0.7

4 years ago

4.0.6

4 years ago

4.0.5

4 years ago

4.0.4

4 years ago

4.0.3

4 years ago

4.0.2

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago

3.0.7

4 years ago

3.0.6

4 years ago

3.0.5

4 years ago

3.0.4

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.3

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.3.15

4 years ago

1.3.14

4 years ago

1.2.13

4 years ago

1.2.14

4 years ago

1.2.12

4 years ago

1.2.11

4 years ago

1.2.8

4 years ago

1.2.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.2.9

4 years ago

1.2.10

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

0.1.1

4 years ago

0.0.1

4 years ago