プロジェクト
概要
Proxyを学べば何でも好きなようにできるのか?そのとおり、Proxyを学べば何でも好きなようにできる!
システム・インフラ計測したスター増加
- 24時間
- 0
- 7日間
- 0
- 15日間
- 0
- 1か月
- 履歴を収集中
期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。
README.md
オリジナルproxy-www
学会 Proxy 就可以为所欲为吗?
对,学会 Proxy 就可以为所欲为!
原始来源:https://twitter.com/RReverser/status/1138788910975397888 #14
const www = new Proxy(new URL('https://www'), {
get: function get(target, prop) {
let o = Reflect.get(target, prop);
if (typeof o === 'function') {
return o.bind(target)
}
if (typeof prop !== 'string') {
return o;
}
if (prop === 'then') {
return Promise.prototype.then.bind(fetch(target));
}
target = new URL(target);
target.hostname += `.${prop}`;
return new Proxy(target, { get });
}
});
访问百度
www.baidu.com.then(response => {
console.log(response.status);
// ==> 200
})
使用 async/await 语法:
const response = await www.baidu.com
console.log(response.ok)
// ==> true
console.log(response.status);
// ==> 200
関連プロジェクトを探す
読み込み中…