Skip to content

A encoder parameters function to transform data in params format

Notifications You must be signed in to change notification settings

aaranadev/encoder-parameters

Repository files navigation

#Encoder Parameters

Installation

If you are using yarn

yarn add @albertoarana/encoder-parameters

or npm

npm install @albertoarana/encoder-parameters --save

Use

Without serialize

import encoderParameters from '@albertoarana/encoder-parameters';

const params = {
  name: 'Alberto',
  lastname: 'Arana'
};

encoderParameters(params);
// ouput: ?name=Alberto&lastname=Arana

With serialize

import encoderParameters from '@albertoarana/encoder-parameters';

const serialize = {
  name: 'filterName',
  lastname: 'filterLastName'
};

const params = {
  name: 'Alberto',
  lastname: 'Arana'
};

encoderParameters(params, serialize);
// ouput: ?filterName=Alberto&filterLastName=Arana

Important

Currently Set or Map elements are not supported directly. For use these elements it is necessary transform their values into an array.

const map = new Map();

map.set(1, 1);
map.set(2, 2);

const params = {
  map: [...map.values()]
}

About

A encoder parameters function to transform data in params format

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published