1.0.3 • Published 2 years ago

prioritize v1.0.3

Weekly downloads
3
License
MIT
Repository
github
Last release
2 years ago

Prioritize

A light ES6 wrapper on fetch to facilitate prioritization of calls.

npm build coverage deps size vulnerabilities license

Prioritize

A light wrapper on fetch to facilitate prioritization of calls.

npm install prioritize

prioritize.baseUrl

A baseUrl to prepend to the url for each call to fetch.

Default: window.location.protocol + '//' + window.location.host

prioritize.defaults

Default settings for each call to fetch.

Default: { headers: { 'Content-Type': 'application/json' } }

prioritize.fetch(url, settings) ⇒ Promise

Prioritized call to fetch.

Returns: Promise - Should be handled like a normal call to fetch.

ParamTypeDescription
urlstringURL to call.
settingsobjectAll settings available to fetch. - Adds any default settings from prioritize.defaults. - settings.body is passed through JSON.stringify() if appropriate.
settings.prioritystringIf set to "low" then this call is added to a queue until all ongoing calls are complete.
settings.paramsobjectSearch parameters to append to the url. example: { a: 1 } => ?a=1. Objects and Arrays are passed through JSON.stringify().

prioritize.get(url, settings) ⇒ Promise

Shortcut to prioritize.fetch with method: 'GET'.

Returns: Promise - Should be handled like a normal call to fetch.

ParamTypeDescription
urlstringURL to call.
settingsobjectPassed to prioritize.fetch with method: 'GET'.

prioritize.patch(url, settings) ⇒ Promise

Shortcut to prioritize.fetch with method: 'PATCH'.

Returns: Promise - Should be handled like a normal call to fetch.

ParamTypeDescription
urlstringURL to call.
settingsobjectPassed to prioritize.fetch with method: 'PATCH'.

prioritize.put(url, settings) ⇒ Promise

Shortcut to prioritize.fetch with method: 'PUT'.

Returns: Promise - Should be handled like a normal call to fetch.

ParamTypeDescription
urlstringURL to call.
settingsobjectPassed to prioritize.fetch with method: 'PUT'.

prioritize.post(url, settings) ⇒ Promise

Shortcut to prioritize.fetch with method: 'POST'.

Returns: Promise - Should be handled like a normal call to fetch.

ParamTypeDescription
urlstringURL to call.
settingsobjectPassed to prioritize.fetch with method: 'POST'.

prioritize.delete(url, settings) ⇒ Promise

Shortcut to prioritize.fetch with method: 'DELETE'.

Returns: Promise - Should be handled like a normal call to fetch.

ParamTypeDescription
urlstringURL to call.
settingsobjectPassed to prioritize.fetch with method: 'DELETE'.
1.0.3

2 years ago

1.0.2

4 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago