@flowio/web-sdk
TypeScript icon, indicating that this package has built-in type declarations

2.1.13 • Public • Published

Overview

A module for common web development tasks when working with @flowio platform. Supports tree-shaking, so only the functions you use will be included in your bundle. No other dependencies.

stringify(object: object)

Stringify a JavaScript object into the format used by @flowio APIs. Can be used for formatting querystring parameters in the same format as the querystring Node module.

Example
import { stringify } from '@flowio/web-sdk';

const parameters = {
  foo: 'bar',
  baz: [
    'baz1',
    'baz2',
  ],
};

stringify(parameters);

// returns:
// foo=bar&baz[0]=baz1&baz[1]=baz2

parseQueryString(querystring: string)

Parse querystring is the same format as the output from stringify above.

JavaScript Example
import { parseQueryString } from '@flowio/web-sdk';

parseQueryString('foo=bar&baz[0]=baz1&baz[1]=baz2');

// returns:
// {
//   foo: 'bar',
//   baz: [
//     'baz1',
//     'baz2',
//   ],
// }
TypeScript Example
import { parseQueryString } from '@flowio/web-sdk';

type Parameters = {
  foo: string,
  baz: Array<string>,
};

parseQueryString<Parameters>('foo=bar&baz[0]=baz1&baz[1]=baz2');

// returns:
// {
//   foo: 'bar',
//   baz: [
//     'baz1',
//     'baz2',
//   ],
// }

appendQueryParameters(url: url, parameters: object)

Append querystring parameters to a URL.

Example
import { appendQueryParameters } from '@flowio/web-sdk';

const parameters = {
  foo: 'bar',
  baz: [
    'baz1',
    'baz2',
  ],
};

appendQueryParameters('https://example.com', parameters);


// returns:
// https://example.com?foo=bar&baz[0]=baz1&baz[1]=baz2

appendQueryParameters('https://example.com?existing=true', parameters);

// returns:
// https://example.com?existing=true&foo=bar&baz[0]=baz1&baz[1]=baz2

Readme

Keywords

none

Package Sidebar

Install

npm i @flowio/web-sdk

Weekly Downloads

18

Version

2.1.13

License

MIT

Unpacked Size

145 kB

Total Files

104

Last publish

Collaborators

  • martapralat
  • sid.jain
  • gdxn96
  • flowtech
  • roryh
  • cbosatflow
  • garethgd