Skip to content

Latest commit

 

History

History
27 lines (17 loc) · 808 Bytes

urlQueryDecoder.md

File metadata and controls

27 lines (17 loc) · 808 Bytes

urlQueryDecoder(config)

A helper function to create a query decoder from urlPropsQueryConfig.

Arguments

  1. config (Object): The urlPropsQueryConfig object, see urlPropsQueryConfig for details.

Returns

(Function): A function which, given an object with encoded parameters, returns the decoded equivalent. It compares against cached values to see if decoding is necessary or if it can reuse old values.

Examples

const urlPropsQueryConfig = {
  foo: { type: UrlQueryParamTypes.number, queryParam: 'fooInUrl' },
  bar: { type: UrlQueryParamTypes.string },
};

const decode = urlQueryDecoder(urlPropsQueryConfig);

decode({ fooInUrl: '137', bar: 'str' });
// === { foo: 137, bar: 'str' }