UNPKG

5.44 kBMarkdownView Raw
1# Prioritize
2
3> A light ES6 wrapper on fetch to facilitate prioritization of calls.
4>
5> [![npm][npm]][npm-url]
6[![build][build]][build-url]
7[![coverage][coverage]][coverage-url]
8[![deps][deps]][deps-url]
9[![size][size]][size-url]
10[![vulnerabilities][vulnerabilities]][vulnerabilities-url]
11[![license][license]][license-url]
12
13
14<br><a name="module_prioritize"></a>
15
16## prioritize
17A light wrapper on fetch to facilitate prioritization of calls.
18
19```
20npm install prioritize
21```
22
23* [prioritize](#module_prioritize)
24 * [.baseUrl](#module_prioritize.baseUrl)
25 * [.defaults](#module_prioritize.defaults)
26 * [.fetch(url, [settings])](#module_prioritize.fetch) ⇒ <code>Promise</code>
27 * [.get(url, [settings])](#module_prioritize.get) ⇒ <code>Promise</code>
28 * [.patch(url, [settings])](#module_prioritize.patch) ⇒ <code>Promise</code>
29 * [.put(url, [settings])](#module_prioritize.put) ⇒ <code>Promise</code>
30 * [.post(url, [settings])](#module_prioritize.post) ⇒ <code>Promise</code>
31 * [.delete(url, [settings])](#module_prioritize.delete) ⇒ <code>Promise</code>
32
33
34<br><a name="module_prioritize.baseUrl"></a>
35
36### prioritize.baseUrl
37> A baseUrl to prepend to the url for each call to fetch
38
39**Default**: <code>&#x27;&#x27;</code>
40
41<br><a name="module_prioritize.defaults"></a>
42
43### prioritize.defaults
44> Default settings for each call to fetch.
45
46**Default**: <code>{ headers: { &#x27;Content-Type&#x27;: &#x27;application/json&#x27; } }</code>
47
48<br><a name="module_prioritize.fetch"></a>
49
50### prioritize.fetch(url, [settings]) ⇒ <code>Promise</code>
51> Prioritized call to fetch.
52
53**Returns**: <code>Promise</code> - Should be handled like a normal call to fetch
54
55| Param | Type | Description |
56| --- | --- | --- |
57| url | <code>string</code> | URL to call |
58| [settings] | <code>object</code> | All settings available to fetch.<br> - Adds any default settings from prioritize.defaults.<br> - settings.body is passed through JSON.stringify() if appropriate. |
59| [settings.priority] | <code>string</code> | If set to "low" then this call is added to a queue until all previously added calls are complete. |
60
61
62<br><a name="module_prioritize.get"></a>
63
64### prioritize.get(url, [settings]) ⇒ <code>Promise</code>
65> Shortcut to prioritize.fetch with method: 'GET'.
66
67**Returns**: <code>Promise</code> - Should be handled like a normal call to fetch
68
69| Param | Type | Description |
70| --- | --- | --- |
71| url | <code>string</code> | URL to call |
72| [settings] | <code>object</code> | Passed to prioritize.fetch with method: 'GET' |
73
74
75<br><a name="module_prioritize.patch"></a>
76
77### prioritize.patch(url, [settings]) ⇒ <code>Promise</code>
78> Shortcut to prioritize.fetch with method: 'PATCH'.
79
80**Returns**: <code>Promise</code> - Should be handled like a normal call to fetch
81
82| Param | Type | Description |
83| --- | --- | --- |
84| url | <code>string</code> | URL to call. |
85| [settings] | <code>object</code> | Passed to prioritize.fetch with method: 'PATCH' |
86
87
88<br><a name="module_prioritize.put"></a>
89
90### prioritize.put(url, [settings]) ⇒ <code>Promise</code>
91> Shortcut to prioritize.fetch with method: 'PUT'.
92
93**Returns**: <code>Promise</code> - Should be handled like a normal call to fetch
94
95| Param | Type | Description |
96| --- | --- | --- |
97| url | <code>string</code> | URL to call |
98| [settings] | <code>object</code> | Passed to prioritize.fetch with method: 'PUT' |
99
100
101<br><a name="module_prioritize.post"></a>
102
103### prioritize.post(url, [settings]) ⇒ <code>Promise</code>
104> Shortcut to prioritize.fetch with method: 'POST'.
105
106**Returns**: <code>Promise</code> - Should be handled like a normal call to fetch
107
108| Param | Type | Description |
109| --- | --- | --- |
110| url | <code>string</code> | URL to call |
111| [settings] | <code>object</code> | Passed to prioritize.fetch with method: 'POST' |
112
113
114<br><a name="module_prioritize.delete"></a>
115
116### prioritize.delete(url, [settings]) ⇒ <code>Promise</code>
117> Shortcut to prioritize.fetch with method: 'DELETE'.
118
119**Returns**: <code>Promise</code> - Should be handled like a normal call to fetch
120
121| Param | Type | Description |
122| --- | --- | --- |
123| url | <code>string</code> | URL to call |
124| [settings] | <code>object</code> | Passed to prioritize.fetch with method: 'DELETE' |
125
126
127[npm]: https://img.shields.io/npm/v/prioritize.svg
128[npm-url]: https://npmjs.com/package/prioritize
129[build]: https://travis-ci.org/DarrenPaulWright/prioritize.svg?branch&#x3D;master
130[build-url]: https://travis-ci.org/DarrenPaulWright/prioritize
131[coverage]: https://coveralls.io/repos/github/DarrenPaulWright/prioritize/badge.svg?branch&#x3D;master
132[coverage-url]: https://coveralls.io/github/DarrenPaulWright/prioritize?branch&#x3D;master
133[deps]: https://david-dm.org/darrenpaulwright/prioritize.svg
134[deps-url]: https://david-dm.org/darrenpaulwright/prioritize
135[size]: https://packagephobia.now.sh/badge?p&#x3D;prioritize
136[size-url]: https://packagephobia.now.sh/result?p&#x3D;prioritize
137[vulnerabilities]: https://snyk.io/test/github/DarrenPaulWright/prioritize/badge.svg?targetFile&#x3D;package.json
138[vulnerabilities-url]: https://snyk.io/test/github/DarrenPaulWright/prioritize?targetFile&#x3D;package.json
139[license]: https://img.shields.io/github/license/DarrenPaulWright/prioritize.svg
140[license-url]: https://npmjs.com/package/prioritize/LICENSE.md