The risk of race condition is reduced for the results of deterministic functions you can use the memoization mechanism tests for deterministic functions are much easier to write and maintain instead of calling them the equivalent can be passed to the target in the form of their result referential transparency which may be useful when refactoring debugging or experimenting with the code in case of errors the process of debugging and fixing the code will usually be easier and faster. Below you will find an example of a trivial function that meets the described requirements.
const vat number . function calculate return price + price vat const price number const price number con calculate Price price price console. log calculatePrice price price Both the repeatability condition and the lack of side Phone Number List effects condition were met. The example below is a classic example of the impure function. const user Record<string unknown> id username 'admin' password ' ' function hidePassword user Record<string unknown> Record<string unknown> delete usssword return user consg hide Password user user The function shown is an impure function because it does not satisfy the no side effects condition. The function hide Passwor dmodifies the input object.
This happens because a reference to the object has been passed so that modifying the object inside the function f the transferred user. const user Record<string unknown> id username 'admin' password ' ' function hidePassword user Record<string unknown> Record<string unknown> const password ...userCopy user return userCopy console.log hidePassword user user My case with nex . . caused my project to start getting database connection authentication errors. It is worth mentioning that in my code was not the only source of database queries and all database clients used the same access data. A little investigation led me to the conclusion that the function that created the Knex instance had mistakenly become the impure function.