Skip to content

Add increment() and decrement() #17

@cwayfinder

Description

@cwayfinder

This is a feature request. There is toggle() for a boolean value and I would like to have similar stuff for numbers.

Example: the following code

const deadCount = state.players[playerIndex].commander.deadCount + 1;
state = dotProp.merge(state, `players.${playerIndex}.commander`, { deadCount });

could be replaced with

state = dotProp.increment(state, `players.${playerIndex}.commander.deadCount`);

I used merge instead of set because the property deadCount might be not initialized. In this case, we can treat it as 0.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions