-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove: iterateEndPoint was deleted.
- Loading branch information
Showing
9 changed files
with
145 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
import checkPrimitiveValue from "./check-primitive-value"; | ||
|
||
/** | ||
* @description Вернёт true если возможно перебрать значение вглубь. | ||
* */ | ||
export default function checkDeepValue(value: unknown) { | ||
return !checkPrimitiveValue(value) && !Array.isArray(value) && !Object.isFrozen(value); | ||
return !( | ||
checkPrimitiveValue(value) || | ||
Array.isArray(value) || | ||
Object.isFrozen(value) | ||
) ; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import isEndPointValue from "./is-end-point-value"; | ||
import isEmptyObject from "./is-empty-object"; | ||
|
||
/** | ||
* @description Функция используется для логики формы. Т.к. нам часто нужно проходить по объектам и перебирать их свойства, | ||
* то это функция отвечает на вопрос: Является ли переданное значение итерируемым и можно ли зайти внутрь его. | ||
* */ | ||
export default function isIterablePoint(value: unknown) { | ||
return !(isEndPointValue(value) || isEmptyObject(value)) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,16 @@ | ||
import {Values} from "../types"; | ||
import isEndPointValue from "./is-end-point-value"; | ||
import iterateEndpoint from "./iterate-endpoint"; | ||
import generateFieldByPath from "./generate-field-by-path"; | ||
import bypassObject from "./bypass-object"; | ||
|
||
/** | ||
* @description Метод вернёт новый объект, заменив все примитивные значения | ||
* на переданный аргумент. | ||
* */ | ||
|
||
function replace(o: Values, value: any): {} { | ||
Object.keys(o) | ||
.forEach(key => { | ||
if (isEndPointValue(o[key])) return o[key] = value; | ||
|
||
replace(o[key], value); | ||
}) | ||
|
||
return o; | ||
} | ||
|
||
export default function replaceValues(object: Values, value: any = true) { | ||
|
||
return iterateEndpoint(object) | ||
return bypassObject(object) | ||
.reduce((acc: any, item) => { | ||
generateFieldByPath(acc, item.path, value) | ||
return acc; | ||
}, {}) | ||
|
||
/* | ||
const copyObject = JSON.parse(JSON.stringify(object)); | ||
return replace(copyObject, value);*/ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.