{"id":13602345,"url":"https://github.com/justjavac/proxy-www","last_synced_at":"2025-04-04T18:09:43.010Z","repository":{"id":44886448,"uuid":"341237965","full_name":"justjavac/proxy-www","owner":"justjavac","description":"学会 Proxy 就可以为所欲为吗？对，学会 Proxy 就可以为所欲为！","archived":false,"fork":false,"pushed_at":"2021-05-01T09:27:56.000Z","size":6,"stargazers_count":878,"open_issues_count":11,"forks_count":28,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-03-28T17:11:12.363Z","etag":null,"topics":["es6","javascript","proxy","typescript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/justjavac.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}},"created_at":"2021-02-22T15:01:58.000Z","updated_at":"2025-02-26T21:50:34.000Z","dependencies_parsed_at":"2022-07-21T15:18:40.795Z","dependency_job_id":null,"html_url":"https://github.com/justjavac/proxy-www","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justjavac%2Fproxy-www","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justjavac%2Fproxy-www/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justjavac%2Fproxy-www/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justjavac%2Fproxy-www/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/justjavac","download_url":"https://codeload.github.com/justjavac/proxy-www/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247226215,"owners_count":20904465,"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":["es6","javascript","proxy","typescript"],"created_at":"2024-08-01T18:01:20.611Z","updated_at":"2025-04-04T18:09:42.988Z","avatar_url":"https://github.com/justjavac.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# proxy-www\n\n\u003e 学会 Proxy 就可以为所欲为吗？\n\u003e \n\u003e 对，学会 Proxy 就可以为所欲为！\n\n原始来源：https://twitter.com/RReverser/status/1138788910975397888 #14\n\n```js\nconst www = new Proxy(new URL('https://www'), {\n    get: function get(target, prop) {\n        let o = Reflect.get(target, prop);\n        if (typeof o === 'function') {\n            return o.bind(target)\n        }\n        if (typeof prop !== 'string') {\n            return o;\n        }\n        if (prop === 'then') {\n            return Promise.prototype.then.bind(fetch(target));\n        }\n        target = new URL(target);\n        target.hostname += `.${prop}`;\n        return new Proxy(target, { get });\n    }\n});\n```\n\n访问百度\n\n```js\nwww.baidu.com.then(response =\u003e {\n    console.log(response.status);\n    // ==\u003e 200\n})\n```\n\n使用 `async`/`await` 语法：\n\n```js\nconst response = await www.baidu.com\n\nconsole.log(response.ok)\n// ==\u003e true\n\nconsole.log(response.status);\n// ==\u003e 200\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustjavac%2Fproxy-www","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustjavac%2Fproxy-www","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustjavac%2Fproxy-www/lists"}