[Pkg-javascript-commits] [node-browser-pack] 20/141: load prelude from file use require and toString
Bastien Roucariès
rouca at moszumanska.debian.org
Thu May 4 10:23:21 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-browser-pack.
commit 029c98f206c8c5af1f8cf5c6522dada3dfc9c698
Author: Roman Shtylman <shtylman at gmail.com>
Date: Fri Feb 22 22:54:18 2013 -0500
load prelude from file use require and toString
Easier to maintain and understand the prelude
---
index.js | 17 +----------------
prelude.js | 14 ++++++++++++++
2 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/index.js b/index.js
index 18b9527..c88e9f9 100644
--- a/index.js
+++ b/index.js
@@ -2,22 +2,7 @@ var JSONStream = require('JSONStream');
var duplexer = require('duplexer');
var through = require('through');
-var prelude = [
- '(function(p,c,e){',
- 'function r(n){',
- 'if(!c[n]){',
- 'if(!p[n])return;',
- 'c[n]={exports:{}};',
- 'p[n][0](function(x){',
- 'return r(p[n][1][x])',
- '},c[n],c[n].exports);',
- '}',
- 'return c[n].exports',
- '}',
- 'for(var i=0;i<e.length;i++)r(e[i]);',
- 'return r',
- '})({'
-].join('');
+var prelude = '(' + require('./prelude').toString() + ')({';
module.exports = function (opts) {
if (!opts) opts = {};
diff --git a/prelude.js b/prelude.js
new file mode 100644
index 0000000..f5d3e41
--- /dev/null
+++ b/prelude.js
@@ -0,0 +1,14 @@
+module.exports = function(p,c,e){
+ function r(n){
+ if(!c[n]){
+ if(!p[n])return;
+ c[n]={exports:{}};
+ p[n][0](function(x){
+ return r(p[n][1][x])
+ },c[n],c[n].exports);
+ }
+ return c[n].exports
+ }
+ for(var i=0;i<e.length;i++)r(e[i]);
+ return r
+};
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-browser-pack.git
More information about the Pkg-javascript-commits
mailing list