{"id":17784937,"url":"https://github.com/mellkam/yumi-fetch","last_synced_at":"2025-03-16T04:30:51.115Z","repository":{"id":162307646,"uuid":"636354408","full_name":"MellKam/yumi-fetch","owner":"MellKam","description":"An extensible fetch wrapper for simplified and powerful HTTP requests using native web APIs 🍭","archived":true,"fork":false,"pushed_at":"2023-08-28T20:36:35.000Z","size":188,"stargazers_count":8,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-15T08:35:39.549Z","etag":null,"topics":["client","fetch","http","request","web-api","wrapper","yumi"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MellKam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-04T17:00:47.000Z","updated_at":"2025-03-07T14:26:14.000Z","dependencies_parsed_at":"2024-12-11T22:43:12.551Z","dependency_job_id":null,"html_url":"https://github.com/MellKam/yumi-fetch","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MellKam%2Fyumi-fetch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MellKam%2Fyumi-fetch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MellKam%2Fyumi-fetch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MellKam%2Fyumi-fetch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MellKam","download_url":"https://codeload.github.com/MellKam/yumi-fetch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243826788,"owners_count":20354220,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client","fetch","http","request","web-api","wrapper","yumi"],"created_at":"2024-10-27T08:22:29.192Z","updated_at":"2025-03-16T04:30:51.110Z","avatar_url":"https://github.com/MellKam.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://svgshare.com/i/tf_.svg\" align=\"center\" width=\"420px\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/yumi-fetch\"\u003e\n    \u003cimg alt=\"npm\" src=\"https://img.shields.io/npm/v/yumi-fetch?color=FF3797\u0026label=npm\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://deno.land/x/yumi\"\u003e\n    \u003cimg alt=\"deno.land\" src=\"https://img.shields.io/github/v/tag/MellKam/yumi-fetch?color=FF3797\u0026label=deno.land%2Fx\u0026logo=deno\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/MellKam/yumi-fetch/blob/main/LICENSE\"\u003e\n    \u003cimg alt=\"license\" src=\"https://img.shields.io/github/license/MellKam/yumi-fetch?color=FF3797\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/MellKam/soundify/commits/main\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/last-commit/MellKam/yumi-fetch?color=FF3797\" alt=\"Last commit\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://bundlejs.com/?q=yumi-fetch\u0026treeshake=%5B%7B+yumi+%7D%5D\"\u003e\n    \u003cimg src=\"https://deno.bundlejs.com/?q=yumi-fetch\u0026treeshake=[{+yumi+}]\u0026badge=minified\u0026color=FF3797\" alt=\"Size of yumi client\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/MellKam/yumi-fetch\"\u003e\n    \u003cimg src=\"https://img.shields.io/codecov/c/gh/MellKam/yumi-fetch?color=FF3797\u0026label=coverage\" alt=\"Code test coverage\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003eExtensible and tiny HTTP client, that gives you unlimited control over you requests\u003c/p\u003e\n\n# Table of Contents\n\n- [Table of Contents](#table-of-contents)\n- [Features](#features)\n- [Installation](#installation)\n  - [npmjs.com](#npmjscom)\n  - [unpkg.com](#unpkgcom)\n  - [deno.land](#denoland)\n- [Getting started](#getting-started)\n- [Bundle size comparison](#bundle-size-comparison)\n- [Benchmark comparison](#benchmark-comparison)\n\n# Features\n\n- 🌐 Global options: The client object allows you to set global request options, headers, and a baseURL for all requests.\n- 💡 Middlewares: Gain full control over requests and responses using middlewares.\n- 💪 Custom client properties: Extend the client with your own custom properties. Add additional functionality or data to enhance the client's capabilities.\n- 🔍 Custom response methods: Extend the response object with custom functions.\n- 🔌 Powerful plugin system: Benefit from a robust plugin system that offers a wide range of out-of-the-box plugins.\n- ✨ Fully type safe: Typescript first package. I fight with typescript, so you dont need to.\n\n# Installation\n\nThis package works with various JavaScript runtimes, utilizing the Fetch API available in most modern environments. It supports web browsers, Node.js (v17.5 and above), and older Node.js versions when using a package like [node-fetch](https://github.com/node-fetch/node-fetch). It is also compatible with Deno, Bun, and other runtimes supporting the Fetch API.\n\n## [npmjs.com](https://www.npmjs.com/package/yumi-fetch)\n\n```bash\nnpm i yumi-fetch\n```\n\n## [unpkg.com](https://www.unpkg.com/yumi-fetch)\n\n```html\n\u003cscript type=\"module\"\u003e\nimport { yumi } from \"https://unpkg.com/yumi-fetch/dist/mod.js\";\n\u003c/script\u003e\n```\n\n## [deno.land](https://deno.land/x/yumi)\n\n```ts\nimport { yumi } from \"https://deno.land/x/yumi/mod.ts\";\n```\n\n# Getting started\n\n```ts\nimport { yumi } from \"yumi-fetch\";\n\nconst client = yumi.withBaseURL(\"https://dummyjson.com/\");\n\ntype Todo = {\n  id: number;\n  todo: string;\n  completed: boolean;\n  userId: number;\n};\n\ntype Todos = {\n  todos: Todo[];\n  total: number;\n  skip: number;\n  limit: number;\n};\n\nconst { todos } = await client\n  .get(\"/todos\", { query: { limit: 2 } })\n  .json\u003cTodos\u003e();\n\nconsole.log(todos);\n\nconst createdTodo = await client\n  .post(\"/todos/add\", {\n    json: {\n      todo: \"Star Yumi-Fetch repository\",\n      completed: false,\n      userId: 5,\n    },\n  })\n  .json\u003cTodo\u003e();\n\nconsole.log(createdTodo);\n```\n\nHere you can find a straightforward API that is similar to the `fetch` function but with several notable improvements. You may be familiar with these features from libraries like `axios`, etc.. Firstly, it includes functions named after HTTP methods, such as `.post()` and `.get()`, which make it more intuitive and convenient to perform these actions. Additionally, the API provides simplified serialization capabilities and includes a `.json()` resolver for easy handling of JSON data.\n\n\u003cdetails\u003e\n  \u003csummary\u003eFor comparison, here's a code snippet using the plain fetch function\u003c/summary\u003e\n  \n  ```ts\n  type Todo = {\n    id: number;\n    todo: string;\n    completed: boolean;\n    userId: number;\n  };\n\n  type Todos = {\n    todos: Todo[];\n    total: number;\n    skip: number;\n    limit: number;\n  };\n\n  const res = await fetch(\"https://dummyjson.com/todos?limit=2\", \n    { \n      headers: { \"Accept\": \"application/json\" } \n    }\n  );\n  if (!res.ok) throw new Error(await res.text());\n  const { todos } = (await res.json()) as Todos;\n\n  console.log(todos);\n\n  const res2 = await fetch(\"https://dummyjson.com/todos/add\", \n    { \n      method: \"POST\",\n      headers: { \n        \"Accept\": \"application/json\", \n        \"Content-Type\": \"application/json\" \n      },\n      body: JSON.stringify({\n        todo: \"Star Yumi-Fetch repository\",\n        completed: false,\n        userId: 5,\n      }) \n    }\n  );\n\n  if (!res2.ok) throw new Error(await res.text());\n  const createdTodo = (await res2.json()) as Todo;\n\n  console.log(createdTodo);\n  ```\n\u003c/details\u003e\n\n__Imagine a scenario where I told you that all these incredible features can be easily attached to your client as modular plug-ins, allowing you to effortlessly expand its functionality. Well, guess what? It's absolutely true!__\n\nThe `yumi` object we imported is essentially a client that has been enhanced with custom modifications on top of it.\n\n```ts\nimport { clientCore, /* ... */ } from \"yumi-fetch\";\n\nexport const yumi = clientCore\n  // adds http methods like .get(), .post(), .put() ...\n  .withProperties(httpMethods()) \n  // adds response resolvers .json(), .text(), .formData() ...\n  .withResolvers(bodyResolvers())\n  // adds query serialization\n  .withPlugin(query())\n  // adds json serialization\n  .withPlugin(json());\n```\n\nThe beauty of this approach is that all these plug-ins seamlessly modify the client type, making it a breeze to work with TypeScript. By composing these plug-ins together, you can create a powerful and flexible client that meets your specific needs.\n\n# Bundle size comparison\n\n| Package | Base API | Minified size | Minified and gzipped size |\n| --- | --- | --- | --- |\n| yumi-fetch | fetch | \u003ca href=\"https://bundlejs.com/?q=yumi-fetch\u0026treeshake=%5B%7Byumi%7D%5D\" alt=\"Minified size badge from bundlejs.com\"\u003e\u003cimg src=\"https://deno.bundlejs.com/?q=yumi-fetch\u0026treeshake=[{yumi}]\u0026badge=minified\" /\u003e\u003c/a\u003e | \u003ca href=\"https://bundlejs.com/?q=yumi-fetch\u0026treeshake=%5B%7Byumi%7D%5D\" alt=\"Minified and gripped size badge from bundlejs.com\"\u003e\u003cimg src=\"https://deno.bundlejs.com/?q=yumi-fetch\u0026treeshake=[{yumi}]\u0026badge=\" /\u003e\u003c/a\u003e |\n| \u003ca href=\"https://github.com/elbywan/wretch\"\u003ewretch\u003c/a\u003e | fetch | \u003ca href=\"https://bundlejs.com/?q=wretch\u0026treeshake=%5B%7Bdefault+as+wretch%7D%5D\" alt=\"Minified size badge from bundlejs.com\"\u003e\u003cimg src=\"https://deno.bundlejs.com/?q=wretch\u0026treeshake=[{default+as+wretch}]\u0026badge=minified\" /\u003e\u003c/a\u003e | \u003ca href=\"https://bundlejs.com/?q=wretch\u0026treeshake=%5B%7Bdefault+as+wretch%7D%5D\" alt=\"Minified and gripped size badge from bundlejs.com\"\u003e\u003cimg src=\"https://deno.bundlejs.com/?q=wretch\u0026treeshake=[{default+as+wretch}]\u0026badge=\" /\u003e\u003c/a\u003e |\n| \u003ca href=\"https://github.com/unjs/ofetch\"\u003eofetch\u003c/a\u003e | fetch | \u003ca href=\"https://deno.bundlejs.com?q=ofetch\u0026treeshake=[{ofetch}]\"\u003e\u003cimg src=\"https://deno.bundlejs.com?q=ofetch\u0026treeshake=[{ofetch}]\u0026badge=minified\" /\u003e\u003c/a\u003e | \u003ca href=\"https://deno.bundlejs.com?q=ofetch\u0026treeshake=[{ofetch}]\"\u003e\u003cimg src=\"https://deno.bundlejs.com?q=ofetch\u0026treeshake=[{ofetch}]\u0026badge\" /\u003e\u003c/a\u003e |\n| \u003ca href=\"https://github.com/sindresorhus/ky\"\u003eky\u003c/a\u003e | fetch | \u003ca href=\"https://bundlejs.com/?q=ky\u0026treeshake=%5B%7Bdefault+as+ky%7D%5D\" alt=\"Minified size badge from bundlejs.com\"\u003e\u003cimg src=\"https://deno.bundlejs.com/?q=ky\u0026treeshake=[{default+as+ky}]\u0026badge=minified\" /\u003e\u003c/a\u003e | \u003ca href=\"https://bundlejs.com/?q=ky\u0026treeshake=%5B%7Bdefault+as+ky%7D%5D\" alt=\"Minified and gripped size badge from bundlejs.com\"\u003e\u003cimg src=\"https://deno.bundlejs.com/?q=ky\u0026treeshake=[{default+as+ky}]\u0026badge=\" /\u003e\u003c/a\u003e |\n| \u003ca href=\"https://github.com/axios/axios\"\u003eaxios\u003c/a\u003e | XMLHttpRequest | \u003ca href=\"https://bundlejs.com/?q=axios\u0026treeshake=[{+default+as+axois+}\" alt=\"Minified size badge from bundlejs.com\"\u003e\u003cimg src=\"https://deno.bundlejs.com?q=axios\u0026treeshake=[{+default+as+axois+}]\u0026badge=minified\" /\u003e\u003c/a\u003e | \u003ca href=\"https://bundlejs.com/?q=axios\u0026treeshake=[{+default+as+axois+}\" alt=\"Minified and gripped size badge from bundlejs.com\"\u003e\u003cimg src=\"https://deno.bundlejs.com?q=axios\u0026treeshake=[{+default+as+axois+}]\u0026badge\" /\u003e\u003c/a\u003e |\n| \u003ca href=\"https://github.com/sindresorhus/got\"\u003egot\u003c/a\u003e | XMLHttpRequest | \u003ca href=\"https://bundlejs.com/?q=got\u0026treeshake=%5B%7Bdefault+as+got%7D%5D\" alt=\"Minified size badge from bundlejs.com\"\u003e\u003cimg src=\"https://deno.bundlejs.com/?q=got\u0026treeshake=[{default+as+got}]\u0026badge=minified\" /\u003e\u003c/a\u003e | \u003ca href=\"https://bundlejs.com/?q=got\u0026treeshake=%5B%7Bdefault+as+got%7D%5D\" alt=\"Minified and gripped size badge from bundlejs.com\"\u003e\u003cimg src=\"https://deno.bundlejs.com/?q=got\u0026treeshake=[{default+as+got}]\u0026badge=\" /\u003e\u003c/a\u003e |\n\n# Benchmark comparison\n\n```bash\ncpu: Apple M1\nruntime: deno 1.35.0 (aarch64-apple-darwin)\n\nbenchmark       time (avg)             (min … max)       p75       p99      p995\n-------------------------------------------------- -----------------------------\nfetch           72.39 µs/iter  (60.75 µs … 714.62 µs)  72.46 µs 204.96 µs 307.29 µs\nwretch           77.1 µs/iter    (67.92 µs … 1.02 ms)  76.92 µs 109.83 µs 286.46 µs\nyumi-fetch      87.31 µs/iter    (75.04 µs … 1.05 ms)  87.08 µs 131.83 µs 277.79 µs\nky             156.34 µs/iter   (121.21 µs … 2.28 ms)  151.5 µs 534.71 µs   1.22 ms\nya-fetch        89.77 µs/iter    (76.38 µs … 1.75 ms)  88.79 µs 144.62 µs 317.83 µs\nofetch          77.51 µs/iter  (68.33 µs … 977.96 µs)   76.5 µs 150.96 µs 197.71 µs\n\nsummary\n  fetch\n   1.07x faster than wretch\n   1.07x faster than ofetch\n   1.21x faster than yumi-fetch\n   1.24x faster than ya-fetch\n   2.16x faster than ky\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmellkam%2Fyumi-fetch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmellkam%2Fyumi-fetch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmellkam%2Fyumi-fetch/lists"}