aboutsummaryrefslogtreecommitdiffstats
path: root/_libly.js
diff options
context:
space:
mode:
authorsuVene2008-12-22 12:06:29 +0000
committersuVene2008-12-22 12:06:29 +0000
commit8577dc9d458c255f74831fedd35813091449a138 (patch)
treeb1e793f546f0621ecfa2346c3f8cc573c2b14140 /_libly.js
parent9b5d4c9b35c16648c303c0dc135abf371b731b1f (diff)
downloadvimperator-plugins-8577dc9d458c255f74831fedd35813091449a138.tar.bz2
add $U.runnable(generator)
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@27232 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to '_libly.js')
-rw-r--r--_libly.js20
1 files changed, 19 insertions, 1 deletions
diff --git a/_libly.js b/_libly.js
index f3c4dd3..abb846a 100644
--- a/_libly.js
+++ b/_libly.js
@@ -5,7 +5,7 @@ var PLUGIN_INFO =
<description>Vimperator plugins library?</description>
<description lang="ja">適当なライブラリっぽいものたち。</description>
<author mail="suvene@zeromemory.info" homepage="http://zeromemory.sblo.jp/">suVene</author>
- <version>0.1.13</version>
+ <version>0.1.14</version>
<minVersion>1.2</minVersion>
<maxVersion>2.0pre</maxVersion>
<updateURL>http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/_libly.js</updateURL>
@@ -47,6 +47,8 @@ evalJson(str, toRemove):
dateFormat(dtm, fmt):
Date型インスタンスを、指定されたフォーマットで文字列に変換します。
fmt を省略した場合、"%y/%M/%d %h:%m:%s" となります。
+runnable(generator):
+ gererator を実行し、再帰的に resume する為の引数を渡します。
== Browser ==
getSelectedString:
@@ -181,6 +183,22 @@ libly.$U = {//{{{
}
return (fmt || '%y/%M/%d %h:%m:%s').replace(/%([yMdhms%])/g, function (_, n) d[n]);
},
+ /**
+ * example)
+ * $U.runnable(function(resume) {
+ * // execute asynchronous function.
+ * // goto next yield;
+ * var val = yield setTimeout(function() { resume('value!'), 1000) });
+ * alert(val); // value!
+ * yield;
+ * });
+ */
+ runnable: function(generator) {
+ var it = generator(function(value) {
+ try { it.send(value); } catch (e) {}
+ });
+ it.next();
+ },
// }}}
// Browser {{{
getSelectedString: function() {