appointments.js
1 year ago
attendees.js
1 year ago
colorManipulation.js
3 years ago
customer.js
1 year ago
date.js
1 year ago
defaultCustomize.js
1 year ago
employee.js
1 year ago
events.js
1 year ago
formFieldsTemplates.js
3 years ago
formatting.js
1 year ago
helper.js
1 year ago
image.js
1 year ago
integrationApple.js
1 year ago
integrationGoogle.js
1 year ago
integrationOutlook.js
1 year ago
integrationStripe.js
1 year ago
integrationZoom.js
1 year ago
licence.js
2 years ago
objectAndArrayManipulation.js
3 years ago
pricing.js
1 year ago
recurring.js
1 year ago
responsive.js
1 year ago
scrollElements.js
4 years ago
settings.js
1 year ago
translationsElementPlus.js
1 year ago
objectAndArrayManipulation.js
33 lines
| 1 | function usePopulateMultiDimensionalObject (needle, haystack, customFunction) { |
| 2 | let stack = [] |
| 3 | function loop(haystack, stack) { |
| 4 | for (let [location, v] of Object.entries(haystack)) { |
| 5 | stack.push(location); |
| 6 | if (location === needle) { |
| 7 | customFunction(v) |
| 8 | break; |
| 9 | } else if (typeof v === 'object') { |
| 10 | loop(v, stack); |
| 11 | } |
| 12 | } |
| 13 | } |
| 14 | loop(haystack, stack); |
| 15 | } |
| 16 | |
| 17 | function useOverrideValuesOfOneObjectWithAnother (needle, haystack, target, customFunction) { |
| 18 | let stack = [] |
| 19 | function loop(stack, haystack, target) { |
| 20 | for (let [location, v] of Object.entries(haystack)) { |
| 21 | stack.push(location); |
| 22 | if (location === needle) { |
| 23 | customFunction(haystack, target) |
| 24 | break; |
| 25 | } else if (typeof v === 'object' && v !== null) { |
| 26 | loop(stack, v, target[location]); |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 | loop(stack, haystack, target); |
| 31 | } |
| 32 | |
| 33 | export { usePopulateMultiDimensionalObject , useOverrideValuesOfOneObjectWithAnother} |