{"id":22283737,"url":"https://github.com/veaba/typescript-axios","last_synced_at":"2025-07-20T01:32:27.864Z","repository":{"id":104582224,"uuid":"202850175","full_name":"veaba/typescript-axios","owner":"veaba","description":"使用typescript 重写axios，翻写完毕，正在做mocha测试。。。","archived":false,"fork":false,"pushed_at":"2019-08-30T07:14:53.000Z","size":634,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T19:53:20.137Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/veaba.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":"2019-08-17T07:29:57.000Z","updated_at":"2019-09-05T09:57:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"92fd24c6-e715-45dd-81db-7e2c8302e4bb","html_url":"https://github.com/veaba/typescript-axios","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/veaba/typescript-axios","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veaba%2Ftypescript-axios","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veaba%2Ftypescript-axios/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veaba%2Ftypescript-axios/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veaba%2Ftypescript-axios/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/veaba","download_url":"https://codeload.github.com/veaba/typescript-axios/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veaba%2Ftypescript-axios/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266053826,"owners_count":23869496,"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":[],"created_at":"2024-12-03T16:41:56.962Z","updated_at":"2025-07-20T01:32:27.839Z","avatar_url":"https://github.com/veaba.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# typescript-axios\n使用typescript 重写axios\n\n\n## LICENSE\n\n本仓库在 Axios [MIT license](https://github.com/axios/axios/blob/master/LICENSE) 下修改、使用、学习\n\n## 了解下TS 的泛型\n\nhttps://zhongsp.gitbooks.io/typescript-handbook/content/doc/handbook/Enums.html\n\n## axios官方 的接口声明\n\u003e https://github.com/axios/axios/blob/master/index.d.ts\n\n\n## 特别说明\n\n有些文件可能在新建时候带有idea 创建者信息，并非说明对该代码有那个啥。\n\n## 疑惑\n\n### axios源码中，大量使用具名函数\n\n具名函数：\n\n```js\nconsole.time('具名函数');\nvar a=[66,99,44].map(function hello(item) {\n  return item*2\n});\nconsole.info(a);\nconsole.timeEnd('具名函数')\n\n```\n不清楚和以下有什么区别：\n```js\nconsole.time('匿名函数');\nvar b =[66,99,44].map(function(item) {\n  return item*2\n});\nconsole.info(b);\nconsole.timeEnd('匿名函数')\n\n```\n而如果使用箭头函数，则为：\n\n```js\nconsole.time('箭头函数');\nvar c=[66,99,44].map(item=\u003eitem*2);\nconsole.info(c);\nconsole.timeEnd('箭头函数');\n```\n\n- 具名函数：0.785888671875ms\n- 匿名函数: 0.740966796875ms\n- 箭头函数: 0.459228515625ms\n\n### 暴露 all/spread 干嘛的？\n\n暴露 all/spread 干嘛的？ [src/index.ts:31](src/index.ts )\n\n\n## dev\n\nnpm install\n\nnpm run dev\n\n使用vscode tsc --watch 项目路径\n\n\n## todo \n\n- 取消token ,test如果用户配置了这里，似乎在使用setTimeInterval 出现内存过载的问题，以前在开发时候遇到\n- let cookies = require('../headers/cookies') // todo 如何让它改成为import？这个module是一个立即执行函数\n- todo 后续ts输出成为ts，然后用于deno开发试试2019年8月22日10:47:23\n- 为什么webpack 打包.ts 文件为什么空白\n\n## 为什么process 这样的结构\n\n而且\nObject.prototype.toString.call(process) \n也不是[object process] \n而是 [object process]\n```text\nconst process=\n{ nextTick: [Function],\n  title: 'browser',\n  browser: true,\n  env: {},\n  argv: [],\n  version: '',\n  versions: {},\n  on: [Function: noop],\n  addListener: [Function: noop],\n  once: [Function: noop],\n  off: [Function: noop],\n  removeListener: [Function: noop],\n  removeAllListeners: [Function: noop],\n  emit: [Function: noop],\n  prependListener: [Function: noop],\n  prependOnceListener: [Function: noop],\n  listeners: [Function],\n  binding: [Function],\n  cwd: [Function],\n  chdir: [Function],\n  umask: [Function] }\n\n```\n\n## demo\n```js\n\n\n/* ******************* demo *********************** */\n// const axiosIns: any = axios.create({});\n//\n// console.info(52545);\n// // req 拦截器\n// axiosIns.interceptors.request.use((req: any) =\u003e {\n// \tif (!req.url) {\n// \t\tconsole.info('请检查，url为空：' + req.url);\n// \t}\n// \treturn req;\n// }, (err: any) =\u003e {\n// \treturn Promise.reject(err.request);\n// });\n// // res 拦截器\n// axiosIns.interceptors.response.use((res: any) =\u003e {\n// \tif (res \u0026\u0026 res.data) {\n// \t\treturn Promise.resolve(res.data);\n// \t}\n// \treturn res.data;\n// }, (err: any) =\u003e {\n// \treturn Promise.resolve(err.response);\n// });\n//\n//\n// axiosIns.get('http://baidu.com')\n// \t.then((res: any) =\u003e {\n// \t\tconsole.log('res:', res)\n// \t})\n// \t.catch((err: any) =\u003e {\n// \t\tconsole.log('err:', err)\n// \t});\n\n```\n\n## Test [TODO] mocha\n\nhttps://mochajs.org/  mocha 官方\n\n- mocha \n\n## Test [TODO] karma\nhttp://karma-runner.github.io/latest/index.html\n\n## Coverage [TODO] \nhttps://coveralls.io/ 测试覆盖率\n\n## 测试指标 [TODO]\n\n- 测试setInterval下  cancelToken\n- 测试多种data 的结果，以纠正用户输入的正常参数\n- get 测试\n- post 测试\n- head 测试\n- options 测试\n- put 测试\n- patch 测试\n- copy\n- link\n- unlink\n- purge\n- lock\n- unlock\n- propfind\n- view\n- common 测试\n- form-data 测试\n- file 测试\n-  cancel 测试\n- x-www-form-urlencoded\n- raw\n- binary\n- graphQL\n\n\n## 优化指标 [TODO]\n\n- （异步函数去写axios）会不会更快呢？\n\n## deno化 [TODO]\n\n## 去看看graphQL 和普通的xhr 有什么区别\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fveaba%2Ftypescript-axios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fveaba%2Ftypescript-axios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fveaba%2Ftypescript-axios/lists"}