Skip to content

Commit

Permalink
YamlFetch
Browse files Browse the repository at this point in the history
  • Loading branch information
jacklehamster committed Jun 7, 2023
1 parent 2620a1c commit eb392da
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion public/gen/main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fetch from "./index";
import {yamlFetch} from "./index";

describe('yaml-fetch', () => {
const text = jest.fn();
Expand All @@ -18,7 +18,7 @@ describe('yaml-fetch', () => {
yaml:
- test
`));
const response = await fetch("dummy.yaml");
const response = await yamlFetch("dummy.yaml");
const yaml = await response.yaml();
expect(yaml).toEqual({yaml: ["test"]});
});
Expand Down
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const yaml = require('js-yaml');

export default async function fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response & {yaml():Promise<any>}> {
export type YamlFetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response & {yaml():Promise<any>}>;

export const yamlFetch: YamlFetch = async (input: RequestInfo | URL, init?: RequestInit): Promise<Response & {yaml():Promise<any>}> => {
const response = await global.fetch(input, init);
return {
...response,
Expand Down

0 comments on commit eb392da

Please sign in to comment.