@ribbon-studios/js-utils 1.6.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/index.cjs +7 -8
- package/dist/index.js +7 -8
- package/dist/rfetch.d.ts +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ Collection of generic javascript utilities curated by the Ribbon Studios Team~
|
|
|
26
26
|
- [`rfetch.put`](#rfetchput)
|
|
27
27
|
- [`rfetch.post`](#rfetchpost)
|
|
28
28
|
- [`rfetch.patch`](#rfetchpatch)
|
|
29
|
-
- [`rfetch.
|
|
29
|
+
- [`rfetch.delete`](#rfetchdelete)
|
|
30
30
|
- [`rfetch.interceptors`](#rfetchinterceptors)
|
|
31
31
|
- [`rfetch.delimiters`](#rfetchdelimiters)
|
|
32
32
|
|
|
@@ -195,7 +195,7 @@ import { rfetch, type RibbonFetchError } from '@ribbon-studios/js-utils';
|
|
|
195
195
|
await rfetch.patch<MyExpectedResponse>('https://ribbonstudios.com');
|
|
196
196
|
```
|
|
197
197
|
|
|
198
|
-
### `rfetch.
|
|
198
|
+
### `rfetch.delete`
|
|
199
199
|
|
|
200
200
|
Shorthand for DELETE requests.
|
|
201
201
|
|
|
@@ -203,7 +203,7 @@ Shorthand for DELETE requests.
|
|
|
203
203
|
import { rfetch, type RibbonFetchError } from '@ribbon-studios/js-utils';
|
|
204
204
|
|
|
205
205
|
// Shorthand for DELETE requests.
|
|
206
|
-
await rfetch.
|
|
206
|
+
await rfetch.delete<MyExpectedResponse>('https://ribbonstudios.com');
|
|
207
207
|
```
|
|
208
208
|
|
|
209
209
|
### `rfetch.interceptors`
|
package/dist/index.cjs
CHANGED
|
@@ -81,10 +81,6 @@ async function rfetch(url, { params, body, ...options } = {}) {
|
|
|
81
81
|
if (requestInit.method !== "GET" && body) {
|
|
82
82
|
if (body instanceof FormData) {
|
|
83
83
|
requestInit.body = body;
|
|
84
|
-
requestInit.headers = {
|
|
85
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
86
|
-
...requestInit.headers
|
|
87
|
-
};
|
|
88
84
|
} else if (typeof body === "string") {
|
|
89
85
|
requestInit.body = body;
|
|
90
86
|
requestInit.headers = {
|
|
@@ -117,6 +113,12 @@ async function rfetch(url, { params, body, ...options } = {}) {
|
|
|
117
113
|
})
|
|
118
114
|
);
|
|
119
115
|
}
|
|
116
|
+
rfetch.delete = (url, options) => {
|
|
117
|
+
return rfetch(url, {
|
|
118
|
+
...options,
|
|
119
|
+
method: "DELETE"
|
|
120
|
+
});
|
|
121
|
+
};
|
|
120
122
|
((rfetch2) => {
|
|
121
123
|
async function get(url, options) {
|
|
122
124
|
return rfetch2(url, {
|
|
@@ -147,10 +149,7 @@ async function rfetch(url, { params, body, ...options } = {}) {
|
|
|
147
149
|
}
|
|
148
150
|
rfetch2.patch = patch;
|
|
149
151
|
async function remove(url, options) {
|
|
150
|
-
return rfetch2(url,
|
|
151
|
-
...options,
|
|
152
|
-
method: "DELETE"
|
|
153
|
-
});
|
|
152
|
+
return rfetch2.delete(url, options);
|
|
154
153
|
}
|
|
155
154
|
rfetch2.remove = remove;
|
|
156
155
|
async function delimiters(type) {
|
package/dist/index.js
CHANGED
|
@@ -79,10 +79,6 @@ async function rfetch(url, { params, body, ...options } = {}) {
|
|
|
79
79
|
if (requestInit.method !== "GET" && body) {
|
|
80
80
|
if (body instanceof FormData) {
|
|
81
81
|
requestInit.body = body;
|
|
82
|
-
requestInit.headers = {
|
|
83
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
84
|
-
...requestInit.headers
|
|
85
|
-
};
|
|
86
82
|
} else if (typeof body === "string") {
|
|
87
83
|
requestInit.body = body;
|
|
88
84
|
requestInit.headers = {
|
|
@@ -115,6 +111,12 @@ async function rfetch(url, { params, body, ...options } = {}) {
|
|
|
115
111
|
})
|
|
116
112
|
);
|
|
117
113
|
}
|
|
114
|
+
rfetch.delete = (url, options) => {
|
|
115
|
+
return rfetch(url, {
|
|
116
|
+
...options,
|
|
117
|
+
method: "DELETE"
|
|
118
|
+
});
|
|
119
|
+
};
|
|
118
120
|
((rfetch2) => {
|
|
119
121
|
async function get(url, options) {
|
|
120
122
|
return rfetch2(url, {
|
|
@@ -145,10 +147,7 @@ async function rfetch(url, { params, body, ...options } = {}) {
|
|
|
145
147
|
}
|
|
146
148
|
rfetch2.patch = patch;
|
|
147
149
|
async function remove(url, options) {
|
|
148
|
-
return rfetch2(url,
|
|
149
|
-
...options,
|
|
150
|
-
method: "DELETE"
|
|
151
|
-
});
|
|
150
|
+
return rfetch2.delete(url, options);
|
|
152
151
|
}
|
|
153
152
|
rfetch2.remove = remove;
|
|
154
153
|
async function delimiters(type) {
|
package/dist/rfetch.d.ts
CHANGED
|
@@ -27,6 +27,10 @@ export declare enum DelimiterType {
|
|
|
27
27
|
* @returns The typed response or an error containing the `status` and the `content`
|
|
28
28
|
*/
|
|
29
29
|
export declare function rfetch<T = any>(url: string | URL, { params, body, ...options }?: RibbonFetchOptions): Promise<T>;
|
|
30
|
+
export declare namespace rfetch {
|
|
31
|
+
var _a: <T>(url: string | URL, options?: RibbonFetchBodyOptions) => Promise<T>;
|
|
32
|
+
export { _a as delete };
|
|
33
|
+
}
|
|
30
34
|
export declare namespace rfetch {
|
|
31
35
|
/**
|
|
32
36
|
* Shorthand method for a GET request
|
|
@@ -66,7 +70,7 @@ export declare namespace rfetch {
|
|
|
66
70
|
* @param url The url you wish to fetch.
|
|
67
71
|
* @param options The request options.
|
|
68
72
|
* @returns The typed response or an error containing the `status` and the `content`
|
|
69
|
-
* @
|
|
73
|
+
* @deprecated in favor of {@link rfetch.delete}
|
|
70
74
|
*/
|
|
71
75
|
function remove<T>(url: string | URL, options?: RibbonFetchBodyOptions): Promise<T>;
|
|
72
76
|
function delimiters(type: DelimiterType): Promise<void>;
|