From 0ed5e680ddb01441bce15b6b2d0e19c60521f15a Mon Sep 17 00:00:00 2001 From: anekos Date: Tue, 22 Dec 2009 14:03:25 +0000 Subject: around の返値を強化 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@36238 d0d07461-0603-4401-acd4-de1884942a52 --- _libly.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to '_libly.js') diff --git a/_libly.js b/_libly.js index f3334a3..c7f6e7c 100755 --- a/_libly.js +++ b/_libly.js @@ -12,7 +12,7 @@ var PLUGIN_INFO = 適当なライブラリっぽいものたち。 suVene MIT - 0.1.28 + 0.1.29 2.3pre 2.3pre http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/_libly.js @@ -43,6 +43,14 @@ around(obj, name, func): args はオリジナルの引数列です。 通常、next には引数を渡す必要はありません。 (任意の引数を渡したい場合は配列で渡します。) + 返値は以下のオブジェクトです + >|| + { + original: オリジナルの関数 + current: 現在の関数 + restore: 元に戻すための関数 + } + ||< bind(obj, func): func に obj を bind します。 func内からは this で obj が参照できるようになります。 @@ -230,7 +238,11 @@ libly.$U = {//{{{ let self = this, args = arguments; return func.call(self, function (_args) next.apply(self, _args || args), args); }; - return [next, current]; + return libly.$U.extend({ + original: next, + current: current, + restore: function () (obj[name] = next) + }, [next, current]); }, bind: function(obj, func) { return function() { -- cgit v1.2.3