I'm trying to transform this object:
url = {
page: 1,
limit: 20,
price_from: 1,
price_to: 500,
stock_from: 1,
stock_to: 200
}
To:
consumableURL = {
page: 1,
limit: 20,
price: {
price_from: 1,
price_to: 500,
},
stock: {
stock_from: 1,
stock_to: 200
}
}
How is this achievable, in a reusable manner to account for other possible introduced keys in the feature?
And I'm guessing also with validation to make sure the two pairs exist before mapping them into an object?