If you are using yarn
yarn add @albertoarana/decoder-parameters
or npm
npm install @albertoarana/decoder-parameters --save
import decoderParameters from '@albertoarana/decoder-parameters';
const params = '?name=Alberto&lastName=Arana';
decoderParameters(params);
// ouput: {name: 'Alberto', lastName: 'Arana'}
import decoderParameters from '@albertoarana/decoder-parameters';
const serialize = {
filterName: 'name',
filterLastName: 'lastName'
};
const params = '?filterName=Alberto&FilterLastName=Arana';
decoderParameters(params, serialize);
// ouput: {name: 'Alberto', lastname: 'Arana'}