aboutsummaryrefslogtreecommitdiffstats
path: root/plugin_loader.js
diff options
context:
space:
mode:
authordrry2008-10-07 17:39:11 +0000
committerdrry2008-10-07 17:39:11 +0000
commit3863130590670c7cd91bdde3d8517fc52d8fd128 (patch)
tree8d604d7c62844e41c574d3eddec9e96a4bbee62b /plugin_loader.js
parentce9337575b6e849c5bbcb5cc368d5d86f9812427 (diff)
downloadvimperator-plugins-3863130590670c7cd91bdde3d8517fc52d8fd128.tar.bz2
* Array に対する `for each` 文を回避しました。
* ほか。 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@20939 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'plugin_loader.js')
-rw-r--r--plugin_loader.js20
1 files changed, 11 insertions, 9 deletions
diff --git a/plugin_loader.js b/plugin_loader.js
index 253db22..cc5190a 100644
--- a/plugin_loader.js
+++ b/plugin_loader.js
@@ -20,22 +20,24 @@
function toArray (obj) {
return obj instanceof Array ? obj
- : obj.toString().split(/[,|\s]/);
+ : obj.toString().split(/[,| \t\r\n]+/);
}
let roots = toArray(globalVariables.plugin_loader_roots);
let plugins = toArray(globalVariables.plugin_loader_plugins);
-let filter = new RegExp('[\\\\/](' + plugins.join('|') + ')\\.(js|vimp)$');
+let filter = new RegExp('[\\\\/](?:' +
+ plugins.map(function (plugin) plugin.replace(/(?=[\\^$.+*?|(){}\[\]])/g, '\\'))
+ .join('|') +
+ ')\\.(?:js|vimp)$');
log('plugin_loader: loading');
-for each (let root in roots) {
+roots.forEach(function (root) {
let files = io.readDirectory(io.getFile(root), true);
- for each (let file in files) {
- if (!filter.test(file.path))
- continue;
- liberator.io.source(file.path, false);
- }
-}
+ files.forEach(function (file) {
+ if (filter.test(file.path))
+ liberator.io.source(file.path, false);
+ });
+});
log('plugin_loader: loaded');