v8 で noSuchMethod をエミュレートする際に問題が発生しています。コマンド ラインでハーモニー プロキシを正しくアクティブにしています (Proxy() オブジェクトを使用してもエラーは発生せず、いくつかのプロキシ機能を使用できます)。
var NoSuchMethodTrap = Proxy.create({
// FIXME: don't know why I need to provide this method,
// JS complains if getPropertyDescriptor is left out, or returns undefined
// Apparently, this method is called twice: once for '_noSuchMethod_' and once for 'foo'
getPropertyDescriptor: function(n){ return {} },
get: function(rcvr, name) {
if (name === '__noSuchMethod__') {
throw new Error("receiver does not implement __noSuchMethod__ hook");
} else {
return function() {
var args = Array.prototype.slice.call(arguments);
return this.__noSuchMethod__(name, args);
}
}
}
});
function MyObject() {};
MyObject.prototype = Object.create(NoSuchMethodTrap);
MyObject.prototype.__noSuchMethod__ = function(methName, args) {
return 'Hello, '+methName;
};
私が試しているもののコードスニプリを含めましたが、コードをどこで取得しても同じケースであるため、少し価値がありません。私はこれを1週間ググっています。ここで質問があります: これは単に v8 で実装されていないのでしょうか? もしそうなら、私は何が欠けていますか?