From 3863130590670c7cd91bdde3d8517fc52d8fd128 Mon Sep 17 00:00:00 2001 From: drry Date: Tue, 7 Oct 2008 17:39:11 +0000 Subject: * Array に対する `for each` 文を回避しました。 * ほか。 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@20939 d0d07461-0603-4401-acd4-de1884942a52 --- plugin_loader.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'plugin_loader.js') 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'); -- cgit v1.2.3