윤준현

Test promise

dd
Showing 219 changed files with 37 additions and 4673 deletions
...@@ -6,6 +6,7 @@ var bodyParser = require('body-parser'); ...@@ -6,6 +6,7 @@ var bodyParser = require('body-parser');
6 var singer = require('./content') 6 var singer = require('./content')
7 var app = express(); // express 객체 저장 7 var app = express(); // express 객체 저장
8 8
9 +
9 //body-parser 미들웨어 사용 10 //body-parser 미들웨어 사용
10 app.use(bodyParser.urlencoded({extended: false})); 11 app.use(bodyParser.urlencoded({extended: false}));
11 app.use(bodyParser.json()); 12 app.use(bodyParser.json());
...@@ -32,7 +33,7 @@ app.post('/message', function(req,res){ ...@@ -32,7 +33,7 @@ app.post('/message', function(req,res){
32 console.log('전달받은 메시지 : ' + msg); 33 console.log('전달받은 메시지 : ' + msg);
33 34
34 var send = {}; 35 var send = {};
35 - function hell_callback(msg, callback){ 36 + function delay(){
36 switch(msg){ 37 switch(msg){
37 case '일본' : 38 case '일본' :
38 send = { 39 send = {
...@@ -58,23 +59,17 @@ app.post('/message', function(req,res){ ...@@ -58,23 +59,17 @@ app.post('/message', function(req,res){
58 }; 59 };
59 break; 60 break;
60 default: 61 default:
61 - send = singer.jpSinger(msg) 62 + singer.jpSinger(msg).then(function(result){
62 - var album_info = []; 63 + send = result;
63 - var album; 64 + })
64 - console.log(discography[0].json_album[1]);
65 - for (var i = 0; i < discography[0].json_album.lenth; i++) {
66 - album = discography[0].json_album[i] + ' 발매일 : ' + discography[0].json_year[i];
67 - console.log(album);
68 - }
69 - });
70 if(send == '') 65 if(send == '')
71 send = singer.krSinger(msg); 66 send = singer.krSinger(msg);
72 break; 67 break;
73 } 68 }
74 - callback(send);
75 } 69 }
70 + delay().then(function(){
76 console.log(send); 71 console.log(send);
77 - hell_callback(msg,function(hell_send){ 72 +
78 - res.json(hell_send); 73 + res.json(send);
79 }) 74 })
80 }) 75 })
...\ No newline at end of file ...\ No newline at end of file
......
This diff is collapsed. Click to expand it.
1 //Reol 나무위키 앨범 발매년도 트랙 크롤링 1 //Reol 나무위키 앨범 발매년도 트랙 크롤링
2 var request = require('request'); 2 var request = require('request');
3 var cheerio = require('cheerio'); 3 var cheerio = require('cheerio');
4 -function crawl_Reol(url, callBack){ 4 +function crawl_Reol(url){
5 - request(url, function(err, res, body){ 5 + return new Promise(function(resolve, reject){
6 + request(url, function (err, res, body) {
6 const $ = cheerio.load(body); 7 const $ = cheerio.load(body);
7 8
8 var Reol = new Array(); 9 var Reol = new Array();
9 var album, year 10 var album, year
10 var album_track = new Array(); 11 var album_track = new Array();
11 var json_album = new Array(), json_year = new Array(), json_track = new Array(); 12 var json_album = new Array(), json_year = new Array(), json_track = new Array();
12 - 13 + $('body > div.content-wrapper > article > div.wiki-content.clearfix > div').each(function (index, ele) {
13 - $('body > div.content-wrapper > article > div.wiki-content.clearfix > div').each(function(index, ele){ 14 + for (var i = 1; i <= $('.toc-item').length; i++) {
14 - for(var i = 1; i <= $('.toc-item').length; i++){ 15 + album = $(this).find('#toc > div > div:nth-child(2) > span:nth-child(' + i + ')').text() //앨범 정보 가져오기
15 - album = $(this).find('#toc > div > div:nth-child(2) > span:nth-child('+i+')').text() //앨범 정보 가져오기 16 + if (album != '') {
16 - if(album != ''){
17 json_album.push(album.substr(2)); 17 json_album.push(album.substr(2));
18 } 18 }
19 19
20 - var index = 7 + (i*2); //트랙, 연도 가져오기 인덱스 변수 20 + var index = 7 + (i * 2); //트랙, 연도 가져오기 인덱스 변수
21 21
22 - if(index != 25){ //규칙성이 어긋나는 부분을 예외처리를 위해 if문 22 + if (index != 25) { //규칙성이 어긋나는 부분을 예외처리를 위해 if문
23 //year 가져오기 23 //year 가져오기
24 - year = $('body > div.content-wrapper > article > div.wiki-content.clearfix > div > div:nth-child('+index+') > div:nth-child(3) > table > tbody > tr:nth-child(1) > td:nth-child(2)').text(); 24 + year = $('body > div.content-wrapper > article > div.wiki-content.clearfix > div > div:nth-child(' + index + ') > div:nth-child(3) > table > tbody > tr:nth-child(1) > td:nth-child(2)').text();
25 //track 가져오기 25 //track 가져오기
26 - $('body > div.content-wrapper > article > div.wiki-content.clearfix > div > div:nth-child('+index+') > div:nth-child(3) > table > tbody').find('tr').each(function(index, ele){ 26 + $('body > div.content-wrapper > article > div.wiki-content.clearfix > div > div:nth-child(' + index + ') > div:nth-child(3) > table > tbody').find('tr').each(function (index, ele) {
27 var track = $(this).children().eq(1).text(); 27 var track = $(this).children().eq(1).text();
28 - if(track != '1' && track != '곡명' && track[4] != '년') 28 + if (track != '1' && track != '곡명' && track[4] != '년')
29 album_track.push(track) 29 album_track.push(track)
30 }); 30 });
31 } 31 }
32 - else{ 32 + else {
33 - year = $('body > div.content-wrapper > article > div.wiki-content.clearfix > div > div:nth-child('+index+') > div:nth-child(4) > table > tbody > tr:nth-child(1) > td:nth-child(2)').text(); 33 + year = $('body > div.content-wrapper > article > div.wiki-content.clearfix > div > div:nth-child(' + index + ') > div:nth-child(4) > table > tbody > tr:nth-child(1) > td:nth-child(2)').text();
34 - $('body > div.content-wrapper > article > div.wiki-content.clearfix > div > div:nth-child('+index+') > div:nth-child(4) > table > tbody').find('tr').each(function(index, ele){ 34 + $('body > div.content-wrapper > article > div.wiki-content.clearfix > div > div:nth-child(' + index + ') > div:nth-child(4) > table > tbody').find('tr').each(function (index, ele) {
35 var track = $(this).children().eq(1).text(); 35 var track = $(this).children().eq(1).text();
36 - if(track != '1' && track != '곡명' && track[4] != '년') 36 + if (track != '1' && track != '곡명' && track[4] != '년')
37 album_track.push(track) 37 album_track.push(track)
38 }); 38 });
39 } 39 }
40 - if(year != ''){ 40 + if (year != '') {
41 json_year.push(year); 41 json_year.push(year);
42 json_track.push(album_track); 42 json_track.push(album_track);
43 } 43 }
44 album_track = []; 44 album_track = [];
45 } 45 }
46 }); 46 });
47 - Reol.push({json_album,json_year,json_track}); 47 + Reol.push({ json_album, json_year, json_track });
48 - callBack(Reol); 48 + if (Reol) {
49 + resolve(Reol);
50 + }
51 + reject(new Error("Request is failed"));
52 + });
49 }); 53 });
50 } 54 }
51 55
......
1 -#!/bin/sh
2 -basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 -
4 -case `uname` in
5 - *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6 -esac
7 -
8 -if [ -x "$basedir/node" ]; then
9 - "$basedir/node" "$basedir/../require/bin/require-command.js" "$@"
10 - ret=$?
11 -else
12 - node "$basedir/../require/bin/require-command.js" "$@"
13 - ret=$?
14 -fi
15 -exit $ret
1 -@IF EXIST "%~dp0\node.exe" (
2 - "%~dp0\node.exe" "%~dp0\..\require\bin\require-command.js" %*
3 -) ELSE (
4 - @SETLOCAL
5 - @SET PATHEXT=%PATHEXT:;.JS;=;%
6 - node "%~dp0\..\require\bin\require-command.js" %*
7 -)
...\ No newline at end of file ...\ No newline at end of file
1 -#!/bin/sh
2 -basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 -
4 -case `uname` in
5 - *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6 -esac
7 -
8 -if [ -x "$basedir/node" ]; then
9 - "$basedir/node" "$basedir/../uglify-js/bin/uglifyjs" "$@"
10 - ret=$?
11 -else
12 - node "$basedir/../uglify-js/bin/uglifyjs" "$@"
13 - ret=$?
14 -fi
15 -exit $ret
1 -@IF EXIST "%~dp0\node.exe" (
2 - "%~dp0\node.exe" "%~dp0\..\uglify-js\bin\uglifyjs" %*
3 -) ELSE (
4 - @SETLOCAL
5 - @SET PATHEXT=%PATHEXT:;.JS;=;%
6 - node "%~dp0\..\uglify-js\bin\uglifyjs" %*
7 -)
...\ No newline at end of file ...\ No newline at end of file
1 -amdefine is released under two licenses: new BSD, and MIT. You may pick the
2 -license that best suits your development needs. The text of both licenses are
3 -provided below.
4 -
5 -
6 -The "New" BSD License:
7 -----------------------
8 -
9 -Copyright (c) 2011-2016, The Dojo Foundation
10 -All rights reserved.
11 -
12 -Redistribution and use in source and binary forms, with or without
13 -modification, are permitted provided that the following conditions are met:
14 -
15 - * Redistributions of source code must retain the above copyright notice, this
16 - list of conditions and the following disclaimer.
17 - * Redistributions in binary form must reproduce the above copyright notice,
18 - this list of conditions and the following disclaimer in the documentation
19 - and/or other materials provided with the distribution.
20 - * Neither the name of the Dojo Foundation nor the names of its contributors
21 - may be used to endorse or promote products derived from this software
22 - without specific prior written permission.
23 -
24 -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25 -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
28 -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 -
35 -
36 -
37 -MIT License
38 ------------
39 -
40 -Copyright (c) 2011-2016, The Dojo Foundation
41 -
42 -Permission is hereby granted, free of charge, to any person obtaining a copy
43 -of this software and associated documentation files (the "Software"), to deal
44 -in the Software without restriction, including without limitation the rights
45 -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
46 -copies of the Software, and to permit persons to whom the Software is
47 -furnished to do so, subject to the following conditions:
48 -
49 -The above copyright notice and this permission notice shall be included in
50 -all copies or substantial portions of the Software.
51 -
52 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
53 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
54 -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
55 -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
56 -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
57 -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
58 -THE SOFTWARE.
1 -# amdefine
2 -
3 -A module that can be used to implement AMD's define() in Node. This allows you
4 -to code to the AMD API and have the module work in node programs without
5 -requiring those other programs to use AMD.
6 -
7 -## Usage
8 -
9 -**1)** Update your package.json to indicate amdefine as a dependency:
10 -
11 -```javascript
12 - "dependencies": {
13 - "amdefine": ">=0.1.0"
14 - }
15 -```
16 -
17 -Then run `npm install` to get amdefine into your project.
18 -
19 -**2)** At the top of each module that uses define(), place this code:
20 -
21 -```javascript
22 -if (typeof define !== 'function') { var define = require('amdefine')(module) }
23 -```
24 -
25 -**Only use these snippets** when loading amdefine. If you preserve the basic structure,
26 -with the braces, it will be stripped out when using the [RequireJS optimizer](#optimizer).
27 -
28 -You can add spaces, line breaks and even require amdefine with a local path, but
29 -keep the rest of the structure to get the stripping behavior.
30 -
31 -As you may know, because `if` statements in JavaScript don't have their own scope, the var
32 -declaration in the above snippet is made whether the `if` expression is truthy or not. If
33 -RequireJS is loaded then the declaration is superfluous because `define` is already already
34 -declared in the same scope in RequireJS. Fortunately JavaScript handles multiple `var`
35 -declarations of the same variable in the same scope gracefully.
36 -
37 -If you want to deliver amdefine.js with your code rather than specifying it as a dependency
38 -with npm, then just download the latest release and refer to it using a relative path:
39 -
40 -[Latest Version](https://github.com/jrburke/amdefine/raw/latest/amdefine.js)
41 -
42 -### amdefine/intercept
43 -
44 -Consider this very experimental.
45 -
46 -Instead of pasting the piece of text for the amdefine setup of a `define`
47 -variable in each module you create or consume, you can use `amdefine/intercept`
48 -instead. It will automatically insert the above snippet in each .js file loaded
49 -by Node.
50 -
51 -**Warning**: you should only use this if you are creating an application that
52 -is consuming AMD style defined()'d modules that are distributed via npm and want
53 -to run that code in Node.
54 -
55 -For library code where you are not sure if it will be used by others in Node or
56 -in the browser, then explicitly depending on amdefine and placing the code
57 -snippet above is suggested path, instead of using `amdefine/intercept`. The
58 -intercept module affects all .js files loaded in the Node app, and it is
59 -inconsiderate to modify global state like that unless you are also controlling
60 -the top level app.
61 -
62 -#### Why distribute AMD-style modules via npm?
63 -
64 -npm has a lot of weaknesses for front-end use (installed layout is not great,
65 -should have better support for the `baseUrl + moduleID + '.js' style of loading,
66 -single file JS installs), but some people want a JS package manager and are
67 -willing to live with those constraints. If that is you, but still want to author
68 -in AMD style modules to get dynamic require([]), better direct source usage and
69 -powerful loader plugin support in the browser, then this tool can help.
70 -
71 -#### amdefine/intercept usage
72 -
73 -Just require it in your top level app module (for example index.js, server.js):
74 -
75 -```javascript
76 -require('amdefine/intercept');
77 -```
78 -
79 -The module does not return a value, so no need to assign the result to a local
80 -variable.
81 -
82 -Then just require() code as you normally would with Node's require(). Any .js
83 -loaded after the intercept require will have the amdefine check injected in
84 -the .js source as it is loaded. It does not modify the source on disk, just
85 -prepends some content to the text of the module as it is loaded by Node.
86 -
87 -#### How amdefine/intercept works
88 -
89 -It overrides the `Module._extensions['.js']` in Node to automatically prepend
90 -the amdefine snippet above. So, it will affect any .js file loaded by your
91 -app.
92 -
93 -## define() usage
94 -
95 -It is best if you use the anonymous forms of define() in your module:
96 -
97 -```javascript
98 -define(function (require) {
99 - var dependency = require('dependency');
100 -});
101 -```
102 -
103 -or
104 -
105 -```javascript
106 -define(['dependency'], function (dependency) {
107 -
108 -});
109 -```
110 -
111 -## RequireJS optimizer integration. <a name="optimizer"></name>
112 -
113 -Version 1.0.3 of the [RequireJS optimizer](http://requirejs.org/docs/optimization.html)
114 -will have support for stripping the `if (typeof define !== 'function')` check
115 -mentioned above, so you can include this snippet for code that runs in the
116 -browser, but avoid taking the cost of the if() statement once the code is
117 -optimized for deployment.
118 -
119 -## Node 0.4 Support
120 -
121 -If you want to support Node 0.4, then add `require` as the second parameter to amdefine:
122 -
123 -```javascript
124 -//Only if you want Node 0.4. If using 0.5 or later, use the above snippet.
125 -if (typeof define !== 'function') { var define = require('amdefine')(module, require) }
126 -```
127 -
128 -## Limitations
129 -
130 -### Synchronous vs Asynchronous
131 -
132 -amdefine creates a define() function that is callable by your code. It will
133 -execute and trace dependencies and call the factory function *synchronously*,
134 -to keep the behavior in line with Node's synchronous dependency tracing.
135 -
136 -The exception: calling AMD's callback-style require() from inside a factory
137 -function. The require callback is called on process.nextTick():
138 -
139 -```javascript
140 -define(function (require) {
141 - require(['a'], function(a) {
142 - //'a' is loaded synchronously, but
143 - //this callback is called on process.nextTick().
144 - });
145 -});
146 -```
147 -
148 -### Loader Plugins
149 -
150 -Loader plugins are supported as long as they call their load() callbacks
151 -synchronously. So ones that do network requests will not work. However plugins
152 -like [text](http://requirejs.org/docs/api.html#text) can load text files locally.
153 -
154 -The plugin API's `load.fromText()` is **not supported** in amdefine, so this means
155 -transpiler plugins like the [CoffeeScript loader plugin](https://github.com/jrburke/require-cs)
156 -will not work. This may be fixable, but it is a bit complex, and I do not have
157 -enough node-fu to figure it out yet. See the source for amdefine.js if you want
158 -to get an idea of the issues involved.
159 -
160 -## Tests
161 -
162 -To run the tests, cd to **tests** and run:
163 -
164 -```
165 -node all.js
166 -node all-intercept.js
167 -```
168 -
169 -## License
170 -
171 -New BSD and MIT. Check the LICENSE file for all the details.
1 -/** vim: et:ts=4:sw=4:sts=4
2 - * @license amdefine 1.0.1 Copyright (c) 2011-2016, The Dojo Foundation All Rights Reserved.
3 - * Available via the MIT or new BSD license.
4 - * see: http://github.com/jrburke/amdefine for details
5 - */
6 -
7 -/*jslint node: true */
8 -/*global module, process */
9 -'use strict';
10 -
11 -/**
12 - * Creates a define for node.
13 - * @param {Object} module the "module" object that is defined by Node for the
14 - * current module.
15 - * @param {Function} [requireFn]. Node's require function for the current module.
16 - * It only needs to be passed in Node versions before 0.5, when module.require
17 - * did not exist.
18 - * @returns {Function} a define function that is usable for the current node
19 - * module.
20 - */
21 -function amdefine(module, requireFn) {
22 - 'use strict';
23 - var defineCache = {},
24 - loaderCache = {},
25 - alreadyCalled = false,
26 - path = require('path'),
27 - makeRequire, stringRequire;
28 -
29 - /**
30 - * Trims the . and .. from an array of path segments.
31 - * It will keep a leading path segment if a .. will become
32 - * the first path segment, to help with module name lookups,
33 - * which act like paths, but can be remapped. But the end result,
34 - * all paths that use this function should look normalized.
35 - * NOTE: this method MODIFIES the input array.
36 - * @param {Array} ary the array of path segments.
37 - */
38 - function trimDots(ary) {
39 - var i, part;
40 - for (i = 0; ary[i]; i+= 1) {
41 - part = ary[i];
42 - if (part === '.') {
43 - ary.splice(i, 1);
44 - i -= 1;
45 - } else if (part === '..') {
46 - if (i === 1 && (ary[2] === '..' || ary[0] === '..')) {
47 - //End of the line. Keep at least one non-dot
48 - //path segment at the front so it can be mapped
49 - //correctly to disk. Otherwise, there is likely
50 - //no path mapping for a path starting with '..'.
51 - //This can still fail, but catches the most reasonable
52 - //uses of ..
53 - break;
54 - } else if (i > 0) {
55 - ary.splice(i - 1, 2);
56 - i -= 2;
57 - }
58 - }
59 - }
60 - }
61 -
62 - function normalize(name, baseName) {
63 - var baseParts;
64 -
65 - //Adjust any relative paths.
66 - if (name && name.charAt(0) === '.') {
67 - //If have a base name, try to normalize against it,
68 - //otherwise, assume it is a top-level require that will
69 - //be relative to baseUrl in the end.
70 - if (baseName) {
71 - baseParts = baseName.split('/');
72 - baseParts = baseParts.slice(0, baseParts.length - 1);
73 - baseParts = baseParts.concat(name.split('/'));
74 - trimDots(baseParts);
75 - name = baseParts.join('/');
76 - }
77 - }
78 -
79 - return name;
80 - }
81 -
82 - /**
83 - * Create the normalize() function passed to a loader plugin's
84 - * normalize method.
85 - */
86 - function makeNormalize(relName) {
87 - return function (name) {
88 - return normalize(name, relName);
89 - };
90 - }
91 -
92 - function makeLoad(id) {
93 - function load(value) {
94 - loaderCache[id] = value;
95 - }
96 -
97 - load.fromText = function (id, text) {
98 - //This one is difficult because the text can/probably uses
99 - //define, and any relative paths and requires should be relative
100 - //to that id was it would be found on disk. But this would require
101 - //bootstrapping a module/require fairly deeply from node core.
102 - //Not sure how best to go about that yet.
103 - throw new Error('amdefine does not implement load.fromText');
104 - };
105 -
106 - return load;
107 - }
108 -
109 - makeRequire = function (systemRequire, exports, module, relId) {
110 - function amdRequire(deps, callback) {
111 - if (typeof deps === 'string') {
112 - //Synchronous, single module require('')
113 - return stringRequire(systemRequire, exports, module, deps, relId);
114 - } else {
115 - //Array of dependencies with a callback.
116 -
117 - //Convert the dependencies to modules.
118 - deps = deps.map(function (depName) {
119 - return stringRequire(systemRequire, exports, module, depName, relId);
120 - });
121 -
122 - //Wait for next tick to call back the require call.
123 - if (callback) {
124 - process.nextTick(function () {
125 - callback.apply(null, deps);
126 - });
127 - }
128 - }
129 - }
130 -
131 - amdRequire.toUrl = function (filePath) {
132 - if (filePath.indexOf('.') === 0) {
133 - return normalize(filePath, path.dirname(module.filename));
134 - } else {
135 - return filePath;
136 - }
137 - };
138 -
139 - return amdRequire;
140 - };
141 -
142 - //Favor explicit value, passed in if the module wants to support Node 0.4.
143 - requireFn = requireFn || function req() {
144 - return module.require.apply(module, arguments);
145 - };
146 -
147 - function runFactory(id, deps, factory) {
148 - var r, e, m, result;
149 -
150 - if (id) {
151 - e = loaderCache[id] = {};
152 - m = {
153 - id: id,
154 - uri: __filename,
155 - exports: e
156 - };
157 - r = makeRequire(requireFn, e, m, id);
158 - } else {
159 - //Only support one define call per file
160 - if (alreadyCalled) {
161 - throw new Error('amdefine with no module ID cannot be called more than once per file.');
162 - }
163 - alreadyCalled = true;
164 -
165 - //Use the real variables from node
166 - //Use module.exports for exports, since
167 - //the exports in here is amdefine exports.
168 - e = module.exports;
169 - m = module;
170 - r = makeRequire(requireFn, e, m, module.id);
171 - }
172 -
173 - //If there are dependencies, they are strings, so need
174 - //to convert them to dependency values.
175 - if (deps) {
176 - deps = deps.map(function (depName) {
177 - return r(depName);
178 - });
179 - }
180 -
181 - //Call the factory with the right dependencies.
182 - if (typeof factory === 'function') {
183 - result = factory.apply(m.exports, deps);
184 - } else {
185 - result = factory;
186 - }
187 -
188 - if (result !== undefined) {
189 - m.exports = result;
190 - if (id) {
191 - loaderCache[id] = m.exports;
192 - }
193 - }
194 - }
195 -
196 - stringRequire = function (systemRequire, exports, module, id, relId) {
197 - //Split the ID by a ! so that
198 - var index = id.indexOf('!'),
199 - originalId = id,
200 - prefix, plugin;
201 -
202 - if (index === -1) {
203 - id = normalize(id, relId);
204 -
205 - //Straight module lookup. If it is one of the special dependencies,
206 - //deal with it, otherwise, delegate to node.
207 - if (id === 'require') {
208 - return makeRequire(systemRequire, exports, module, relId);
209 - } else if (id === 'exports') {
210 - return exports;
211 - } else if (id === 'module') {
212 - return module;
213 - } else if (loaderCache.hasOwnProperty(id)) {
214 - return loaderCache[id];
215 - } else if (defineCache[id]) {
216 - runFactory.apply(null, defineCache[id]);
217 - return loaderCache[id];
218 - } else {
219 - if(systemRequire) {
220 - return systemRequire(originalId);
221 - } else {
222 - throw new Error('No module with ID: ' + id);
223 - }
224 - }
225 - } else {
226 - //There is a plugin in play.
227 - prefix = id.substring(0, index);
228 - id = id.substring(index + 1, id.length);
229 -
230 - plugin = stringRequire(systemRequire, exports, module, prefix, relId);
231 -
232 - if (plugin.normalize) {
233 - id = plugin.normalize(id, makeNormalize(relId));
234 - } else {
235 - //Normalize the ID normally.
236 - id = normalize(id, relId);
237 - }
238 -
239 - if (loaderCache[id]) {
240 - return loaderCache[id];
241 - } else {
242 - plugin.load(id, makeRequire(systemRequire, exports, module, relId), makeLoad(id), {});
243 -
244 - return loaderCache[id];
245 - }
246 - }
247 - };
248 -
249 - //Create a define function specific to the module asking for amdefine.
250 - function define(id, deps, factory) {
251 - if (Array.isArray(id)) {
252 - factory = deps;
253 - deps = id;
254 - id = undefined;
255 - } else if (typeof id !== 'string') {
256 - factory = id;
257 - id = deps = undefined;
258 - }
259 -
260 - if (deps && !Array.isArray(deps)) {
261 - factory = deps;
262 - deps = undefined;
263 - }
264 -
265 - if (!deps) {
266 - deps = ['require', 'exports', 'module'];
267 - }
268 -
269 - //Set up properties for this module. If an ID, then use
270 - //internal cache. If no ID, then use the external variables
271 - //for this node module.
272 - if (id) {
273 - //Put the module in deep freeze until there is a
274 - //require call for it.
275 - defineCache[id] = [id, deps, factory];
276 - } else {
277 - runFactory(id, deps, factory);
278 - }
279 - }
280 -
281 - //define.require, which has access to all the values in the
282 - //cache. Useful for AMD modules that all have IDs in the file,
283 - //but need to finally export a value to node based on one of those
284 - //IDs.
285 - define.require = function (id) {
286 - if (loaderCache[id]) {
287 - return loaderCache[id];
288 - }
289 -
290 - if (defineCache[id]) {
291 - runFactory.apply(null, defineCache[id]);
292 - return loaderCache[id];
293 - }
294 - };
295 -
296 - define.amd = {};
297 -
298 - return define;
299 -}
300 -
301 -module.exports = amdefine;
1 -/*jshint node: true */
2 -var inserted,
3 - Module = require('module'),
4 - fs = require('fs'),
5 - existingExtFn = Module._extensions['.js'],
6 - amdefineRegExp = /amdefine\.js/;
7 -
8 -inserted = "if (typeof define !== 'function') {var define = require('amdefine')(module)}";
9 -
10 -//From the node/lib/module.js source:
11 -function stripBOM(content) {
12 - // Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
13 - // because the buffer-to-string conversion in `fs.readFileSync()`
14 - // translates it to FEFF, the UTF-16 BOM.
15 - if (content.charCodeAt(0) === 0xFEFF) {
16 - content = content.slice(1);
17 - }
18 - return content;
19 -}
20 -
21 -//Also adapted from the node/lib/module.js source:
22 -function intercept(module, filename) {
23 - var content = stripBOM(fs.readFileSync(filename, 'utf8'));
24 -
25 - if (!amdefineRegExp.test(module.id)) {
26 - content = inserted + content;
27 - }
28 -
29 - module._compile(content, filename);
30 -}
31 -
32 -intercept._id = 'amdefine/intercept';
33 -
34 -if (!existingExtFn._id || existingExtFn._id !== intercept._id) {
35 - Module._extensions['.js'] = intercept;
36 -}
1 -{
2 - "_from": "amdefine@>=0.0.4",
3 - "_id": "amdefine@1.0.1",
4 - "_inBundle": false,
5 - "_integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=",
6 - "_location": "/amdefine",
7 - "_phantomChildren": {},
8 - "_requested": {
9 - "type": "range",
10 - "registry": true,
11 - "raw": "amdefine@>=0.0.4",
12 - "name": "amdefine",
13 - "escapedName": "amdefine",
14 - "rawSpec": ">=0.0.4",
15 - "saveSpec": null,
16 - "fetchSpec": ">=0.0.4"
17 - },
18 - "_requiredBy": [
19 - "/source-map"
20 - ],
21 - "_resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz",
22 - "_shasum": "4a5282ac164729e93619bcfd3ad151f817ce91f5",
23 - "_spec": "amdefine@>=0.0.4",
24 - "_where": "D:\\OneDrive\\University Life\\2018\\2nd semester\\OpenSourceSoftware\\KaKao_ChatBot\\node_modules\\source-map",
25 - "author": {
26 - "name": "James Burke",
27 - "email": "jrburke@gmail.com",
28 - "url": "http://github.com/jrburke"
29 - },
30 - "bugs": {
31 - "url": "https://github.com/jrburke/amdefine/issues"
32 - },
33 - "bundleDependencies": false,
34 - "deprecated": false,
35 - "description": "Provide AMD's define() API for declaring modules in the AMD format",
36 - "engines": {
37 - "node": ">=0.4.2"
38 - },
39 - "homepage": "http://github.com/jrburke/amdefine",
40 - "license": "BSD-3-Clause OR MIT",
41 - "main": "./amdefine.js",
42 - "name": "amdefine",
43 - "repository": {
44 - "type": "git",
45 - "url": "git+https://github.com/jrburke/amdefine.git"
46 - },
47 - "version": "1.0.1"
48 -}
1 -Copyright (c) 2010 Caolan McMahon
2 -
3 -Permission is hereby granted, free of charge, to any person obtaining a copy
4 -of this software and associated documentation files (the "Software"), to deal
5 -in the Software without restriction, including without limitation the rights
6 -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 -copies of the Software, and to permit persons to whom the Software is
8 -furnished to do so, subject to the following conditions:
9 -
10 -The above copyright notice and this permission notice shall be included in
11 -all copies or substantial portions of the Software.
12 -
13 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 -THE SOFTWARE.
This diff is collapsed. Click to expand it.
1 -{
2 - "name": "async",
3 - "repo": "caolan/async",
4 - "description": "Higher-order functions and common patterns for asynchronous code",
5 - "version": "0.1.23",
6 - "keywords": [],
7 - "dependencies": {},
8 - "development": {},
9 - "main": "lib/async.js",
10 - "scripts": [ "lib/async.js" ]
11 -}
This diff is collapsed. Click to expand it.
1 -{
2 - "_from": "async@~0.2.6",
3 - "_id": "async@0.2.10",
4 - "_inBundle": false,
5 - "_integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E=",
6 - "_location": "/async",
7 - "_phantomChildren": {},
8 - "_requested": {
9 - "type": "range",
10 - "registry": true,
11 - "raw": "async@~0.2.6",
12 - "name": "async",
13 - "escapedName": "async",
14 - "rawSpec": "~0.2.6",
15 - "saveSpec": null,
16 - "fetchSpec": "~0.2.6"
17 - },
18 - "_requiredBy": [
19 - "/uglify-js"
20 - ],
21 - "_resolved": "http://registry.npmjs.org/async/-/async-0.2.10.tgz",
22 - "_shasum": "b6bbe0b0674b9d719708ca38de8c237cb526c3d1",
23 - "_spec": "async@~0.2.6",
24 - "_where": "D:\\OneDrive\\University Life\\2018\\2nd semester\\OpenSourceSoftware\\KaKao_ChatBot\\node_modules\\uglify-js",
25 - "author": {
26 - "name": "Caolan McMahon"
27 - },
28 - "bugs": {
29 - "url": "https://github.com/caolan/async/issues"
30 - },
31 - "bundleDependencies": false,
32 - "deprecated": false,
33 - "description": "Higher-order functions and common patterns for asynchronous code",
34 - "devDependencies": {
35 - "nodelint": ">0.0.0",
36 - "nodeunit": ">0.0.0",
37 - "uglify-js": "1.2.x"
38 - },
39 - "homepage": "https://github.com/caolan/async#readme",
40 - "jam": {
41 - "main": "lib/async.js",
42 - "include": [
43 - "lib/async.js",
44 - "README.md",
45 - "LICENSE"
46 - ]
47 - },
48 - "licenses": [
49 - {
50 - "type": "MIT",
51 - "url": "https://github.com/caolan/async/raw/master/LICENSE"
52 - }
53 - ],
54 - "main": "./lib/async",
55 - "name": "async",
56 - "repository": {
57 - "type": "git",
58 - "url": "git+https://github.com/caolan/async.git"
59 - },
60 - "scripts": {
61 - "test": "nodeunit test/test-async.js"
62 - },
63 - "version": "0.2.10"
64 -}
1 { 1 {
2 - "_from": "cheerio@^1.0.0-rc.2", 2 + "_from": "cheerio",
3 "_id": "cheerio@1.0.0-rc.2", 3 "_id": "cheerio@1.0.0-rc.2",
4 "_inBundle": false, 4 "_inBundle": false,
5 "_integrity": "sha1-S59TqBsn5NXawxwP/Qz6A8xoMNs=", 5 "_integrity": "sha1-S59TqBsn5NXawxwP/Qz6A8xoMNs=",
6 "_location": "/cheerio", 6 "_location": "/cheerio",
7 "_phantomChildren": {}, 7 "_phantomChildren": {},
8 "_requested": { 8 "_requested": {
9 - "type": "range", 9 + "type": "tag",
10 "registry": true, 10 "registry": true,
11 - "raw": "cheerio@^1.0.0-rc.2", 11 + "raw": "cheerio",
12 "name": "cheerio", 12 "name": "cheerio",
13 "escapedName": "cheerio", 13 "escapedName": "cheerio",
14 - "rawSpec": "^1.0.0-rc.2", 14 + "rawSpec": "",
15 "saveSpec": null, 15 "saveSpec": null,
16 - "fetchSpec": "^1.0.0-rc.2" 16 + "fetchSpec": "latest"
17 }, 17 },
18 "_requiredBy": [ 18 "_requiredBy": [
19 "#USER", 19 "#USER",
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
21 ], 21 ],
22 "_resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.2.tgz", 22 "_resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.2.tgz",
23 "_shasum": "4b9f53a81b27e4d5dac31c0ffd0cfa03cc6830db", 23 "_shasum": "4b9f53a81b27e4d5dac31c0ffd0cfa03cc6830db",
24 - "_spec": "cheerio@^1.0.0-rc.2", 24 + "_spec": "cheerio",
25 "_where": "D:\\OneDrive\\University Life\\2018\\2nd semester\\OpenSourceSoftware\\KaKao_ChatBot", 25 "_where": "D:\\OneDrive\\University Life\\2018\\2nd semester\\OpenSourceSoftware\\KaKao_ChatBot",
26 "author": { 26 "author": {
27 "name": "Matt Mueller", 27 "name": "Matt Mueller",
......
1 -language: node_js
2 -node_js:
3 - - "0.8"
4 - - "0.10"
1 -Copyright 2010 James Halliday (mail@substack.net)
2 -
3 -This project is free software released under the MIT/X11 license:
4 -
5 -Permission is hereby granted, free of charge, to any person obtaining a copy
6 -of this software and associated documentation files (the "Software"), to deal
7 -in the Software without restriction, including without limitation the rights
8 -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 -copies of the Software, and to permit persons to whom the Software is
10 -furnished to do so, subject to the following conditions:
11 -
12 -The above copyright notice and this permission notice shall be included in
13 -all copies or substantial portions of the Software.
14 -
15 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 -THE SOFTWARE.
1 -#!/usr/bin/env node
2 -var util = require('util');
3 -var argv = require('optimist').argv;
4 -
5 -if (argv.s) {
6 - util.print(argv.fr ? 'Le chat dit: ' : 'The cat says: ');
7 -}
8 -console.log(
9 - (argv.fr ? 'miaou' : 'meow') + (argv.p ? '.' : '')
10 -);
1 -#!/usr/bin/env node
2 -var argv = require('optimist')
3 - .boolean(['x','y','z'])
4 - .argv
5 -;
6 -console.dir([ argv.x, argv.y, argv.z ]);
7 -console.dir(argv._);
1 -#!/usr/bin/env node
2 -var argv = require('optimist')
3 - .boolean('v')
4 - .argv
5 -;
6 -console.dir(argv.v);
7 -console.dir(argv._);
1 -#!/usr/bin/env node
2 -
3 -var argv = require('optimist')
4 - .default({ x : 10, y : 10 })
5 - .argv
6 -;
7 -
8 -console.log(argv.x + argv.y);
1 -#!/usr/bin/env node
2 -var argv = require('optimist')
3 - .default('x', 10)
4 - .default('y', 10)
5 - .argv
6 -;
7 -console.log(argv.x + argv.y);
1 -#!/usr/bin/env node
2 -
3 -var argv = require('optimist')
4 - .usage('Usage: $0 -x [num] -y [num]')
5 - .demand(['x','y'])
6 - .argv;
7 -
8 -console.log(argv.x / argv.y);
1 -#!/usr/bin/env node
2 -var argv = require('optimist')
3 - .usage('Count the lines in a file.\nUsage: $0')
4 - .demand('f')
5 - .alias('f', 'file')
6 - .describe('f', 'Load a file')
7 - .argv
8 -;
9 -
10 -var fs = require('fs');
11 -var s = fs.createReadStream(argv.file);
12 -
13 -var lines = 0;
14 -s.on('data', function (buf) {
15 - lines += buf.toString().match(/\n/g).length;
16 -});
17 -
18 -s.on('end', function () {
19 - console.log(lines);
20 -});
1 -#!/usr/bin/env node
2 -var argv = require('optimist')
3 - .usage('Count the lines in a file.\nUsage: $0')
4 - .options({
5 - file : {
6 - demand : true,
7 - alias : 'f',
8 - description : 'Load a file'
9 - },
10 - base : {
11 - alias : 'b',
12 - description : 'Numeric base to use for output',
13 - default : 10,
14 - },
15 - })
16 - .argv
17 -;
18 -
19 -var fs = require('fs');
20 -var s = fs.createReadStream(argv.file);
21 -
22 -var lines = 0;
23 -s.on('data', function (buf) {
24 - lines += buf.toString().match(/\n/g).length;
25 -});
26 -
27 -s.on('end', function () {
28 - console.log(lines.toString(argv.base));
29 -});
1 -#!/usr/bin/env node
2 -var argv = require('optimist')
3 - .usage('Count the lines in a file.\nUsage: $0')
4 - .wrap(80)
5 - .demand('f')
6 - .alias('f', [ 'file', 'filename' ])
7 - .describe('f',
8 - "Load a file. It's pretty important."
9 - + " Required even. So you'd better specify it."
10 - )
11 - .alias('b', 'base')
12 - .describe('b', 'Numeric base to display the number of lines in')
13 - .default('b', 10)
14 - .describe('x', 'Super-secret optional parameter which is secret')
15 - .default('x', '')
16 - .argv
17 -;
18 -
19 -var fs = require('fs');
20 -var s = fs.createReadStream(argv.file);
21 -
22 -var lines = 0;
23 -s.on('data', function (buf) {
24 - lines += buf.toString().match(/\n/g).length;
25 -});
26 -
27 -s.on('end', function () {
28 - console.log(lines.toString(argv.base));
29 -});
1 -#!/usr/bin/env node
2 -var argv = require('optimist').argv;
3 -console.log('(%d,%d)', argv.x, argv.y);
4 -console.log(argv._);
1 -#!/usr/bin/env node
2 -console.dir(require('optimist').argv);
1 -#!/usr/bin/env node
2 -var argv = require('optimist').argv;
3 -console.log('(%d,%d)', argv.x, argv.y);
1 -#!/usr/bin/env node
2 -var argv = require('optimist')
3 - .string('x', 'y')
4 - .argv
5 -;
6 -console.dir([ argv.x, argv.y ]);
7 -
8 -/* Turns off numeric coercion:
9 - ./node string.js -x 000123 -y 9876
10 - [ '000123', '9876' ]
11 -*/
1 -var optimist = require('./../index');
2 -
3 -var argv = optimist.usage('This is my awesome program', {
4 - 'about': {
5 - description: 'Provide some details about the author of this program',
6 - required: true,
7 - short: 'a',
8 - },
9 - 'info': {
10 - description: 'Provide some information about the node.js agains!!!!!!',
11 - boolean: true,
12 - short: 'i'
13 - }
14 -}).argv;
15 -
16 -optimist.showHelp();
17 -
18 -console.log('\n\nInspecting options');
19 -console.dir(argv);
...\ No newline at end of file ...\ No newline at end of file
1 -#!/usr/bin/env node
2 -var argv = require('optimist').argv;
3 -
4 -if (argv.rif - 5 * argv.xup > 7.138) {
5 - console.log('Buy more riffiwobbles');
6 -}
7 -else {
8 - console.log('Sell the xupptumblers');
9 -}
10 -
This diff is collapsed. Click to expand it.
1 -{
2 - "_from": "optimist@~0.3.5",
3 - "_id": "optimist@0.3.7",
4 - "_inBundle": false,
5 - "_integrity": "sha1-yQlBrVnkJzMokjB00s8ufLxuwNk=",
6 - "_location": "/optimist",
7 - "_phantomChildren": {},
8 - "_requested": {
9 - "type": "range",
10 - "registry": true,
11 - "raw": "optimist@~0.3.5",
12 - "name": "optimist",
13 - "escapedName": "optimist",
14 - "rawSpec": "~0.3.5",
15 - "saveSpec": null,
16 - "fetchSpec": "~0.3.5"
17 - },
18 - "_requiredBy": [
19 - "/uglify-js"
20 - ],
21 - "_resolved": "https://registry.npmjs.org/optimist/-/optimist-0.3.7.tgz",
22 - "_shasum": "c90941ad59e4273328923074d2cf2e7cbc6ec0d9",
23 - "_spec": "optimist@~0.3.5",
24 - "_where": "D:\\OneDrive\\University Life\\2018\\2nd semester\\OpenSourceSoftware\\KaKao_ChatBot\\node_modules\\uglify-js",
25 - "author": {
26 - "name": "James Halliday",
27 - "email": "mail@substack.net",
28 - "url": "http://substack.net"
29 - },
30 - "bugs": {
31 - "url": "https://github.com/substack/node-optimist/issues"
32 - },
33 - "bundleDependencies": false,
34 - "dependencies": {
35 - "wordwrap": "~0.0.2"
36 - },
37 - "deprecated": false,
38 - "description": "Light-weight option parsing with an argv hash. No optstrings attached.",
39 - "devDependencies": {
40 - "hashish": "~0.0.4",
41 - "tap": "~0.4.0"
42 - },
43 - "engine": {
44 - "node": ">=0.4"
45 - },
46 - "homepage": "https://github.com/substack/node-optimist#readme",
47 - "keywords": [
48 - "argument",
49 - "args",
50 - "option",
51 - "parser",
52 - "parsing",
53 - "cli",
54 - "command"
55 - ],
56 - "license": "MIT/X11",
57 - "main": "./index.js",
58 - "name": "optimist",
59 - "repository": {
60 - "type": "git",
61 - "url": "git+ssh://git@github.com/substack/node-optimist.git"
62 - },
63 - "scripts": {
64 - "test": "tap ./test/*.js"
65 - },
66 - "version": "0.3.7"
67 -}
1 -optimist
2 -========
3 -
4 -Optimist is a node.js library for option parsing for people who hate option
5 -parsing. More specifically, this module is for people who like all the --bells
6 -and -whistlz of program usage but think optstrings are a waste of time.
7 -
8 -With optimist, option parsing doesn't have to suck (as much).
9 -
10 -[![build status](https://secure.travis-ci.org/substack/node-optimist.png)](http://travis-ci.org/substack/node-optimist)
11 -
12 -examples
13 -========
14 -
15 -With Optimist, the options are just a hash! No optstrings attached.
16 --------------------------------------------------------------------
17 -
18 -xup.js:
19 -
20 -````javascript
21 -#!/usr/bin/env node
22 -var argv = require('optimist').argv;
23 -
24 -if (argv.rif - 5 * argv.xup > 7.138) {
25 - console.log('Buy more riffiwobbles');
26 -}
27 -else {
28 - console.log('Sell the xupptumblers');
29 -}
30 -````
31 -
32 -***
33 -
34 - $ ./xup.js --rif=55 --xup=9.52
35 - Buy more riffiwobbles
36 -
37 - $ ./xup.js --rif 12 --xup 8.1
38 - Sell the xupptumblers
39 -
40 -![This one's optimistic.](http://substack.net/images/optimistic.png)
41 -
42 -But wait! There's more! You can do short options:
43 --------------------------------------------------
44 -
45 -short.js:
46 -
47 -````javascript
48 -#!/usr/bin/env node
49 -var argv = require('optimist').argv;
50 -console.log('(%d,%d)', argv.x, argv.y);
51 -````
52 -
53 -***
54 -
55 - $ ./short.js -x 10 -y 21
56 - (10,21)
57 -
58 -And booleans, both long and short (and grouped):
59 -----------------------------------
60 -
61 -bool.js:
62 -
63 -````javascript
64 -#!/usr/bin/env node
65 -var util = require('util');
66 -var argv = require('optimist').argv;
67 -
68 -if (argv.s) {
69 - util.print(argv.fr ? 'Le chat dit: ' : 'The cat says: ');
70 -}
71 -console.log(
72 - (argv.fr ? 'miaou' : 'meow') + (argv.p ? '.' : '')
73 -);
74 -````
75 -
76 -***
77 -
78 - $ ./bool.js -s
79 - The cat says: meow
80 -
81 - $ ./bool.js -sp
82 - The cat says: meow.
83 -
84 - $ ./bool.js -sp --fr
85 - Le chat dit: miaou.
86 -
87 -And non-hypenated options too! Just use `argv._`!
88 --------------------------------------------------
89 -
90 -nonopt.js:
91 -
92 -````javascript
93 -#!/usr/bin/env node
94 -var argv = require('optimist').argv;
95 -console.log('(%d,%d)', argv.x, argv.y);
96 -console.log(argv._);
97 -````
98 -
99 -***
100 -
101 - $ ./nonopt.js -x 6.82 -y 3.35 moo
102 - (6.82,3.35)
103 - [ 'moo' ]
104 -
105 - $ ./nonopt.js foo -x 0.54 bar -y 1.12 baz
106 - (0.54,1.12)
107 - [ 'foo', 'bar', 'baz' ]
108 -
109 -Plus, Optimist comes with .usage() and .demand()!
110 --------------------------------------------------
111 -
112 -divide.js:
113 -
114 -````javascript
115 -#!/usr/bin/env node
116 -var argv = require('optimist')
117 - .usage('Usage: $0 -x [num] -y [num]')
118 - .demand(['x','y'])
119 - .argv;
120 -
121 -console.log(argv.x / argv.y);
122 -````
123 -
124 -***
125 -
126 - $ ./divide.js -x 55 -y 11
127 - 5
128 -
129 - $ node ./divide.js -x 4.91 -z 2.51
130 - Usage: node ./divide.js -x [num] -y [num]
131 -
132 - Options:
133 - -x [required]
134 - -y [required]
135 -
136 - Missing required arguments: y
137 -
138 -EVEN MORE HOLY COW
139 -------------------
140 -
141 -default_singles.js:
142 -
143 -````javascript
144 -#!/usr/bin/env node
145 -var argv = require('optimist')
146 - .default('x', 10)
147 - .default('y', 10)
148 - .argv
149 -;
150 -console.log(argv.x + argv.y);
151 -````
152 -
153 -***
154 -
155 - $ ./default_singles.js -x 5
156 - 15
157 -
158 -default_hash.js:
159 -
160 -````javascript
161 -#!/usr/bin/env node
162 -var argv = require('optimist')
163 - .default({ x : 10, y : 10 })
164 - .argv
165 -;
166 -console.log(argv.x + argv.y);
167 -````
168 -
169 -***
170 -
171 - $ ./default_hash.js -y 7
172 - 17
173 -
174 -And if you really want to get all descriptive about it...
175 ----------------------------------------------------------
176 -
177 -boolean_single.js
178 -
179 -````javascript
180 -#!/usr/bin/env node
181 -var argv = require('optimist')
182 - .boolean('v')
183 - .argv
184 -;
185 -console.dir(argv);
186 -````
187 -
188 -***
189 -
190 - $ ./boolean_single.js -v foo bar baz
191 - true
192 - [ 'bar', 'baz', 'foo' ]
193 -
194 -boolean_double.js
195 -
196 -````javascript
197 -#!/usr/bin/env node
198 -var argv = require('optimist')
199 - .boolean(['x','y','z'])
200 - .argv
201 -;
202 -console.dir([ argv.x, argv.y, argv.z ]);
203 -console.dir(argv._);
204 -````
205 -
206 -***
207 -
208 - $ ./boolean_double.js -x -z one two three
209 - [ true, false, true ]
210 - [ 'one', 'two', 'three' ]
211 -
212 -Optimist is here to help...
213 ----------------------------
214 -
215 -You can describe parameters for help messages and set aliases. Optimist figures
216 -out how to format a handy help string automatically.
217 -
218 -line_count.js
219 -
220 -````javascript
221 -#!/usr/bin/env node
222 -var argv = require('optimist')
223 - .usage('Count the lines in a file.\nUsage: $0')
224 - .demand('f')
225 - .alias('f', 'file')
226 - .describe('f', 'Load a file')
227 - .argv
228 -;
229 -
230 -var fs = require('fs');
231 -var s = fs.createReadStream(argv.file);
232 -
233 -var lines = 0;
234 -s.on('data', function (buf) {
235 - lines += buf.toString().match(/\n/g).length;
236 -});
237 -
238 -s.on('end', function () {
239 - console.log(lines);
240 -});
241 -````
242 -
243 -***
244 -
245 - $ node line_count.js
246 - Count the lines in a file.
247 - Usage: node ./line_count.js
248 -
249 - Options:
250 - -f, --file Load a file [required]
251 -
252 - Missing required arguments: f
253 -
254 - $ node line_count.js --file line_count.js
255 - 20
256 -
257 - $ node line_count.js -f line_count.js
258 - 20
259 -
260 -methods
261 -=======
262 -
263 -By itself,
264 -
265 -````javascript
266 -require('optimist').argv
267 -`````
268 -
269 -will use `process.argv` array to construct the `argv` object.
270 -
271 -You can pass in the `process.argv` yourself:
272 -
273 -````javascript
274 -require('optimist')([ '-x', '1', '-y', '2' ]).argv
275 -````
276 -
277 -or use .parse() to do the same thing:
278 -
279 -````javascript
280 -require('optimist').parse([ '-x', '1', '-y', '2' ])
281 -````
282 -
283 -The rest of these methods below come in just before the terminating `.argv`.
284 -
285 -.alias(key, alias)
286 -------------------
287 -
288 -Set key names as equivalent such that updates to a key will propagate to aliases
289 -and vice-versa.
290 -
291 -Optionally `.alias()` can take an object that maps keys to aliases.
292 -
293 -.default(key, value)
294 ---------------------
295 -
296 -Set `argv[key]` to `value` if no option was specified on `process.argv`.
297 -
298 -Optionally `.default()` can take an object that maps keys to default values.
299 -
300 -.demand(key)
301 -------------
302 -
303 -If `key` is a string, show the usage information and exit if `key` wasn't
304 -specified in `process.argv`.
305 -
306 -If `key` is a number, demand at least as many non-option arguments, which show
307 -up in `argv._`.
308 -
309 -If `key` is an Array, demand each element.
310 -
311 -.describe(key, desc)
312 ---------------------
313 -
314 -Describe a `key` for the generated usage information.
315 -
316 -Optionally `.describe()` can take an object that maps keys to descriptions.
317 -
318 -.options(key, opt)
319 -------------------
320 -
321 -Instead of chaining together `.alias().demand().default()`, you can specify
322 -keys in `opt` for each of the chainable methods.
323 -
324 -For example:
325 -
326 -````javascript
327 -var argv = require('optimist')
328 - .options('f', {
329 - alias : 'file',
330 - default : '/etc/passwd',
331 - })
332 - .argv
333 -;
334 -````
335 -
336 -is the same as
337 -
338 -````javascript
339 -var argv = require('optimist')
340 - .alias('f', 'file')
341 - .default('f', '/etc/passwd')
342 - .argv
343 -;
344 -````
345 -
346 -Optionally `.options()` can take an object that maps keys to `opt` parameters.
347 -
348 -.usage(message)
349 ----------------
350 -
351 -Set a usage message to show which commands to use. Inside `message`, the string
352 -`$0` will get interpolated to the current script name or node command for the
353 -present script similar to how `$0` works in bash or perl.
354 -
355 -.check(fn)
356 -----------
357 -
358 -Check that certain conditions are met in the provided arguments.
359 -
360 -If `fn` throws or returns `false`, show the thrown error, usage information, and
361 -exit.
362 -
363 -.boolean(key)
364 --------------
365 -
366 -Interpret `key` as a boolean. If a non-flag option follows `key` in
367 -`process.argv`, that string won't get set as the value of `key`.
368 -
369 -If `key` never shows up as a flag in `process.arguments`, `argv[key]` will be
370 -`false`.
371 -
372 -If `key` is an Array, interpret all the elements as booleans.
373 -
374 -.string(key)
375 -------------
376 -
377 -Tell the parser logic not to interpret `key` as a number or boolean.
378 -This can be useful if you need to preserve leading zeros in an input.
379 -
380 -If `key` is an Array, interpret all the elements as strings.
381 -
382 -.wrap(columns)
383 ---------------
384 -
385 -Format usage output to wrap at `columns` many columns.
386 -
387 -.help()
388 --------
389 -
390 -Return the generated usage string.
391 -
392 -.showHelp(fn=console.error)
393 ----------------------------
394 -
395 -Print the usage data using `fn` for printing.
396 -
397 -.parse(args)
398 -------------
399 -
400 -Parse `args` instead of `process.argv`. Returns the `argv` object.
401 -
402 -.argv
403 ------
404 -
405 -Get the arguments as a plain old object.
406 -
407 -Arguments without a corresponding flag show up in the `argv._` array.
408 -
409 -The script name or node command is available at `argv.$0` similarly to how `$0`
410 -works in bash or perl.
411 -
412 -parsing tricks
413 -==============
414 -
415 -stop parsing
416 -------------
417 -
418 -Use `--` to stop parsing flags and stuff the remainder into `argv._`.
419 -
420 - $ node examples/reflect.js -a 1 -b 2 -- -c 3 -d 4
421 - { _: [ '-c', '3', '-d', '4' ],
422 - '$0': 'node ./examples/reflect.js',
423 - a: 1,
424 - b: 2 }
425 -
426 -negate fields
427 --------------
428 -
429 -If you want to explicity set a field to false instead of just leaving it
430 -undefined or to override a default you can do `--no-key`.
431 -
432 - $ node examples/reflect.js -a --no-b
433 - { _: [],
434 - '$0': 'node ./examples/reflect.js',
435 - a: true,
436 - b: false }
437 -
438 -numbers
439 --------
440 -
441 -Every argument that looks like a number (`!isNaN(Number(arg))`) is converted to
442 -one. This way you can just `net.createConnection(argv.port)` and you can add
443 -numbers out of `argv` with `+` without having that mean concatenation,
444 -which is super frustrating.
445 -
446 -duplicates
447 -----------
448 -
449 -If you specify a flag multiple times it will get turned into an array containing
450 -all the values in order.
451 -
452 - $ node examples/reflect.js -x 5 -x 8 -x 0
453 - { _: [],
454 - '$0': 'node ./examples/reflect.js',
455 - x: [ 5, 8, 0 ] }
456 -
457 -dot notation
458 -------------
459 -
460 -When you use dots (`.`s) in argument names, an implicit object path is assumed.
461 -This lets you organize arguments into nested objects.
462 -
463 - $ node examples/reflect.js --foo.bar.baz=33 --foo.quux=5
464 - { _: [],
465 - '$0': 'node ./examples/reflect.js',
466 - foo: { bar: { baz: 33 }, quux: 5 } }
467 -
468 -installation
469 -============
470 -
471 -With [npm](http://github.com/isaacs/npm), just do:
472 - npm install optimist
473 -
474 -or clone this project on github:
475 -
476 - git clone http://github.com/substack/node-optimist.git
477 -
478 -To run the tests with [expresso](http://github.com/visionmedia/expresso),
479 -just do:
480 -
481 - expresso
482 -
483 -inspired By
484 -===========
485 -
486 -This module is loosely inspired by Perl's
487 -[Getopt::Casual](http://search.cpan.org/~photo/Getopt-Casual-0.13.1/Casual.pm).
1 -var spawn = require('child_process').spawn;
2 -var test = require('tap').test;
3 -
4 -test('dotSlashEmpty', testCmd('./bin.js', []));
5 -
6 -test('dotSlashArgs', testCmd('./bin.js', [ 'a', 'b', 'c' ]));
7 -
8 -test('nodeEmpty', testCmd('node bin.js', []));
9 -
10 -test('nodeArgs', testCmd('node bin.js', [ 'x', 'y', 'z' ]));
11 -
12 -test('whichNodeEmpty', function (t) {
13 - var which = spawn('which', ['node']);
14 -
15 - which.stdout.on('data', function (buf) {
16 - t.test(
17 - testCmd(buf.toString().trim() + ' bin.js', [])
18 - );
19 - t.end();
20 - });
21 -
22 - which.stderr.on('data', function (err) {
23 - assert.error(err);
24 - t.end();
25 - });
26 -});
27 -
28 -test('whichNodeArgs', function (t) {
29 - var which = spawn('which', ['node']);
30 -
31 - which.stdout.on('data', function (buf) {
32 - t.test(
33 - testCmd(buf.toString().trim() + ' bin.js', [ 'q', 'r' ])
34 - );
35 - t.end();
36 - });
37 -
38 - which.stderr.on('data', function (err) {
39 - t.error(err);
40 - t.end();
41 - });
42 -});
43 -
44 -function testCmd (cmd, args) {
45 -
46 - return function (t) {
47 - var to = setTimeout(function () {
48 - assert.fail('Never got stdout data.')
49 - }, 5000);
50 -
51 - var oldDir = process.cwd();
52 - process.chdir(__dirname + '/_');
53 -
54 - var cmds = cmd.split(' ');
55 -
56 - var bin = spawn(cmds[0], cmds.slice(1).concat(args.map(String)));
57 - process.chdir(oldDir);
58 -
59 - bin.stderr.on('data', function (err) {
60 - t.error(err);
61 - t.end();
62 - });
63 -
64 - bin.stdout.on('data', function (buf) {
65 - clearTimeout(to);
66 - var _ = JSON.parse(buf.toString());
67 - t.same(_.map(String), args.map(String));
68 - t.end();
69 - });
70 - };
71 -}
1 -#!/usr/bin/env node
2 -console.log(JSON.stringify(process.argv));
1 -#!/usr/bin/env node
2 -var argv = require('../../index').argv
3 -console.log(JSON.stringify(argv._));
This diff is collapsed. Click to expand it.
1 -var Hash = require('hashish');
2 -var optimist = require('../index');
3 -var test = require('tap').test;
4 -
5 -test('usageFail', function (t) {
6 - var r = checkUsage(function () {
7 - return optimist('-x 10 -z 20'.split(' '))
8 - .usage('Usage: $0 -x NUM -y NUM')
9 - .demand(['x','y'])
10 - .argv;
11 - });
12 - t.same(
13 - r.result,
14 - { x : 10, z : 20, _ : [], $0 : './usage' }
15 - );
16 -
17 - t.same(
18 - r.errors.join('\n').split(/\n+/),
19 - [
20 - 'Usage: ./usage -x NUM -y NUM',
21 - 'Options:',
22 - ' -x [required]',
23 - ' -y [required]',
24 - 'Missing required arguments: y',
25 - ]
26 - );
27 - t.same(r.logs, []);
28 - t.ok(r.exit);
29 - t.end();
30 -});
31 -
32 -
33 -test('usagePass', function (t) {
34 - var r = checkUsage(function () {
35 - return optimist('-x 10 -y 20'.split(' '))
36 - .usage('Usage: $0 -x NUM -y NUM')
37 - .demand(['x','y'])
38 - .argv;
39 - });
40 - t.same(r, {
41 - result : { x : 10, y : 20, _ : [], $0 : './usage' },
42 - errors : [],
43 - logs : [],
44 - exit : false,
45 - });
46 - t.end();
47 -});
48 -
49 -test('checkPass', function (t) {
50 - var r = checkUsage(function () {
51 - return optimist('-x 10 -y 20'.split(' '))
52 - .usage('Usage: $0 -x NUM -y NUM')
53 - .check(function (argv) {
54 - if (!('x' in argv)) throw 'You forgot about -x';
55 - if (!('y' in argv)) throw 'You forgot about -y';
56 - })
57 - .argv;
58 - });
59 - t.same(r, {
60 - result : { x : 10, y : 20, _ : [], $0 : './usage' },
61 - errors : [],
62 - logs : [],
63 - exit : false,
64 - });
65 - t.end();
66 -});
67 -
68 -test('checkFail', function (t) {
69 - var r = checkUsage(function () {
70 - return optimist('-x 10 -z 20'.split(' '))
71 - .usage('Usage: $0 -x NUM -y NUM')
72 - .check(function (argv) {
73 - if (!('x' in argv)) throw 'You forgot about -x';
74 - if (!('y' in argv)) throw 'You forgot about -y';
75 - })
76 - .argv;
77 - });
78 -
79 - t.same(
80 - r.result,
81 - { x : 10, z : 20, _ : [], $0 : './usage' }
82 - );
83 -
84 - t.same(
85 - r.errors.join('\n').split(/\n+/),
86 - [
87 - 'Usage: ./usage -x NUM -y NUM',
88 - 'You forgot about -y'
89 - ]
90 - );
91 -
92 - t.same(r.logs, []);
93 - t.ok(r.exit);
94 - t.end();
95 -});
96 -
97 -test('checkCondPass', function (t) {
98 - function checker (argv) {
99 - return 'x' in argv && 'y' in argv;
100 - }
101 -
102 - var r = checkUsage(function () {
103 - return optimist('-x 10 -y 20'.split(' '))
104 - .usage('Usage: $0 -x NUM -y NUM')
105 - .check(checker)
106 - .argv;
107 - });
108 - t.same(r, {
109 - result : { x : 10, y : 20, _ : [], $0 : './usage' },
110 - errors : [],
111 - logs : [],
112 - exit : false,
113 - });
114 - t.end();
115 -});
116 -
117 -test('checkCondFail', function (t) {
118 - function checker (argv) {
119 - return 'x' in argv && 'y' in argv;
120 - }
121 -
122 - var r = checkUsage(function () {
123 - return optimist('-x 10 -z 20'.split(' '))
124 - .usage('Usage: $0 -x NUM -y NUM')
125 - .check(checker)
126 - .argv;
127 - });
128 -
129 - t.same(
130 - r.result,
131 - { x : 10, z : 20, _ : [], $0 : './usage' }
132 - );
133 -
134 - t.same(
135 - r.errors.join('\n').split(/\n+/).join('\n'),
136 - 'Usage: ./usage -x NUM -y NUM\n'
137 - + 'Argument check failed: ' + checker.toString()
138 - );
139 -
140 - t.same(r.logs, []);
141 - t.ok(r.exit);
142 - t.end();
143 -});
144 -
145 -test('countPass', function (t) {
146 - var r = checkUsage(function () {
147 - return optimist('1 2 3 --moo'.split(' '))
148 - .usage('Usage: $0 [x] [y] [z] {OPTIONS}')
149 - .demand(3)
150 - .argv;
151 - });
152 - t.same(r, {
153 - result : { _ : [ '1', '2', '3' ], moo : true, $0 : './usage' },
154 - errors : [],
155 - logs : [],
156 - exit : false,
157 - });
158 - t.end();
159 -});
160 -
161 -test('countFail', function (t) {
162 - var r = checkUsage(function () {
163 - return optimist('1 2 --moo'.split(' '))
164 - .usage('Usage: $0 [x] [y] [z] {OPTIONS}')
165 - .demand(3)
166 - .argv;
167 - });
168 - t.same(
169 - r.result,
170 - { _ : [ '1', '2' ], moo : true, $0 : './usage' }
171 - );
172 -
173 - t.same(
174 - r.errors.join('\n').split(/\n+/),
175 - [
176 - 'Usage: ./usage [x] [y] [z] {OPTIONS}',
177 - 'Not enough non-option arguments: got 2, need at least 3',
178 - ]
179 - );
180 -
181 - t.same(r.logs, []);
182 - t.ok(r.exit);
183 - t.end();
184 -});
185 -
186 -test('defaultSingles', function (t) {
187 - var r = checkUsage(function () {
188 - return optimist('--foo 50 --baz 70 --powsy'.split(' '))
189 - .default('foo', 5)
190 - .default('bar', 6)
191 - .default('baz', 7)
192 - .argv
193 - ;
194 - });
195 - t.same(r.result, {
196 - foo : '50',
197 - bar : 6,
198 - baz : '70',
199 - powsy : true,
200 - _ : [],
201 - $0 : './usage',
202 - });
203 - t.end();
204 -});
205 -
206 -test('defaultAliases', function (t) {
207 - var r = checkUsage(function () {
208 - return optimist('')
209 - .alias('f', 'foo')
210 - .default('f', 5)
211 - .argv
212 - ;
213 - });
214 - t.same(r.result, {
215 - f : '5',
216 - foo : '5',
217 - _ : [],
218 - $0 : './usage',
219 - });
220 - t.end();
221 -});
222 -
223 -test('defaultHash', function (t) {
224 - var r = checkUsage(function () {
225 - return optimist('--foo 50 --baz 70'.split(' '))
226 - .default({ foo : 10, bar : 20, quux : 30 })
227 - .argv
228 - ;
229 - });
230 - t.same(r.result, {
231 - _ : [],
232 - $0 : './usage',
233 - foo : 50,
234 - baz : 70,
235 - bar : 20,
236 - quux : 30,
237 - });
238 - t.end();
239 -});
240 -
241 -test('rebase', function (t) {
242 - t.equal(
243 - optimist.rebase('/home/substack', '/home/substack/foo/bar/baz'),
244 - './foo/bar/baz'
245 - );
246 - t.equal(
247 - optimist.rebase('/home/substack/foo/bar/baz', '/home/substack'),
248 - '../../..'
249 - );
250 - t.equal(
251 - optimist.rebase('/home/substack/foo', '/home/substack/pow/zoom.txt'),
252 - '../pow/zoom.txt'
253 - );
254 - t.end();
255 -});
256 -
257 -function checkUsage (f) {
258 -
259 - var exit = false;
260 -
261 - process._exit = process.exit;
262 - process._env = process.env;
263 - process._argv = process.argv;
264 -
265 - process.exit = function (t) { exit = true };
266 - process.env = Hash.merge(process.env, { _ : 'node' });
267 - process.argv = [ './usage' ];
268 -
269 - var errors = [];
270 - var logs = [];
271 -
272 - console._error = console.error;
273 - console.error = function (msg) { errors.push(msg) };
274 - console._log = console.log;
275 - console.log = function (msg) { logs.push(msg) };
276 -
277 - var result = f();
278 -
279 - process.exit = process._exit;
280 - process.env = process._env;
281 - process.argv = process._argv;
282 -
283 - console.error = console._error;
284 - console.log = console._log;
285 -
286 - return {
287 - errors : errors,
288 - logs : logs,
289 - exit : exit,
290 - result : result,
291 - };
292 -};
1 -TODO
2 -
3 -v0.5.0
4 -+ Major cleanup
5 -+ Remove old unused functionality
6 -+ Load modules in parallel (faster dev mode)
7 -
8 -v0.4.9
9 -+ Make the max length of lines an option and make it quite short by default for easier debugging
10 -
11 -v0.4.7
12 -+ Remove default port and host - just use what the current page uses by default
13 -+ Treat Android devices as mobile, with regards to loading resources in one big response rather than individual requests
14 -+ Now works if script include put in head
15 -
16 -v0.4.6
17 -+ Add server.setOpts and server.handleRequest
18 -
19 -v0.4.5
20 -+ Set the mimetype of script files correctly
21 -+ Remove node_modules directory - use dependencies in package.json instead
22 -+ Implement addPath and addFile for specifying custom path resolutions
23 -+ Implement addReplacement for replacing code during dev serving or compilation
24 -+ Implement dontAddClosureForModule and dontIncludeModule for compiler
25 -+ Remove dependency on std.js
26 -+ Add usePagePort option to make module requests go to the host/port of the page it's served on, rather than the host/port passed in to listen(port, ...)
27 -
28 -v0.4.4
29 -+ Import js files directly under node_modules correctly, e.g. ./node_modules/foo.js
30 -
31 -v0.4.3
32 -+ Fix import of socket.io browser npm module
33 -+ Enable nested npm module imports by reimplementing node's require.resolve algorithm
34 -
35 -v0.4.2
36 -+ Use uglifyjs to compress JS
37 -+ Synchronous compilation API
38 -+ Remove --paths option. Search for modules exactly like require.resolve does
39 -+ Greatle simplify Readme instructions
40 -+ Use util.resolve in compiler, minimizing repeated code
41 -+ Implement require.mount(server, opts) - mounts itself onto an existing http server
42 -+ Implement require.connect(opts) - connect middleware
43 -+ Implement require.isRequireRequest - checks if an http request is for the require server
44 -
45 -v0.4.1
46 -+ Consult package.json's "main" field when resolving modules in the compiler
47 -+ Fix bug where modules starting with (function() { ... }) would throw in their compiled form
48 -+ Clearer compiler usage example in example/compile.js
49 -+ Better error messages when a module cannot be found during compilation
50 -
51 -v0.4.0
52 -+ New API
53 -+ New command line utility
54 -+ New documentation
55 -
56 -v0.3.2
57 -+ Improved command line tool
58 -+ new API: single method require('require/compiler').compile(<code | file path>, <compilation level 0 | 1 | 2 | 3>, <callback>)
59 -+ allow chaining of methods on the require server
60 -+ alert an error message client-side when a module is not found (rather than crash the process :)
61 -
62 -v0.3.1
63 -+ Fix context bug in delay
64 -+ Change compiled instances of require._[PATH] to require[PATH]. require is simply a hash of module paths.
65 -+ Add setRoot API
66 -+ Improved docs in README
67 -+ Binary request-dev --port 1234 --host localhost ./path
68 -
69 -v0.3.0
70 -+ Make a standalone server for dev mode
71 -
72 -v0.2.8
73 -+ Don't leave require.paths modified after require.resolve. Add paths right before they're needed, and remove paths after.
74 -
75 -v0.2.7
76 -+ Improve path resolution
77 -
78 -v0.2.6
79 -+ Improve the order in which we try to load modules
80 -
81 -v0.2.5
82 -+ Fix compilation order for __main__
83 -
84 -v0.2.1
85 -+ A development server that serves requires files in dev mode
86 -
87 -v0.2.0
88 -+ latest version published on npm
89 -
90 -v0.1.13
91 -+ better file layout - bin/ lib/
92 -+ created bin/compile to compile files
93 -+ created bin/compress to compile and compress files
94 -+ improved readability of compiled files by flattening the require hierarchy
95 -+ replace module names with short names, e.g. "_1", "_2", etc
96 -
97 -v0.1.12
98 -+ Support module path names in the compiler, e.g. require('require/compiler')
99 -
100 -v0.1.11
101 -+ Fix: compiler now resolves module/index.js paths correctly
102 -
103 -v0.1.10
104 -+ Allow for a node server to server require using require('require').toString()
105 -
106 -v0.1.9
107 -+ It's no longer required to add id="browser-require" to a script tag in order to load the main module automatically
108 -
109 -v0.1.8
110 -+ Rename to require
111 -
112 -v0.1.7
113 -+ Publish with npm
114 -
115 -v0.1.6
116 -+ Fix: Variables declared inside of require.js are no longer visible to imported modules
117 -+ Remove the "root" configuration parameter added in v0.1.1. You cannot modify the root in node.
118 -
119 -v0.1.5
120 -+ Allow for a file inside of a folder to import the folder's index file with require('./')
121 -
122 -v0.1.4
123 -+ Allow modules with circular dependencies to reference each other
124 -
125 -v0.1.3
126 -+ Don't get stuck loading circular dependencies
127 -
128 -v0.1.2
129 -+ Support index.js - if a module is not found at location, look for it at location/index.js
130 -
131 -v0.1.1
132 -+ Support the "root" configuration parameter
133 -+ Fix: consecutive slashes get replaced with a single slash as opposed to no slash
134 -
135 -v0.1.0
136 -First version, implements node's require() statement for the browser
1 -Copyright (c) 2011 Marcus Westin
2 -
3 -Permission is hereby granted, free of charge, to any person obtaining a copy
4 -of this software and associated documentation files (the "Software"), to deal
5 -in the Software without restriction, including without limitation the rights
6 -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 -copies of the Software, and to permit persons to whom the Software is
8 -furnished to do so, subject to the following conditions:
9 -
10 -The above copyright notice and this permission notice shall be included in
11 -all copies or substantial portions of the Software.
12 -
13 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 -THE SOFTWARE.
...\ No newline at end of file ...\ No newline at end of file
1 -require brings `require` to the browser
2 -=======================================
3 -
4 -Node's `require()` is the de facto javascript dependency statement.
5 -
6 -`npm` is the de facto javascript module manager.
7 -
8 -require brings both of them to the browser.
9 -
10 -tl;dr
11 -=====
12 -"Just give me some code that runs"
13 -
14 - mkdir app; cd app
15 - echo '{ "name":"app" }' > package.json
16 - sudo npm install require
17 - sudo npm install raphael
18 - curl -O https://raw.github.com/gist/975866/little_server.js
19 - curl -O https://raw.github.com/gist/975868/little_client.js
20 - node little_server.js
21 -
22 -Now go to http://localhost:8080
23 -
24 -Install
25 -=======
26 -
27 - sudo npm install -g require
28 -
29 -Run
30 -===
31 -Start dev server
32 -
33 - require serve ./example --port 1234 --host localhost
34 -
35 -In your HTML:
36 -
37 - <script src="//localhost:1234/require/client"></script>
38 -
39 -This is like calling require('client') from inside ./example.
40 -[Read more on node's require path resolution](http://nodejs.org/api/modules.html)
41 -
42 -Compile
43 -=======
44 -(You'll want to do this before you deploy to production)
45 -
46 - require compile ./example/client.js > client.min.js
47 -
48 -Use programmatically
49 -====================
50 -In node:
51 -
52 - require('require/server').listen(1234)
53 -
54 -or mount it on an http server you're already running
55 -
56 - var server = http.createServer(function(req, res) { })
57 - require('require/server').mount(server)
58 - server.listen(8080, 'localhost')
59 -
60 -or, as connect middleware
61 -
62 - connect.createServer(
63 - connect.static(__dirname + '/example'),
64 - require('require/server').connect()
65 - )
66 -
67 -Compile programmatically:
68 -
69 - var compiler = require('require/compiler')
70 - console.log(compiler.compile('./example/client.js'))
71 - console.log(compiler.compileCode('require("./example/client")'))
72 -
73 -The compiler supports all the options of https://github.com/mishoo/UglifyJS, e.g.
74 -
75 - compiler.compile('./example/client.js', { beautify:true, ascii_only:true })
1 -#!/usr/bin/env node
2 -
3 -var path = require('path'),
4 - server = require('../server'),
5 - compiler = require('../compiler')
6 -
7 -var opts = {
8 - port: 1234,
9 - host: 'localhost',
10 - command: null,
11 - path: null
12 -}
13 -
14 -var args = [].slice.call(process.argv, 2)
15 -
16 -opts.command = args.shift()
17 -opts.path = path.resolve(args.shift())
18 -
19 -while (args.length) {
20 - var arg = args.shift()
21 - switch(arg) {
22 - case '--port':
23 - opts.port = args.shift()
24 - break
25 - case '--host':
26 - opts.host = args.shift()
27 - break
28 - case '--root':
29 - opts.root = args.shift()
30 - break
31 - case '--usePagePort':
32 - if (args[0] && args[0][0] != '-') {
33 - console.log('Unexpected value for --usePagePort flag', args[0])
34 - process.exit(1)
35 - }
36 - opts.usePagePort = true
37 - break
38 - default:
39 - console.log('Unknown option', arg)
40 - process.exit(1)
41 - break
42 - }
43 -}
44 -
45 -switch (opts.command) {
46 - case 'serve':
47 - if (!opts.path) {
48 - console.log('Specify a path to serve from, e.g. require serve ./example')
49 - process.exit(1)
50 - }
51 - server.listen(opts)
52 - console.log('serving from', opts.path, 'on', 'http://'+opts.host+':'+opts.port)
53 - break
54 - case 'compile':
55 - if (!opts.path) {
56 - console.log('Specify a single file to compile, e.g. require compile ./path/to/file.js')
57 - process.exit(1)
58 - }
59 - console.log(compiler.compile(opts.path))
60 - break
61 - default:
62 - if (opts.command) {
63 - console.log('Unknown command', '"' + opts.command + '".', 'Try "require serve" or "require compile"')
64 - } else {
65 - console.log('You need to give a command, e.g. "require serve" or "require compile"')
66 - }
67 - process.exit(1)
68 -}
69 -
1 -var fs = require('fs')
2 -var path = require('path')
3 -var extend = require('std/extend')
4 -var each = require('std/each')
5 -var getCode = require('./lib/getCode')
6 -var resolve = require('./lib/resolve')
7 -var getRequireStatements = require('./lib/getRequireStatements')
8 -
9 -module.exports = {
10 - compile: compileFile,
11 - compileHTML: compileHTMLFile,
12 - compileCode: compileCode
13 -}
14 -
15 -/* api
16 - *****/
17 -function compileFile(filePath, opts) {
18 - filePath = path.resolve(filePath)
19 - opts = extend(opts, { basePath:path.dirname(filePath), toplevel:true })
20 - var code = getCode(filePath)
21 - return _compile(code, opts, filePath)
22 -}
23 -
24 -function compileCode(code, opts) {
25 - opts = extend(opts, { basePath:process.cwd(), toplevel:true })
26 - return _compile(code, opts, '<code passed into compiler.compile()>')
27 -}
28 -
29 -function compileHTMLFile(filePath, opts) {
30 - var html = fs.readFileSync(filePath).toString()
31 - while (match = html.match(/<script src="\/require\/([\/\w\.]+)"><\/script>/)) {
32 - var js = compileFile(match[1].toString(), opts)
33 -
34 - var BACKREFERENCE_WORKAROUND = '____________backreference_workaround________'
35 - js = js.replace('\$\&', BACKREFERENCE_WORKAROUND)
36 - html = html.replace(match[0], '<script>'+js+'</script>')
37 - html = html.replace(BACKREFERENCE_WORKAROUND, '\$\&')
38 - }
39 - return html
40 -}
41 -
42 -
43 -var _compile = function(code, opts, mainModule) {
44 - var code = 'var __require__ = {}, require=function(){}\n' + _compileModule(code, opts.basePath, mainModule)
45 - if (opts.minify === false) { return code } // TODO use uglifyjs' beautifier?
46 -
47 - var UglifyJS = require('uglify-js')
48 - var result = UglifyJS.minify(code, {
49 - fromString:true,
50 - mangle:true,
51 - output: {
52 - // http://lisperator.net/uglifyjs/codegen
53 - indent_start : 0, // start indentation on every line (only when `beautify`)
54 - indent_level : 4, // indentation level (only when `beautify`)
55 - quote_keys : false, // quote all keys in object literals?
56 - space_colon : true, // add a space after colon signs?
57 - ascii_only : false, // output ASCII-safe? (encodes Unicode characters as ASCII)
58 - inline_script : false, // escape "</script"?
59 - width : 80, // informative maximum line width (for beautified output)
60 - max_line_len : 200, // maximum line length (for non-beautified output)
61 - ie_proof : true, // output IE-safe code?
62 - beautify : false, // beautify output?
63 - source_map : null, // output a source map
64 - bracketize : false, // use brackets every time?
65 - comments : false, // output comments?
66 - semicolons : true // use semicolons to separate statements? (otherwise, newlines)
67 - },
68 - compress: {
69 - // http://lisperator.net/uglifyjs/compress
70 - sequences : true, // join consecutive statemets with the “comma operator”
71 - properties : true, // optimize property access: a["foo"] → a.foo
72 - dead_code : true, // discard unreachable code
73 - drop_debugger : true, // discard “debugger” statements
74 - unsafe : false, // some unsafe optimizations (see below)
75 - conditionals : true, // optimize if-s and conditional expressions
76 - comparisons : true, // optimize comparisons
77 - evaluate : true, // evaluate constant expressions
78 - booleans : true, // optimize boolean expressions
79 - loops : true, // optimize loops
80 - unused : true, // drop unused variables/functions
81 - hoist_funs : true, // hoist function declarations
82 - hoist_vars : false, // hoist variable declarations
83 - if_return : true, // optimize if-s followed by return/continue
84 - join_vars : true, // join var declarations
85 - cascade : true, // try to cascade `right` into `left` in sequences
86 - side_effects : true, // drop side-effect-free statements
87 - warnings : false, // warn about potentially dangerous optimizations/code
88 - global_defs : {} // global definitions
89 - }
90 - })
91 - // also see result.map
92 - return result.code
93 -}
94 -
95 -/* util
96 - ******/
97 -var _compileModule = function(code, pathBase, mainModule) {
98 - var modules = [mainModule]
99 - _replaceRequireStatements(mainModule, code, modules, pathBase)
100 - code = _concatModules(modules)
101 - code = _minifyRequireStatements(code, modules)
102 - return code
103 -}
104 -
105 -var _minifyRequireStatements = function(code, modules) {
106 - each(modules, function(modulePath, i) {
107 - var escapedPath = modulePath.replace(/\//g, '\\/').replace('(','\\(').replace(')','\\)')
108 - var regex = new RegExp('__require__\\["'+ escapedPath +'"\\]', 'g')
109 -
110 - code = code.replace(regex, '__require__["_'+ i +'"]')
111 - })
112 - return code
113 -}
114 -
115 -var _replaceRequireStatements = function(modulePath, code, modules, pathBase) {
116 - var requireStatements = getRequireStatements(code)
117 -
118 - if (!requireStatements.length) {
119 - modules[modulePath] = code
120 - return
121 - }
122 -
123 - each(requireStatements, function(requireStatement) {
124 - var subModulePath = resolve.requireStatement(requireStatement, modulePath)
125 -
126 - if (!subModulePath) {
127 - throw new Error("Require Compiler Error: Cannot find module '"+ rawModulePath +"' (in '"+ modulePath +"')")
128 - }
129 -
130 - code = code.replace(requireStatement, '__require__["' + subModulePath + '"].exports')
131 -
132 - if (!modules[subModulePath]) {
133 - modules[subModulePath] = true
134 - var newPathBase = path.dirname(subModulePath)
135 - var newModuleCode = getCode(subModulePath)
136 - _replaceRequireStatements(subModulePath, newModuleCode, modules, newPathBase)
137 - modules.push(subModulePath)
138 - }
139 - })
140 -
141 - modules[modulePath] = code
142 -}
143 -
144 -var _concatModules = function(modules) {
145 - var getClosuredModule = function(modulePath) {
146 - return [
147 - ';(function() {',
148 - ' // ' + modulePath,
149 - ' var module = __require__["'+modulePath+'"] = {exports:{}}, exports = module.exports;',
150 - modules[modulePath],
151 - '})()'
152 - ].join('\n')
153 - }
154 -
155 - var moduleDefinitions = []
156 - for (var i=1, modulePath; modulePath = modules[i]; i++) {
157 - moduleDefinitions.push(getClosuredModule(modulePath))
158 - }
159 - moduleDefinitions.push(getClosuredModule(modules[0])) // __main__
160 -
161 - return moduleDefinitions.join('\n\n')
162 -}
1 -var dependency = require('./shared/dependency')
2 -
3 -var el = document.body.appendChild(document.createElement('div'))
4 -el.innerHTML = 'shared dependency:' + JSON.stringify(dependency)
1 -var fs = require('fs'),
2 - compiler = require('../compiler')
3 -
4 -var file = __dirname + '/client.js',
5 - basePath = __dirname,
6 - code = fs.readFileSync(file).toString()
7 -
8 -console.log(compiler.compileCode(code, { basePath:__dirname }))
1 -var connect = require('connect'),
2 - requireServer = require('require/server')
3 -
4 -connect.createServer(
5 - connect.static(__dirname),
6 - requireServer.connect(__dirname)
7 -).listen(8080)
1 -<!doctype html>
2 -<html>
3 -<head>
4 - <title>test</title>
5 -</head>
6 -<body>
7 - <script src="/require/client"></script>
8 -</body>
1 -{
2 - "author": "",
3 - "name": "testApp",
4 - "version": "0.0.0",
5 - "repository": {
6 - "url": ""
7 - },
8 - "directories": {
9 - "lib": "."
10 - },
11 - "engines": {
12 - "node": "*"
13 - },
14 - "dependencies": {},
15 - "devDependencies": {}
16 -}
...\ No newline at end of file ...\ No newline at end of file
1 -<body>
2 - <script src="//localhost:1234/raphael_circle"></script>
3 -</body>
4 -
1 -var raphael = require('raphael'),
2 - canvas = document.body.appendChild(document.createElement('div')),
3 - paper = raphael(canvas)
4 -
5 -paper.circle(50, 50, 40)
1 -var http = require('http'),
2 - fs = require('fs'),
3 - dependency = require('./shared/dependency'),
4 - requireServer = require('../server') // this would be require('require/server') in most applications
5 -
6 -var base = __dirname + '/',
7 - root = 'require'
8 -var server = http.createServer(function(req, res) {
9 - if (requireServer.isRequireRequest(req)) { return }
10 - fs.readFile(base + (req.url.substr(1) || 'index.html'), function(err, content) {
11 - if (err) { return res.end(err.stack) }
12 - res.end(content)
13 - })
14 -})
15 -
16 -requireServer.mount(server, __dirname)
17 -
18 -server.listen(8080)
19 -
20 -console.log('shared dependency:', dependency)
1 -module.exports = {
2 - foo: 'bar',
3 - cat: 'qwe'
4 -}
1 -var fs = require('fs')
2 -
3 -module.exports = function readCode(filePath) {
4 - if (!filePath.match(/\.js$/)) { filePath += '.js' }
5 - return fs.readFileSync(filePath).toString()
6 -}
...\ No newline at end of file ...\ No newline at end of file
1 -var each = require('std/each')
2 -var getCode = require('./getCode')
3 -var getRequireStatements = require('./getRequireStatements')
4 -var resolve = require('./resolve')
5 -
6 -module.exports = getDependencyLevels
7 -
8 -function getDependencyLevels(mainModulePath) {
9 - var leaves = []
10 - var root = []
11 - root.isRoot = true
12 - root.path = mainModulePath
13 - _buildDependencyTreeOf(root)
14 -
15 - var levels = []
16 - var seenPaths = {}
17 - _buildLevel(leaves)
18 -
19 - return levels
20 -
21 - // builds full dependency tree, noting every dependency of every node
22 - function _buildDependencyTreeOf(node) {
23 - var requireStatements = getRequireStatements(getCode(node.path))
24 - if (requireStatements.length == 0) {
25 - return leaves.push(node)
26 - }
27 - each(requireStatements, function(requireStatement) {
28 - var childNode = []
29 - childNode.path = resolve.requireStatement(requireStatement, node.path)
30 - childNode.parent = node
31 - node.push(childNode)
32 - _buildDependencyTreeOf(childNode)
33 - })
34 - node.waitingForNumChildren = node.length
35 - }
36 -
37 - // builds a list of dependency levels, where nodes in each level is dependent only on nodes in levels below it
38 - // the dependency levels allow for parallel loading of every file in any given level
39 - function _buildLevel(nodes) {
40 - var level = []
41 - levels.push(level)
42 - var parents = []
43 - each(nodes, function(node) {
44 - if (!seenPaths[node.path]) {
45 - seenPaths[node.path] = true
46 - level.push(node.path)
47 - }
48 - if (node.isRoot) { return }
49 -
50 - node.parent.waitingForNumChildren -= 1
51 -
52 - if (node.parent.waitingForNumChildren == 0) {
53 - parents.push(node.parent)
54 - }
55 - })
56 - if (!parents.length) { return }
57 - _buildLevel(parents)
58 - }
59 -}
1 -module.exports = getRequireStatements
2 -
3 -var _globalRequireRegex = /require\s*\(['"][\w\/\.-]*['"]\)/g
4 -function getRequireStatements(code) {
5 - return code.match(_globalRequireRegex) || []
6 -}
1 -var path = require('path')
2 -var fs = require('fs')
3 -var existsSync = fs.existsSync || path.existsSync
4 -
5 -var _nodePaths = (process.env.NODE_PATH ? process.env.NODE_PATH.split(':') : [])
6 -_nodePaths.push(process.cwd())
7 -
8 -module.exports = {
9 - path: resolvePath,
10 - _nodePaths:_nodePaths,
11 - requireStatement: resolveRequireStatement
12 -}
13 -
14 -function resolvePath(searchPath, pathBase) {
15 - if (searchPath[0] == '.') {
16 - // relative path, e.g. require("./foo")
17 - return _findModuleMain(path.resolve(pathBase, searchPath))
18 - }
19 -
20 - var searchParts = searchPath.split('/')
21 - var componentName = searchParts[searchParts.length - 1]
22 - var name = searchParts.shift()
23 - var rest = searchParts.join('/')
24 -
25 - // npm-style path, e.g. require("npm").
26 - // Climb parent directories in search for "node_modules"
27 - var modulePath = _findModuleMain(path.resolve(pathBase, 'node_modules', searchPath))
28 - if (modulePath) { return modulePath }
29 -
30 - if (pathBase != '/') {
31 - // not yet at the root - keep climbing!
32 - return resolvePath(searchPath, path.resolve(pathBase, '..'))
33 - }
34 -
35 - return ''
36 -}
37 -
38 -var _pathnameGroupingRegex = /require\s*\(['"]([\w\/\.-]*)['"]\)/
39 -function resolveRequireStatement(requireStmnt, currentPath) {
40 - var rawPath = requireStmnt.match(_pathnameGroupingRegex)[1]
41 - var resolvedPath = resolvePath(rawPath, path.dirname(currentPath))
42 -
43 - if (!resolvedPath && rawPath[0] != '.' && rawPath[0] != '/') {
44 - for (var i=0; i<_nodePaths.length; i++) {
45 - resolvedPath = _findModuleMain(path.resolve(_nodePaths[i], rawPath))
46 - if (resolvedPath) { break }
47 - }
48 - }
49 -
50 - if (!resolvedPath) { throw 'Could not resolve "'+rawPath+'" in "'+currentPath+'"' }
51 - return resolvedPath
52 -}
53 -
54 -function _findModuleMain(absModulePath, tryFileName) {
55 - var foundPath = ''
56 - function attempt(aPath) {
57 - if (foundPath) { return }
58 - if (existsSync(aPath)) { foundPath = aPath }
59 - }
60 - attempt(absModulePath + '.js')
61 - try {
62 - var package = JSON.parse(fs.readFileSync(absModulePath + '/package.json').toString())
63 - attempt(path.resolve(absModulePath, package.main+'.js'))
64 - attempt(path.resolve(absModulePath, package.main))
65 - } catch(e) {}
66 - attempt(absModulePath + '/index.js')
67 -
68 - if (tryFileName) { attempt(absModulePath + '/' + tryFileName + '.js') }
69 - return foundPath
70 -}
71 -
72 -
1 -{
2 - "_from": "require",
3 - "_id": "require@2.4.20",
4 - "_inBundle": false,
5 - "_integrity": "sha1-Zstrqqu2XeinHXk/XGX9GE83mLY=",
6 - "_location": "/require",
7 - "_phantomChildren": {},
8 - "_requested": {
9 - "type": "tag",
10 - "registry": true,
11 - "raw": "require",
12 - "name": "require",
13 - "escapedName": "require",
14 - "rawSpec": "",
15 - "saveSpec": null,
16 - "fetchSpec": "latest"
17 - },
18 - "_requiredBy": [
19 - "#USER",
20 - "/"
21 - ],
22 - "_resolved": "https://registry.npmjs.org/require/-/require-2.4.20.tgz",
23 - "_shasum": "66cb6baaabb65de8a71d793f5c65fd184f3798b6",
24 - "_spec": "require",
25 - "_where": "D:\\OneDrive\\University Life\\2018\\2nd semester\\OpenSourceSoftware\\KaKao_ChatBot",
26 - "author": {
27 - "name": "Marcus Westin",
28 - "email": "narcvs@gmail.com",
29 - "url": "http://marcuswest.in"
30 - },
31 - "bin": {
32 - "require": "./bin/require-command.js"
33 - },
34 - "bugs": {
35 - "url": "https://github.com/marcuswestin/require/issues"
36 - },
37 - "bundleDependencies": false,
38 - "dependencies": {
39 - "std": "0.1.40",
40 - "uglify-js": "2.3.0"
41 - },
42 - "deprecated": false,
43 - "description": "javascript module management! brings node's require statement to the browser",
44 - "devDependencies": {},
45 - "directories": {},
46 - "engines": {
47 - "browsers": "*",
48 - "node": "*"
49 - },
50 - "homepage": "https://github.com/marcuswestin/require",
51 - "main": "./require",
52 - "name": "require",
53 - "repository": {
54 - "type": "git",
55 - "url": "git://github.com/marcuswestin/require.git"
56 - },
57 - "scripts": {
58 - "start": "node server.js"
59 - },
60 - "version": "2.4.20"
61 -}
1 -var http = require('http')
2 -var fs = require('fs')
3 -var path = require('path')
4 -var extend = require('std/extend')
5 -var isObject = require('std/isObject')
6 -var map = require('std/map')
7 -var each = require('std/each')
8 -var getDependencyLevels = require('./lib/getDependencyLevels')
9 -var getRequireStatements = require('./lib/getRequireStatements')
10 -var getCode = require('./lib/getCode')
11 -var resolve = require('./lib/resolve')
12 -
13 -module.exports = {
14 - listen: listen,
15 - mount: mount,
16 - connect: connect,
17 - isRequireRequest: isRequireRequest,
18 - handleRequest: handleRequest
19 -}
20 -
21 -function listen(portOrOpts) {
22 - var _opts = (isObject(portOrOpts) ? portOrOpts : { port:portOrOpts || 1234 })
23 - opts.handleAllRequests = true
24 - mount(http.createServer(), _opts).listen(opts.port, opts.host)
25 -}
26 -
27 -function mount(server, _opts) {
28 - setOpts(_opts)
29 - return server.on('request', _checkRequest)
30 -}
31 -
32 -function connect(opts) {
33 - setOpts(opts)
34 - return _checkRequest
35 -}
36 -
37 -function _checkRequest(req, res, next) {
38 - if (isRequireRequest(req) || opts.handleAllRequests) {
39 - handleRequest(req, res)
40 - } else {
41 - next && next()
42 - }
43 -}
44 -
45 -function isRequireRequest(req) {
46 - return req.url.substr(1, opts.root.length) == opts.root
47 -}
48 -
49 -/* options
50 - *********/
51 -var opts = {
52 - path: process.cwd(),
53 - root: 'require',
54 - port: null,
55 - host: null
56 -}
57 -function setOpts(_opts) {
58 - opts = extend(_opts, opts)
59 - if (opts.path) {
60 - resolve._nodePaths.push(opts.path)
61 - }
62 -}
63 -function getUrlBase() {
64 - var basePort = (!opts.usePagePort && opts.port)
65 - if (opts.host && basePort) {
66 - return '//' + opts.host + ':' + basePort + '/' + opts.root + '/'
67 - } else {
68 - return '/' + opts.root + '/'
69 - }
70 -}
71 -
72 -/* request handlers
73 - ******************/
74 -function handleRequest(req, res) {
75 - var reqPath = _normalizeURL(req.url).substr(opts.root.length + 2)
76 - if (reqPath.match(/\.js$/)) {
77 - _handleModuleRequest(reqPath, res)
78 - } else {
79 - _handleMainModuleRequest(reqPath, req, res)
80 - }
81 -
82 - function _normalizeURL(url) {
83 - return url.replace(/\?.*/g, '').replace(/\/js$/, '.js')
84 - }
85 -}
86 -
87 -function _handleMainModuleRequest(reqPath, req, res) {
88 - var mainModulePath = resolve.path('./' + reqPath, opts.path)
89 - if (!mainModulePath) { return _sendError(res, 'Could not find module "'+reqPath+'" from "'+opts.path+'"') }
90 -
91 - try { var dependencyTree = getDependencyLevels(mainModulePath) }
92 - catch(err) { return _sendError(res, 'in getDependencyLevels: ' + (err.message || err)) }
93 -
94 - var userAgent = req.headers['user-agent']
95 - var isMobile = userAgent.match('iPad') || userAgent.match('iPod') || userAgent.match('iPhone') || userAgent.match('Android')
96 -
97 - var response = isMobile ? _getMobilePayload() : _getNormalPayload()
98 -
99 - res.writeHead(200, { 'Cache-Control':'no-cache', 'Expires':'Fri, 31 Dec 1998 12:00:00 GMT', 'Content-Length':response.length, 'Content-Type':'text/javascript' })
100 - res.end(response)
101 -
102 - function _getMobilePayload() {
103 - var result = ['__require__={loadNextModule:function(){},onModuleLoaded:function(){}}']
104 - each(dependencyTree, function(level) {
105 - each(level, function(dependency) {
106 - result.push(';(function(){ '+_getModuleCode(res, dependency)+' }());')
107 - })
108 - })
109 - return new Buffer(result.join('\n'))
110 - }
111 -
112 - function _getNormalPayload() {
113 - var paramsString = map([getUrlBase(), dependencyTree], JSON.stringify).join(',\n\t\t')
114 - return new Buffer('\t('+clientBootstrapFn.toString()+')(\n\t\t'+paramsString+'\n\t)')
115 -
116 - function clientBootstrapFn(urlBase, levels) {
117 - // This function gets sent to the client as toString
118 - __require__ = {
119 - loadNextLevel: loadNextLevel,
120 - onModuleLoaded: onModuleLoaded
121 - }
122 -
123 - var currentLevel = null
124 - loadNextLevel()
125 -
126 - function loadNextLevel() {
127 - if (!levels.length) { return } // all done!
128 - currentLevel = levels.shift()
129 - var head = document.getElementsByTagName('head')[0]
130 - for (var i=0; i<currentLevel.length; i++) {
131 - // var url = location.protocol + '//' + location.host + urlBase + currentLevel[i]
132 - var url = urlBase + currentLevel[i]
133 - head.appendChild(document.createElement('script')).src = url
134 - }
135 - }
136 -
137 - function onModuleLoaded() {
138 - currentLevel.pop()
139 - if (currentLevel.length == 0) {
140 - loadNextLevel()
141 - }
142 - }
143 - }
144 - }
145 -}
146 -
147 -function _asString(fn) { return fn.toString() }
148 -
149 -function _handleModuleRequest(reqPath, res) {
150 - try { var code = _getModuleCode(res, reqPath) }
151 - catch(err) { return _sendError(res, err.stack || err) }
152 -
153 - code += '\n\n'
154 -
155 - var buf = new Buffer(code)
156 - res.writeHead(200, { 'Cache-Control':'no-cache', 'Expires':'Fri, 31 Dec 1998 12:00:00 GMT', 'Content-Length':buf.length, 'Content-Type':'text/javascript' })
157 - res.end(buf)
158 -}
159 -
160 -function _getModuleCode(res, reqPath) {
161 - var code = getCode(reqPath)
162 - var requireStatements = getRequireStatements(code)
163 -
164 - try {
165 - each(requireStatements, function(requireStmnt) {
166 - var depPath = resolve.requireStatement(requireStmnt, reqPath)
167 - if (!depPath) { throw 'Could not resolve module' }
168 - code = code.replace(requireStmnt, '__require__["'+depPath+'"]')
169 - })
170 - } catch(e) {
171 - _sendError(res, e.message || e)
172 - }
173 -
174 - var _closureStart = ';(function(){'
175 - var _moduleDef = 'var module={exports:{}},exports=module.exports;/*FILE BEGIN*/ '
176 - var _closureEnd = '/*FILE END*/__require__["'+reqPath+'"]=module.exports; __require__.onModuleLoaded()\n})()'
177 - return _closureStart + _moduleDef + code + // all on the first line to make error line number reports correct
178 - '\n' + _closureEnd
179 -}
180 -
181 -function _sendError(res, msg) {
182 - if (msg) { msg = msg.replace(/\n/g, '\\n').replace(/"/g, '\\"') }
183 - res.writeHead(200)
184 - res.end('alert("error: ' + msg + '")')
185 -}
1 -language: node_js
2 -node_js:
3 - - 0.8
4 - - "0.10"
...\ No newline at end of file ...\ No newline at end of file
1 -# Change Log
2 -
3 -## 0.1.43
4 -
5 -* Performance improvements for `SourceMapGenerator` and `SourceNode`. See issue
6 - #148 for some discussion and issues #150, #151, and #152 for implementations.
7 -
8 -## 0.1.42
9 -
10 -* Fix an issue where `SourceNode`s from different versions of the source-map
11 - library couldn't be used in conjunction with each other. See issue #142.
12 -
13 -## 0.1.41
14 -
15 -* Fix a bug with getting the source content of relative sources with a "./"
16 - prefix. See issue #145 and [Bug 1090768](bugzil.la/1090768).
17 -
18 -* Add the `SourceMapConsumer.prototype.computeColumnSpans` method to compute the
19 - column span of each mapping.
20 -
21 -* Add the `SourceMapConsumer.prototype.allGeneratedPositionsFor` method to find
22 - all generated positions associated with a given original source and line.
23 -
24 -## 0.1.40
25 -
26 -* Performance improvements for parsing source maps in SourceMapConsumer.
27 -
28 -## 0.1.39
29 -
30 -* Fix a bug where setting a source's contents to null before any source content
31 - had been set before threw a TypeError. See issue #131.
32 -
33 -## 0.1.38
34 -
35 -* Fix a bug where finding relative paths from an empty path were creating
36 - absolute paths. See issue #129.
37 -
38 -## 0.1.37
39 -
40 -* Fix a bug where if the source root was an empty string, relative source paths
41 - would turn into absolute source paths. Issue #124.
42 -
43 -## 0.1.36
44 -
45 -* Allow the `names` mapping property to be an empty string. Issue #121.
46 -
47 -## 0.1.35
48 -
49 -* A third optional parameter was added to `SourceNode.fromStringWithSourceMap`
50 - to specify a path that relative sources in the second parameter should be
51 - relative to. Issue #105.
52 -
53 -* If no file property is given to a `SourceMapGenerator`, then the resulting
54 - source map will no longer have a `null` file property. The property will
55 - simply not exist. Issue #104.
56 -
57 -* Fixed a bug where consecutive newlines were ignored in `SourceNode`s.
58 - Issue #116.
59 -
60 -## 0.1.34
61 -
62 -* Make `SourceNode` work with windows style ("\r\n") newlines. Issue #103.
63 -
64 -* Fix bug involving source contents and the
65 - `SourceMapGenerator.prototype.applySourceMap`. Issue #100.
66 -
67 -## 0.1.33
68 -
69 -* Fix some edge cases surrounding path joining and URL resolution.
70 -
71 -* Add a third parameter for relative path to
72 - `SourceMapGenerator.prototype.applySourceMap`.
73 -
74 -* Fix issues with mappings and EOLs.
75 -
76 -## 0.1.32
77 -
78 -* Fixed a bug where SourceMapConsumer couldn't handle negative relative columns
79 - (issue 92).
80 -
81 -* Fixed test runner to actually report number of failed tests as its process
82 - exit code.
83 -
84 -* Fixed a typo when reporting bad mappings (issue 87).
85 -
86 -## 0.1.31
87 -
88 -* Delay parsing the mappings in SourceMapConsumer until queried for a source
89 - location.
90 -
91 -* Support Sass source maps (which at the time of writing deviate from the spec
92 - in small ways) in SourceMapConsumer.
93 -
94 -## 0.1.30
95 -
96 -* Do not join source root with a source, when the source is a data URI.
97 -
98 -* Extend the test runner to allow running single specific test files at a time.
99 -
100 -* Performance improvements in `SourceNode.prototype.walk` and
101 - `SourceMapConsumer.prototype.eachMapping`.
102 -
103 -* Source map browser builds will now work inside Workers.
104 -
105 -* Better error messages when attempting to add an invalid mapping to a
106 - `SourceMapGenerator`.
107 -
108 -## 0.1.29
109 -
110 -* Allow duplicate entries in the `names` and `sources` arrays of source maps
111 - (usually from TypeScript) we are parsing. Fixes github issue 72.
112 -
113 -## 0.1.28
114 -
115 -* Skip duplicate mappings when creating source maps from SourceNode; github
116 - issue 75.
117 -
118 -## 0.1.27
119 -
120 -* Don't throw an error when the `file` property is missing in SourceMapConsumer,
121 - we don't use it anyway.
122 -
123 -## 0.1.26
124 -
125 -* Fix SourceNode.fromStringWithSourceMap for empty maps. Fixes github issue 70.
126 -
127 -## 0.1.25
128 -
129 -* Make compatible with browserify
130 -
131 -## 0.1.24
132 -
133 -* Fix issue with absolute paths and `file://` URIs. See
134 - https://bugzilla.mozilla.org/show_bug.cgi?id=885597
135 -
136 -## 0.1.23
137 -
138 -* Fix issue with absolute paths and sourcesContent, github issue 64.
139 -
140 -## 0.1.22
141 -
142 -* Ignore duplicate mappings in SourceMapGenerator. Fixes github issue 21.
143 -
144 -## 0.1.21
145 -
146 -* Fixed handling of sources that start with a slash so that they are relative to
147 - the source root's host.
148 -
149 -## 0.1.20
150 -
151 -* Fixed github issue #43: absolute URLs aren't joined with the source root
152 - anymore.
153 -
154 -## 0.1.19
155 -
156 -* Using Travis CI to run tests.
157 -
158 -## 0.1.18
159 -
160 -* Fixed a bug in the handling of sourceRoot.
161 -
162 -## 0.1.17
163 -
164 -* Added SourceNode.fromStringWithSourceMap.
165 -
166 -## 0.1.16
167 -
168 -* Added missing documentation.
169 -
170 -* Fixed the generating of empty mappings in SourceNode.
171 -
172 -## 0.1.15
173 -
174 -* Added SourceMapGenerator.applySourceMap.
175 -
176 -## 0.1.14
177 -
178 -* The sourceRoot is now handled consistently.
179 -
180 -## 0.1.13
181 -
182 -* Added SourceMapGenerator.fromSourceMap.
183 -
184 -## 0.1.12
185 -
186 -* SourceNode now generates empty mappings too.
187 -
188 -## 0.1.11
189 -
190 -* Added name support to SourceNode.
191 -
192 -## 0.1.10
193 -
194 -* Added sourcesContent support to the customer and generator.
1 -
2 -Copyright (c) 2009-2011, Mozilla Foundation and contributors
3 -All rights reserved.
4 -
5 -Redistribution and use in source and binary forms, with or without
6 -modification, are permitted provided that the following conditions are met:
7 -
8 -* Redistributions of source code must retain the above copyright notice, this
9 - list of conditions and the following disclaimer.
10 -
11 -* Redistributions in binary form must reproduce the above copyright notice,
12 - this list of conditions and the following disclaimer in the documentation
13 - and/or other materials provided with the distribution.
14 -
15 -* Neither the names of the Mozilla Foundation nor the names of project
16 - contributors may be used to endorse or promote products derived from this
17 - software without specific prior written permission.
18 -
19 -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23 -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1 -/* -*- Mode: js; js-indent-level: 2; -*- */
2 -/*
3 - * Copyright 2011 Mozilla Foundation and contributors
4 - * Licensed under the New BSD license. See LICENSE or:
5 - * http://opensource.org/licenses/BSD-3-Clause
6 - */
7 -var path = require('path');
8 -var fs = require('fs');
9 -var copy = require('dryice').copy;
10 -
11 -function removeAmdefine(src) {
12 - src = String(src).replace(
13 - /if\s*\(typeof\s*define\s*!==\s*'function'\)\s*{\s*var\s*define\s*=\s*require\('amdefine'\)\(module,\s*require\);\s*}\s*/g,
14 - '');
15 - src = src.replace(
16 - /\b(define\(.*)('amdefine',?)/gm,
17 - '$1');
18 - return src;
19 -}
20 -removeAmdefine.onRead = true;
21 -
22 -function makeNonRelative(src) {
23 - return src
24 - .replace(/require\('.\//g, 'require(\'source-map/')
25 - .replace(/\.\.\/\.\.\/lib\//g, '');
26 -}
27 -makeNonRelative.onRead = true;
28 -
29 -function buildBrowser() {
30 - console.log('\nCreating dist/source-map.js');
31 -
32 - var project = copy.createCommonJsProject({
33 - roots: [ path.join(__dirname, 'lib') ]
34 - });
35 -
36 - copy({
37 - source: [
38 - 'build/mini-require.js',
39 - {
40 - project: project,
41 - require: [ 'source-map/source-map-generator',
42 - 'source-map/source-map-consumer',
43 - 'source-map/source-node']
44 - },
45 - 'build/suffix-browser.js'
46 - ],
47 - filter: [
48 - copy.filter.moduleDefines,
49 - removeAmdefine
50 - ],
51 - dest: 'dist/source-map.js'
52 - });
53 -}
54 -
55 -function buildBrowserMin() {
56 - console.log('\nCreating dist/source-map.min.js');
57 -
58 - copy({
59 - source: 'dist/source-map.js',
60 - filter: copy.filter.uglifyjs,
61 - dest: 'dist/source-map.min.js'
62 - });
63 -}
64 -
65 -function buildFirefox() {
66 - console.log('\nCreating dist/SourceMap.jsm');
67 -
68 - var project = copy.createCommonJsProject({
69 - roots: [ path.join(__dirname, 'lib') ]
70 - });
71 -
72 - copy({
73 - source: [
74 - 'build/prefix-source-map.jsm',
75 - {
76 - project: project,
77 - require: [ 'source-map/source-map-consumer',
78 - 'source-map/source-map-generator',
79 - 'source-map/source-node' ]
80 - },
81 - 'build/suffix-source-map.jsm'
82 - ],
83 - filter: [
84 - copy.filter.moduleDefines,
85 - removeAmdefine,
86 - makeNonRelative
87 - ],
88 - dest: 'dist/SourceMap.jsm'
89 - });
90 -
91 - // Create dist/test/Utils.jsm
92 - console.log('\nCreating dist/test/Utils.jsm');
93 -
94 - project = copy.createCommonJsProject({
95 - roots: [ __dirname, path.join(__dirname, 'lib') ]
96 - });
97 -
98 - copy({
99 - source: [
100 - 'build/prefix-utils.jsm',
101 - 'build/assert-shim.js',
102 - {
103 - project: project,
104 - require: [ 'test/source-map/util' ]
105 - },
106 - 'build/suffix-utils.jsm'
107 - ],
108 - filter: [
109 - copy.filter.moduleDefines,
110 - removeAmdefine,
111 - makeNonRelative
112 - ],
113 - dest: 'dist/test/Utils.jsm'
114 - });
115 -
116 - function isTestFile(f) {
117 - return /^test\-.*?\.js/.test(f);
118 - }
119 -
120 - var testFiles = fs.readdirSync(path.join(__dirname, 'test', 'source-map')).filter(isTestFile);
121 -
122 - testFiles.forEach(function (testFile) {
123 - console.log('\nCreating', path.join('dist', 'test', testFile.replace(/\-/g, '_')));
124 -
125 - copy({
126 - source: [
127 - 'build/test-prefix.js',
128 - path.join('test', 'source-map', testFile),
129 - 'build/test-suffix.js'
130 - ],
131 - filter: [
132 - removeAmdefine,
133 - makeNonRelative,
134 - function (input, source) {
135 - return input.replace('define(',
136 - 'define("'
137 - + path.join('test', 'source-map', testFile.replace(/\.js$/, ''))
138 - + '", ["require", "exports", "module"], ');
139 - },
140 - function (input, source) {
141 - return input.replace('{THIS_MODULE}', function () {
142 - return "test/source-map/" + testFile.replace(/\.js$/, '');
143 - });
144 - }
145 - ],
146 - dest: path.join('dist', 'test', testFile.replace(/\-/g, '_'))
147 - });
148 - });
149 -}
150 -
151 -function ensureDir(name) {
152 - var dirExists = false;
153 - try {
154 - dirExists = fs.statSync(name).isDirectory();
155 - } catch (err) {}
156 -
157 - if (!dirExists) {
158 - fs.mkdirSync(name, 0777);
159 - }
160 -}
161 -
162 -ensureDir("dist");
163 -ensureDir("dist/test");
164 -buildFirefox();
165 -buildBrowser();
166 -buildBrowserMin();
This diff is collapsed. Click to expand it.
1 -/* -*- Mode: js; js-indent-level: 2; -*- */
2 -/*
3 - * Copyright 2011 Mozilla Foundation and contributors
4 - * Licensed under the New BSD license. See LICENSE or:
5 - * http://opensource.org/licenses/BSD-3-Clause
6 - */
7 -define('test/source-map/assert', ['exports'], function (exports) {
8 -
9 - let do_throw = function (msg) {
10 - throw new Error(msg);
11 - };
12 -
13 - exports.init = function (throw_fn) {
14 - do_throw = throw_fn;
15 - };
16 -
17 - exports.doesNotThrow = function (fn) {
18 - try {
19 - fn();
20 - }
21 - catch (e) {
22 - do_throw(e.message);
23 - }
24 - };
25 -
26 - exports.equal = function (actual, expected, msg) {
27 - msg = msg || String(actual) + ' != ' + String(expected);
28 - if (actual != expected) {
29 - do_throw(msg);
30 - }
31 - };
32 -
33 - exports.ok = function (val, msg) {
34 - msg = msg || String(val) + ' is falsey';
35 - if (!Boolean(val)) {
36 - do_throw(msg);
37 - }
38 - };
39 -
40 - exports.strictEqual = function (actual, expected, msg) {
41 - msg = msg || String(actual) + ' !== ' + String(expected);
42 - if (actual !== expected) {
43 - do_throw(msg);
44 - }
45 - };
46 -
47 - exports.throws = function (fn) {
48 - try {
49 - fn();
50 - do_throw('Expected an error to be thrown, but it wasn\'t.');
51 - }
52 - catch (e) {
53 - }
54 - };
55 -
56 -});
1 -/* -*- Mode: js; js-indent-level: 2; -*- */
2 -/*
3 - * Copyright 2011 Mozilla Foundation and contributors
4 - * Licensed under the New BSD license. See LICENSE or:
5 - * http://opensource.org/licenses/BSD-3-Clause
6 - */
7 -
8 -/**
9 - * Define a module along with a payload.
10 - * @param {string} moduleName Name for the payload
11 - * @param {ignored} deps Ignored. For compatibility with CommonJS AMD Spec
12 - * @param {function} payload Function with (require, exports, module) params
13 - */
14 -function define(moduleName, deps, payload) {
15 - if (typeof moduleName != "string") {
16 - throw new TypeError('Expected string, got: ' + moduleName);
17 - }
18 -
19 - if (arguments.length == 2) {
20 - payload = deps;
21 - }
22 -
23 - if (moduleName in define.modules) {
24 - throw new Error("Module already defined: " + moduleName);
25 - }
26 - define.modules[moduleName] = payload;
27 -};
28 -
29 -/**
30 - * The global store of un-instantiated modules
31 - */
32 -define.modules = {};
33 -
34 -
35 -/**
36 - * We invoke require() in the context of a Domain so we can have multiple
37 - * sets of modules running separate from each other.
38 - * This contrasts with JSMs which are singletons, Domains allows us to
39 - * optionally load a CommonJS module twice with separate data each time.
40 - * Perhaps you want 2 command lines with a different set of commands in each,
41 - * for example.
42 - */
43 -function Domain() {
44 - this.modules = {};
45 - this._currentModule = null;
46 -}
47 -
48 -(function () {
49 -
50 - /**
51 - * Lookup module names and resolve them by calling the definition function if
52 - * needed.
53 - * There are 2 ways to call this, either with an array of dependencies and a
54 - * callback to call when the dependencies are found (which can happen
55 - * asynchronously in an in-page context) or with a single string an no callback
56 - * where the dependency is resolved synchronously and returned.
57 - * The API is designed to be compatible with the CommonJS AMD spec and
58 - * RequireJS.
59 - * @param {string[]|string} deps A name, or names for the payload
60 - * @param {function|undefined} callback Function to call when the dependencies
61 - * are resolved
62 - * @return {undefined|object} The module required or undefined for
63 - * array/callback method
64 - */
65 - Domain.prototype.require = function(deps, callback) {
66 - if (Array.isArray(deps)) {
67 - var params = deps.map(function(dep) {
68 - return this.lookup(dep);
69 - }, this);
70 - if (callback) {
71 - callback.apply(null, params);
72 - }
73 - return undefined;
74 - }
75 - else {
76 - return this.lookup(deps);
77 - }
78 - };
79 -
80 - function normalize(path) {
81 - var bits = path.split('/');
82 - var i = 1;
83 - while (i < bits.length) {
84 - if (bits[i] === '..') {
85 - bits.splice(i-1, 1);
86 - } else if (bits[i] === '.') {
87 - bits.splice(i, 1);
88 - } else {
89 - i++;
90 - }
91 - }
92 - return bits.join('/');
93 - }
94 -
95 - function join(a, b) {
96 - a = a.trim();
97 - b = b.trim();
98 - if (/^\//.test(b)) {
99 - return b;
100 - } else {
101 - return a.replace(/\/*$/, '/') + b;
102 - }
103 - }
104 -
105 - function dirname(path) {
106 - var bits = path.split('/');
107 - bits.pop();
108 - return bits.join('/');
109 - }
110 -
111 - /**
112 - * Lookup module names and resolve them by calling the definition function if
113 - * needed.
114 - * @param {string} moduleName A name for the payload to lookup
115 - * @return {object} The module specified by aModuleName or null if not found.
116 - */
117 - Domain.prototype.lookup = function(moduleName) {
118 - if (/^\./.test(moduleName)) {
119 - moduleName = normalize(join(dirname(this._currentModule), moduleName));
120 - }
121 -
122 - if (moduleName in this.modules) {
123 - var module = this.modules[moduleName];
124 - return module;
125 - }
126 -
127 - if (!(moduleName in define.modules)) {
128 - throw new Error("Module not defined: " + moduleName);
129 - }
130 -
131 - var module = define.modules[moduleName];
132 -
133 - if (typeof module == "function") {
134 - var exports = {};
135 - var previousModule = this._currentModule;
136 - this._currentModule = moduleName;
137 - module(this.require.bind(this), exports, { id: moduleName, uri: "" });
138 - this._currentModule = previousModule;
139 - module = exports;
140 - }
141 -
142 - // cache the resulting module object for next time
143 - this.modules[moduleName] = module;
144 -
145 - return module;
146 - };
147 -
148 -}());
149 -
150 -define.Domain = Domain;
151 -define.globalDomain = new Domain();
152 -var require = define.globalDomain.require.bind(define.globalDomain);
1 -/* -*- Mode: js; js-indent-level: 2; -*- */
2 -/*
3 - * Copyright 2011 Mozilla Foundation and contributors
4 - * Licensed under the New BSD license. See LICENSE or:
5 - * http://opensource.org/licenses/BSD-3-Clause
6 - */
7 -
8 -/*
9 - * WARNING!
10 - *
11 - * Do not edit this file directly, it is built from the sources at
12 - * https://github.com/mozilla/source-map/
13 - */
14 -
15 -///////////////////////////////////////////////////////////////////////////////
16 -
17 -
18 -this.EXPORTED_SYMBOLS = [ "SourceMapConsumer", "SourceMapGenerator", "SourceNode" ];
19 -
20 -Components.utils.import('resource://gre/modules/devtools/Require.jsm');
1 -/* -*- Mode: js; js-indent-level: 2; -*- */
2 -/*
3 - * Copyright 2011 Mozilla Foundation and contributors
4 - * Licensed under the New BSD license. See LICENSE or:
5 - * http://opensource.org/licenses/BSD-3-Clause
6 - */
7 -
8 -/*
9 - * WARNING!
10 - *
11 - * Do not edit this file directly, it is built from the sources at
12 - * https://github.com/mozilla/source-map/
13 - */
14 -
15 -Components.utils.import('resource://gre/modules/devtools/Require.jsm');
16 -Components.utils.import('resource://gre/modules/devtools/SourceMap.jsm');
17 -
18 -this.EXPORTED_SYMBOLS = [ "define", "runSourceMapTests" ];
1 -/* -*- Mode: js; js-indent-level: 2; -*- */
2 -///////////////////////////////////////////////////////////////////////////////
3 -
4 -this.sourceMap = {
5 - SourceMapConsumer: require('source-map/source-map-consumer').SourceMapConsumer,
6 - SourceMapGenerator: require('source-map/source-map-generator').SourceMapGenerator,
7 - SourceNode: require('source-map/source-node').SourceNode
8 -};
1 -/* -*- Mode: js; js-indent-level: 2; -*- */
2 -///////////////////////////////////////////////////////////////////////////////
3 -
4 -this.SourceMapConsumer = require('source-map/source-map-consumer').SourceMapConsumer;
5 -this.SourceMapGenerator = require('source-map/source-map-generator').SourceMapGenerator;
6 -this.SourceNode = require('source-map/source-node').SourceNode;
1 -/* -*- Mode: js; js-indent-level: 2; -*- */
2 -/*
3 - * Copyright 2011 Mozilla Foundation and contributors
4 - * Licensed under the New BSD license. See LICENSE or:
5 - * http://opensource.org/licenses/BSD-3-Clause
6 - */
7 -function runSourceMapTests(modName, do_throw) {
8 - let mod = require(modName);
9 - let assert = require('test/source-map/assert');
10 - let util = require('test/source-map/util');
11 -
12 - assert.init(do_throw);
13 -
14 - for (let k in mod) {
15 - if (/^test/.test(k)) {
16 - mod[k](assert, util);
17 - }
18 - }
19 -
20 -}
21 -this.runSourceMapTests = runSourceMapTests;
1 -/*
2 - * WARNING!
3 - *
4 - * Do not edit this file directly, it is built from the sources at
5 - * https://github.com/mozilla/source-map/
6 - */
7 -
8 -Components.utils.import('resource://test/Utils.jsm');
1 -function run_test() {
2 - runSourceMapTests('{THIS_MODULE}', do_throw);
3 -}
1 -/*
2 - * Copyright 2009-2011 Mozilla Foundation and contributors
3 - * Licensed under the New BSD license. See LICENSE.txt or:
4 - * http://opensource.org/licenses/BSD-3-Clause
5 - */
6 -exports.SourceMapGenerator = require('./source-map/source-map-generator').SourceMapGenerator;
7 -exports.SourceMapConsumer = require('./source-map/source-map-consumer').SourceMapConsumer;
8 -exports.SourceNode = require('./source-map/source-node').SourceNode;
1 -/* -*- Mode: js; js-indent-level: 2; -*- */
2 -/*
3 - * Copyright 2011 Mozilla Foundation and contributors
4 - * Licensed under the New BSD license. See LICENSE or:
5 - * http://opensource.org/licenses/BSD-3-Clause
6 - */
7 -if (typeof define !== 'function') {
8 - var define = require('amdefine')(module, require);
9 -}
10 -define(function (require, exports, module) {
11 -
12 - var util = require('./util');
13 -
14 - /**
15 - * A data structure which is a combination of an array and a set. Adding a new
16 - * member is O(1), testing for membership is O(1), and finding the index of an
17 - * element is O(1). Removing elements from the set is not supported. Only
18 - * strings are supported for membership.
19 - */
20 - function ArraySet() {
21 - this._array = [];
22 - this._set = {};
23 - }
24 -
25 - /**
26 - * Static method for creating ArraySet instances from an existing array.
27 - */
28 - ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
29 - var set = new ArraySet();
30 - for (var i = 0, len = aArray.length; i < len; i++) {
31 - set.add(aArray[i], aAllowDuplicates);
32 - }
33 - return set;
34 - };
35 -
36 - /**
37 - * Add the given string to this set.
38 - *
39 - * @param String aStr
40 - */
41 - ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
42 - var isDuplicate = this.has(aStr);
43 - var idx = this._array.length;
44 - if (!isDuplicate || aAllowDuplicates) {
45 - this._array.push(aStr);
46 - }
47 - if (!isDuplicate) {
48 - this._set[util.toSetString(aStr)] = idx;
49 - }
50 - };
51 -
52 - /**
53 - * Is the given string a member of this set?
54 - *
55 - * @param String aStr
56 - */
57 - ArraySet.prototype.has = function ArraySet_has(aStr) {
58 - return Object.prototype.hasOwnProperty.call(this._set,
59 - util.toSetString(aStr));
60 - };
61 -
62 - /**
63 - * What is the index of the given string in the array?
64 - *
65 - * @param String aStr
66 - */
67 - ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
68 - if (this.has(aStr)) {
69 - return this._set[util.toSetString(aStr)];
70 - }
71 - throw new Error('"' + aStr + '" is not in the set.');
72 - };
73 -
74 - /**
75 - * What is the element at the given index?
76 - *
77 - * @param Number aIdx
78 - */
79 - ArraySet.prototype.at = function ArraySet_at(aIdx) {
80 - if (aIdx >= 0 && aIdx < this._array.length) {
81 - return this._array[aIdx];
82 - }
83 - throw new Error('No element indexed by ' + aIdx);
84 - };
85 -
86 - /**
87 - * Returns the array representation of this set (which has the proper indices
88 - * indicated by indexOf). Note that this is a copy of the internal array used
89 - * for storing the members so that no one can mess with internal state.
90 - */
91 - ArraySet.prototype.toArray = function ArraySet_toArray() {
92 - return this._array.slice();
93 - };
94 -
95 - exports.ArraySet = ArraySet;
96 -
97 -});
1 -/* -*- Mode: js; js-indent-level: 2; -*- */
2 -/*
3 - * Copyright 2011 Mozilla Foundation and contributors
4 - * Licensed under the New BSD license. See LICENSE or:
5 - * http://opensource.org/licenses/BSD-3-Clause
6 - *
7 - * Based on the Base 64 VLQ implementation in Closure Compiler:
8 - * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
9 - *
10 - * Copyright 2011 The Closure Compiler Authors. All rights reserved.
11 - * Redistribution and use in source and binary forms, with or without
12 - * modification, are permitted provided that the following conditions are
13 - * met:
14 - *
15 - * * Redistributions of source code must retain the above copyright
16 - * notice, this list of conditions and the following disclaimer.
17 - * * Redistributions in binary form must reproduce the above
18 - * copyright notice, this list of conditions and the following
19 - * disclaimer in the documentation and/or other materials provided
20 - * with the distribution.
21 - * * Neither the name of Google Inc. nor the names of its
22 - * contributors may be used to endorse or promote products derived
23 - * from this software without specific prior written permission.
24 - *
25 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 - */
37 -if (typeof define !== 'function') {
38 - var define = require('amdefine')(module, require);
39 -}
40 -define(function (require, exports, module) {
41 -
42 - var base64 = require('./base64');
43 -
44 - // A single base 64 digit can contain 6 bits of data. For the base 64 variable
45 - // length quantities we use in the source map spec, the first bit is the sign,
46 - // the next four bits are the actual value, and the 6th bit is the
47 - // continuation bit. The continuation bit tells us whether there are more
48 - // digits in this value following this digit.
49 - //
50 - // Continuation
51 - // | Sign
52 - // | |
53 - // V V
54 - // 101011
55 -
56 - var VLQ_BASE_SHIFT = 5;
57 -
58 - // binary: 100000
59 - var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
60 -
61 - // binary: 011111
62 - var VLQ_BASE_MASK = VLQ_BASE - 1;
63 -
64 - // binary: 100000
65 - var VLQ_CONTINUATION_BIT = VLQ_BASE;
66 -
67 - /**
68 - * Converts from a two-complement value to a value where the sign bit is
69 - * placed in the least significant bit. For example, as decimals:
70 - * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
71 - * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
72 - */
73 - function toVLQSigned(aValue) {
74 - return aValue < 0
75 - ? ((-aValue) << 1) + 1
76 - : (aValue << 1) + 0;
77 - }
78 -
79 - /**
80 - * Converts to a two-complement value from a value where the sign bit is
81 - * placed in the least significant bit. For example, as decimals:
82 - * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
83 - * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
84 - */
85 - function fromVLQSigned(aValue) {
86 - var isNegative = (aValue & 1) === 1;
87 - var shifted = aValue >> 1;
88 - return isNegative
89 - ? -shifted
90 - : shifted;
91 - }
92 -
93 - /**
94 - * Returns the base 64 VLQ encoded value.
95 - */
96 - exports.encode = function base64VLQ_encode(aValue) {
97 - var encoded = "";
98 - var digit;
99 -
100 - var vlq = toVLQSigned(aValue);
101 -
102 - do {
103 - digit = vlq & VLQ_BASE_MASK;
104 - vlq >>>= VLQ_BASE_SHIFT;
105 - if (vlq > 0) {
106 - // There are still more digits in this value, so we must make sure the
107 - // continuation bit is marked.
108 - digit |= VLQ_CONTINUATION_BIT;
109 - }
110 - encoded += base64.encode(digit);
111 - } while (vlq > 0);
112 -
113 - return encoded;
114 - };
115 -
116 - /**
117 - * Decodes the next base 64 VLQ value from the given string and returns the
118 - * value and the rest of the string via the out parameter.
119 - */
120 - exports.decode = function base64VLQ_decode(aStr, aOutParam) {
121 - var i = 0;
122 - var strLen = aStr.length;
123 - var result = 0;
124 - var shift = 0;
125 - var continuation, digit;
126 -
127 - do {
128 - if (i >= strLen) {
129 - throw new Error("Expected more digits in base 64 VLQ value.");
130 - }
131 - digit = base64.decode(aStr.charAt(i++));
132 - continuation = !!(digit & VLQ_CONTINUATION_BIT);
133 - digit &= VLQ_BASE_MASK;
134 - result = result + (digit << shift);
135 - shift += VLQ_BASE_SHIFT;
136 - } while (continuation);
137 -
138 - aOutParam.value = fromVLQSigned(result);
139 - aOutParam.rest = aStr.slice(i);
140 - };
141 -
142 -});
1 -/* -*- Mode: js; js-indent-level: 2; -*- */
2 -/*
3 - * Copyright 2011 Mozilla Foundation and contributors
4 - * Licensed under the New BSD license. See LICENSE or:
5 - * http://opensource.org/licenses/BSD-3-Clause
6 - */
7 -if (typeof define !== 'function') {
8 - var define = require('amdefine')(module, require);
9 -}
10 -define(function (require, exports, module) {
11 -
12 - var charToIntMap = {};
13 - var intToCharMap = {};
14 -
15 - 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
16 - .split('')
17 - .forEach(function (ch, index) {
18 - charToIntMap[ch] = index;
19 - intToCharMap[index] = ch;
20 - });
21 -
22 - /**
23 - * Encode an integer in the range of 0 to 63 to a single base 64 digit.
24 - */
25 - exports.encode = function base64_encode(aNumber) {
26 - if (aNumber in intToCharMap) {
27 - return intToCharMap[aNumber];
28 - }
29 - throw new TypeError("Must be between 0 and 63: " + aNumber);
30 - };
31 -
32 - /**
33 - * Decode a single base 64 digit to an integer.
34 - */
35 - exports.decode = function base64_decode(aChar) {
36 - if (aChar in charToIntMap) {
37 - return charToIntMap[aChar];
38 - }
39 - throw new TypeError("Not a valid base 64 digit: " + aChar);
40 - };
41 -
42 -});
1 -/* -*- Mode: js; js-indent-level: 2; -*- */
2 -/*
3 - * Copyright 2011 Mozilla Foundation and contributors
4 - * Licensed under the New BSD license. See LICENSE or:
5 - * http://opensource.org/licenses/BSD-3-Clause
6 - */
7 -if (typeof define !== 'function') {
8 - var define = require('amdefine')(module, require);
9 -}
10 -define(function (require, exports, module) {
11 -
12 - /**
13 - * Recursive implementation of binary search.
14 - *
15 - * @param aLow Indices here and lower do not contain the needle.
16 - * @param aHigh Indices here and higher do not contain the needle.
17 - * @param aNeedle The element being searched for.
18 - * @param aHaystack The non-empty array being searched.
19 - * @param aCompare Function which takes two elements and returns -1, 0, or 1.
20 - */
21 - function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare) {
22 - // This function terminates when one of the following is true:
23 - //
24 - // 1. We find the exact element we are looking for.
25 - //
26 - // 2. We did not find the exact element, but we can return the index of
27 - // the next closest element that is less than that element.
28 - //
29 - // 3. We did not find the exact element, and there is no next-closest
30 - // element which is less than the one we are searching for, so we
31 - // return -1.
32 - var mid = Math.floor((aHigh - aLow) / 2) + aLow;
33 - var cmp = aCompare(aNeedle, aHaystack[mid], true);
34 - if (cmp === 0) {
35 - // Found the element we are looking for.
36 - return mid;
37 - }
38 - else if (cmp > 0) {
39 - // aHaystack[mid] is greater than our needle.
40 - if (aHigh - mid > 1) {
41 - // The element is in the upper half.
42 - return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare);
43 - }
44 - // We did not find an exact match, return the next closest one
45 - // (termination case 2).
46 - return mid;
47 - }
48 - else {
49 - // aHaystack[mid] is less than our needle.
50 - if (mid - aLow > 1) {
51 - // The element is in the lower half.
52 - return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare);
53 - }
54 - // The exact needle element was not found in this haystack. Determine if
55 - // we are in termination case (2) or (3) and return the appropriate thing.
56 - return aLow < 0 ? -1 : aLow;
57 - }
58 - }
59 -
60 - /**
61 - * This is an implementation of binary search which will always try and return
62 - * the index of next lowest value checked if there is no exact hit. This is
63 - * because mappings between original and generated line/col pairs are single
64 - * points, and there is an implicit region between each of them, so a miss
65 - * just means that you aren't on the very start of a region.
66 - *
67 - * @param aNeedle The element you are looking for.
68 - * @param aHaystack The array that is being searched.
69 - * @param aCompare A function which takes the needle and an element in the
70 - * array and returns -1, 0, or 1 depending on whether the needle is less
71 - * than, equal to, or greater than the element, respectively.
72 - */
73 - exports.search = function search(aNeedle, aHaystack, aCompare) {
74 - if (aHaystack.length === 0) {
75 - return -1;
76 - }
77 - return recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, aCompare)
78 - };
79 -
80 -});
1 -/* -*- Mode: js; js-indent-level: 2; -*- */
2 -/*
3 - * Copyright 2014 Mozilla Foundation and contributors
4 - * Licensed under the New BSD license. See LICENSE or:
5 - * http://opensource.org/licenses/BSD-3-Clause
6 - */
7 -if (typeof define !== 'function') {
8 - var define = require('amdefine')(module, require);
9 -}
10 -define(function (require, exports, module) {
11 -
12 - var util = require('./util');
13 -
14 - /**
15 - * Determine whether mappingB is after mappingA with respect to generated
16 - * position.
17 - */
18 - function generatedPositionAfter(mappingA, mappingB) {
19 - // Optimized for most common case
20 - var lineA = mappingA.generatedLine;
21 - var lineB = mappingB.generatedLine;
22 - var columnA = mappingA.generatedColumn;
23 - var columnB = mappingB.generatedColumn;
24 - return lineB > lineA || lineB == lineA && columnB >= columnA ||
25 - util.compareByGeneratedPositions(mappingA, mappingB) <= 0;
26 - }
27 -
28 - /**
29 - * A data structure to provide a sorted view of accumulated mappings in a
30 - * performance conscious manner. It trades a neglibable overhead in general
31 - * case for a large speedup in case of mappings being added in order.
32 - */
33 - function MappingList() {
34 - this._array = [];
35 - this._sorted = true;
36 - // Serves as infimum
37 - this._last = {generatedLine: -1, generatedColumn: 0};
38 - }
39 -
40 - /**
41 - * Iterate through internal items. This method takes the same arguments that
42 - * `Array.prototype.forEach` takes.
43 - *
44 - * NOTE: The order of the mappings is NOT guaranteed.
45 - */
46 - MappingList.prototype.unsortedForEach =
47 - function MappingList_forEach(aCallback, aThisArg) {
48 - this._array.forEach(aCallback, aThisArg);
49 - };
50 -
51 - /**
52 - * Add the given source mapping.
53 - *
54 - * @param Object aMapping
55 - */
56 - MappingList.prototype.add = function MappingList_add(aMapping) {
57 - var mapping;
58 - if (generatedPositionAfter(this._last, aMapping)) {
59 - this._last = aMapping;
60 - this._array.push(aMapping);
61 - } else {
62 - this._sorted = false;
63 - this._array.push(aMapping);
64 - }
65 - };
66 -
67 - /**
68 - * Returns the flat, sorted array of mappings. The mappings are sorted by
69 - * generated position.
70 - *
71 - * WARNING: This method returns internal data without copying, for
72 - * performance. The return value must NOT be mutated, and should be treated as
73 - * an immutable borrow. If you want to take ownership, you must make your own
74 - * copy.
75 - */
76 - MappingList.prototype.toArray = function MappingList_toArray() {
77 - if (!this._sorted) {
78 - this._array.sort(util.compareByGeneratedPositions);
79 - this._sorted = true;
80 - }
81 - return this._array;
82 - };
83 -
84 - exports.MappingList = MappingList;
85 -
86 -});
This diff is collapsed. Click to expand it.
1 -/* -*- Mode: js; js-indent-level: 2; -*- */
2 -/*
3 - * Copyright 2011 Mozilla Foundation and contributors
4 - * Licensed under the New BSD license. See LICENSE or:
5 - * http://opensource.org/licenses/BSD-3-Clause
6 - */
7 -if (typeof define !== 'function') {
8 - var define = require('amdefine')(module, require);
9 -}
10 -define(function (require, exports, module) {
11 -
12 - /**
13 - * This is a helper function for getting values from parameter/options
14 - * objects.
15 - *
16 - * @param args The object we are extracting values from
17 - * @param name The name of the property we are getting.
18 - * @param defaultValue An optional value to return if the property is missing
19 - * from the object. If this is not specified and the property is missing, an
20 - * error will be thrown.
21 - */
22 - function getArg(aArgs, aName, aDefaultValue) {
23 - if (aName in aArgs) {
24 - return aArgs[aName];
25 - } else if (arguments.length === 3) {
26 - return aDefaultValue;
27 - } else {
28 - throw new Error('"' + aName + '" is a required argument.');
29 - }
30 - }
31 - exports.getArg = getArg;
32 -
33 - var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/;
34 - var dataUrlRegexp = /^data:.+\,.+$/;
35 -
36 - function urlParse(aUrl) {
37 - var match = aUrl.match(urlRegexp);
38 - if (!match) {
39 - return null;
40 - }
41 - return {
42 - scheme: match[1],
43 - auth: match[2],
44 - host: match[3],
45 - port: match[4],
46 - path: match[5]
47 - };
48 - }
49 - exports.urlParse = urlParse;
50 -
51 - function urlGenerate(aParsedUrl) {
52 - var url = '';
53 - if (aParsedUrl.scheme) {
54 - url += aParsedUrl.scheme + ':';
55 - }
56 - url += '//';
57 - if (aParsedUrl.auth) {
58 - url += aParsedUrl.auth + '@';
59 - }
60 - if (aParsedUrl.host) {
61 - url += aParsedUrl.host;
62 - }
63 - if (aParsedUrl.port) {
64 - url += ":" + aParsedUrl.port
65 - }
66 - if (aParsedUrl.path) {
67 - url += aParsedUrl.path;
68 - }
69 - return url;
70 - }
71 - exports.urlGenerate = urlGenerate;
72 -
73 - /**
74 - * Normalizes a path, or the path portion of a URL:
75 - *
76 - * - Replaces consequtive slashes with one slash.
77 - * - Removes unnecessary '.' parts.
78 - * - Removes unnecessary '<dir>/..' parts.
79 - *
80 - * Based on code in the Node.js 'path' core module.
81 - *
82 - * @param aPath The path or url to normalize.
83 - */
84 - function normalize(aPath) {
85 - var path = aPath;
86 - var url = urlParse(aPath);
87 - if (url) {
88 - if (!url.path) {
89 - return aPath;
90 - }
91 - path = url.path;
92 - }
93 - var isAbsolute = (path.charAt(0) === '/');
94 -
95 - var parts = path.split(/\/+/);
96 - for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
97 - part = parts[i];
98 - if (part === '.') {
99 - parts.splice(i, 1);
100 - } else if (part === '..') {
101 - up++;
102 - } else if (up > 0) {
103 - if (part === '') {
104 - // The first part is blank if the path is absolute. Trying to go
105 - // above the root is a no-op. Therefore we can remove all '..' parts
106 - // directly after the root.
107 - parts.splice(i + 1, up);
108 - up = 0;
109 - } else {
110 - parts.splice(i, 2);
111 - up--;
112 - }
113 - }
114 - }
115 - path = parts.join('/');
116 -
117 - if (path === '') {
118 - path = isAbsolute ? '/' : '.';
119 - }
120 -
121 - if (url) {
122 - url.path = path;
123 - return urlGenerate(url);
124 - }
125 - return path;
126 - }
127 - exports.normalize = normalize;
128 -
129 - /**
130 - * Joins two paths/URLs.
131 - *
132 - * @param aRoot The root path or URL.
133 - * @param aPath The path or URL to be joined with the root.
134 - *
135 - * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
136 - * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
137 - * first.
138 - * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
139 - * is updated with the result and aRoot is returned. Otherwise the result
140 - * is returned.
141 - * - If aPath is absolute, the result is aPath.
142 - * - Otherwise the two paths are joined with a slash.
143 - * - Joining for example 'http://' and 'www.example.com' is also supported.
144 - */
145 - function join(aRoot, aPath) {
146 - if (aRoot === "") {
147 - aRoot = ".";
148 - }
149 - if (aPath === "") {
150 - aPath = ".";
151 - }
152 - var aPathUrl = urlParse(aPath);
153 - var aRootUrl = urlParse(aRoot);
154 - if (aRootUrl) {
155 - aRoot = aRootUrl.path || '/';
156 - }
157 -
158 - // `join(foo, '//www.example.org')`
159 - if (aPathUrl && !aPathUrl.scheme) {
160 - if (aRootUrl) {
161 - aPathUrl.scheme = aRootUrl.scheme;
162 - }
163 - return urlGenerate(aPathUrl);
164 - }
165 -
166 - if (aPathUrl || aPath.match(dataUrlRegexp)) {
167 - return aPath;
168 - }
169 -
170 - // `join('http://', 'www.example.com')`
171 - if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
172 - aRootUrl.host = aPath;
173 - return urlGenerate(aRootUrl);
174 - }
175 -
176 - var joined = aPath.charAt(0) === '/'
177 - ? aPath
178 - : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
179 -
180 - if (aRootUrl) {
181 - aRootUrl.path = joined;
182 - return urlGenerate(aRootUrl);
183 - }
184 - return joined;
185 - }
186 - exports.join = join;
187 -
188 - /**
189 - * Make a path relative to a URL or another path.
190 - *
191 - * @param aRoot The root path or URL.
192 - * @param aPath The path or URL to be made relative to aRoot.
193 - */
194 - function relative(aRoot, aPath) {
195 - if (aRoot === "") {
196 - aRoot = ".";
197 - }
198 -
199 - aRoot = aRoot.replace(/\/$/, '');
200 -
201 - // XXX: It is possible to remove this block, and the tests still pass!
202 - var url = urlParse(aRoot);
203 - if (aPath.charAt(0) == "/" && url && url.path == "/") {
204 - return aPath.slice(1);
205 - }
206 -
207 - return aPath.indexOf(aRoot + '/') === 0
208 - ? aPath.substr(aRoot.length + 1)
209 - : aPath;
210 - }
211 - exports.relative = relative;
212 -
213 - /**
214 - * Because behavior goes wacky when you set `__proto__` on objects, we
215 - * have to prefix all the strings in our set with an arbitrary character.
216 - *
217 - * See https://github.com/mozilla/source-map/pull/31 and
218 - * https://github.com/mozilla/source-map/issues/30
219 - *
220 - * @param String aStr
221 - */
222 - function toSetString(aStr) {
223 - return '$' + aStr;
224 - }
225 - exports.toSetString = toSetString;
226 -
227 - function fromSetString(aStr) {
228 - return aStr.substr(1);
229 - }
230 - exports.fromSetString = fromSetString;
231 -
232 - function strcmp(aStr1, aStr2) {
233 - var s1 = aStr1 || "";
234 - var s2 = aStr2 || "";
235 - return (s1 > s2) - (s1 < s2);
236 - }
237 -
238 - /**
239 - * Comparator between two mappings where the original positions are compared.
240 - *
241 - * Optionally pass in `true` as `onlyCompareGenerated` to consider two
242 - * mappings with the same original source/line/column, but different generated
243 - * line and column the same. Useful when searching for a mapping with a
244 - * stubbed out mapping.
245 - */
246 - function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
247 - var cmp;
248 -
249 - cmp = strcmp(mappingA.source, mappingB.source);
250 - if (cmp) {
251 - return cmp;
252 - }
253 -
254 - cmp = mappingA.originalLine - mappingB.originalLine;
255 - if (cmp) {
256 - return cmp;
257 - }
258 -
259 - cmp = mappingA.originalColumn - mappingB.originalColumn;
260 - if (cmp || onlyCompareOriginal) {
261 - return cmp;
262 - }
263 -
264 - cmp = strcmp(mappingA.name, mappingB.name);
265 - if (cmp) {
266 - return cmp;
267 - }
268 -
269 - cmp = mappingA.generatedLine - mappingB.generatedLine;
270 - if (cmp) {
271 - return cmp;
272 - }
273 -
274 - return mappingA.generatedColumn - mappingB.generatedColumn;
275 - };
276 - exports.compareByOriginalPositions = compareByOriginalPositions;
277 -
278 - /**
279 - * Comparator between two mappings where the generated positions are
280 - * compared.
281 - *
282 - * Optionally pass in `true` as `onlyCompareGenerated` to consider two
283 - * mappings with the same generated line and column, but different
284 - * source/name/original line and column the same. Useful when searching for a
285 - * mapping with a stubbed out mapping.
286 - */
287 - function compareByGeneratedPositions(mappingA, mappingB, onlyCompareGenerated) {
288 - var cmp;
289 -
290 - cmp = mappingA.generatedLine - mappingB.generatedLine;
291 - if (cmp) {
292 - return cmp;
293 - }
294 -
295 - cmp = mappingA.generatedColumn - mappingB.generatedColumn;
296 - if (cmp || onlyCompareGenerated) {
297 - return cmp;
298 - }
299 -
300 - cmp = strcmp(mappingA.source, mappingB.source);
301 - if (cmp) {
302 - return cmp;
303 - }
304 -
305 - cmp = mappingA.originalLine - mappingB.originalLine;
306 - if (cmp) {
307 - return cmp;
308 - }
309 -
310 - cmp = mappingA.originalColumn - mappingB.originalColumn;
311 - if (cmp) {
312 - return cmp;
313 - }
314 -
315 - return strcmp(mappingA.name, mappingB.name);
316 - };
317 - exports.compareByGeneratedPositions = compareByGeneratedPositions;
318 -
319 -});
1 -{
2 - "_from": "source-map@~0.1.7",
3 - "_id": "source-map@0.1.43",
4 - "_inBundle": false,
5 - "_integrity": "sha1-wkvBRspRfBRx9drL4lcbK3+eM0Y=",
6 - "_location": "/source-map",
7 - "_phantomChildren": {},
8 - "_requested": {
9 - "type": "range",
10 - "registry": true,
11 - "raw": "source-map@~0.1.7",
12 - "name": "source-map",
13 - "escapedName": "source-map",
14 - "rawSpec": "~0.1.7",
15 - "saveSpec": null,
16 - "fetchSpec": "~0.1.7"
17 - },
18 - "_requiredBy": [
19 - "/uglify-js"
20 - ],
21 - "_resolved": "http://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz",
22 - "_shasum": "c24bc146ca517c1471f5dacbe2571b2b7f9e3346",
23 - "_spec": "source-map@~0.1.7",
24 - "_where": "D:\\OneDrive\\University Life\\2018\\2nd semester\\OpenSourceSoftware\\KaKao_ChatBot\\node_modules\\uglify-js",
25 - "author": {
26 - "name": "Nick Fitzgerald",
27 - "email": "nfitzgerald@mozilla.com"
28 - },
29 - "bugs": {
30 - "url": "https://github.com/mozilla/source-map/issues"
31 - },
32 - "bundleDependencies": false,
33 - "contributors": [
34 - {
35 - "name": "Tobias Koppers",
36 - "email": "tobias.koppers@googlemail.com"
37 - },
38 - {
39 - "name": "Duncan Beevers",
40 - "email": "duncan@dweebd.com"
41 - },
42 - {
43 - "name": "Stephen Crane",
44 - "email": "scrane@mozilla.com"
45 - },
46 - {
47 - "name": "Ryan Seddon",
48 - "email": "seddon.ryan@gmail.com"
49 - },
50 - {
51 - "name": "Miles Elam",
52 - "email": "miles.elam@deem.com"
53 - },
54 - {
55 - "name": "Mihai Bazon",
56 - "email": "mihai.bazon@gmail.com"
57 - },
58 - {
59 - "name": "Michael Ficarra",
60 - "email": "github.public.email@michael.ficarra.me"
61 - },
62 - {
63 - "name": "Todd Wolfson",
64 - "email": "todd@twolfson.com"
65 - },
66 - {
67 - "name": "Alexander Solovyov",
68 - "email": "alexander@solovyov.net"
69 - },
70 - {
71 - "name": "Felix Gnass",
72 - "email": "fgnass@gmail.com"
73 - },
74 - {
75 - "name": "Conrad Irwin",
76 - "email": "conrad.irwin@gmail.com"
77 - },
78 - {
79 - "name": "usrbincc",
80 - "email": "usrbincc@yahoo.com"
81 - },
82 - {
83 - "name": "David Glasser",
84 - "email": "glasser@davidglasser.net"
85 - },
86 - {
87 - "name": "Chase Douglas",
88 - "email": "chase@newrelic.com"
89 - },
90 - {
91 - "name": "Evan Wallace",
92 - "email": "evan.exe@gmail.com"
93 - },
94 - {
95 - "name": "Heather Arthur",
96 - "email": "fayearthur@gmail.com"
97 - },
98 - {
99 - "name": "Hugh Kennedy",
100 - "email": "hughskennedy@gmail.com"
101 - },
102 - {
103 - "name": "David Glasser",
104 - "email": "glasser@davidglasser.net"
105 - },
106 - {
107 - "name": "Simon Lydell",
108 - "email": "simon.lydell@gmail.com"
109 - },
110 - {
111 - "name": "Jmeas Smith",
112 - "email": "jellyes2@gmail.com"
113 - },
114 - {
115 - "name": "Michael Z Goddard",
116 - "email": "mzgoddard@gmail.com"
117 - },
118 - {
119 - "name": "azu",
120 - "email": "azu@users.noreply.github.com"
121 - },
122 - {
123 - "name": "John Gozde",
124 - "email": "john@gozde.ca"
125 - },
126 - {
127 - "name": "Adam Kirkton",
128 - "email": "akirkton@truefitinnovation.com"
129 - },
130 - {
131 - "name": "Chris Montgomery",
132 - "email": "christopher.montgomery@dowjones.com"
133 - },
134 - {
135 - "name": "J. Ryan Stinnett",
136 - "email": "jryans@gmail.com"
137 - },
138 - {
139 - "name": "Jack Herrington",
140 - "email": "jherrington@walmartlabs.com"
141 - },
142 - {
143 - "name": "Chris Truter",
144 - "email": "jeffpalentine@gmail.com"
145 - },
146 - {
147 - "name": "Daniel Espeset",
148 - "email": "daniel@danielespeset.com"
149 - }
150 - ],
151 - "dependencies": {
152 - "amdefine": ">=0.0.4"
153 - },
154 - "deprecated": false,
155 - "description": "Generates and consumes source maps",
156 - "devDependencies": {
157 - "dryice": ">=0.4.8"
158 - },
159 - "directories": {
160 - "lib": "./lib"
161 - },
162 - "engines": {
163 - "node": ">=0.8.0"
164 - },
165 - "homepage": "https://github.com/mozilla/source-map",
166 - "licenses": [
167 - {
168 - "type": "BSD",
169 - "url": "http://opensource.org/licenses/BSD-3-Clause"
170 - }
171 - ],
172 - "main": "./lib/source-map.js",
173 - "name": "source-map",
174 - "repository": {
175 - "type": "git",
176 - "url": "git+ssh://git@github.com/mozilla/source-map.git"
177 - },
178 - "scripts": {
179 - "build": "node Makefile.dryice.js",
180 - "test": "node test/run-tests.js"
181 - },
182 - "version": "0.1.43"
183 -}
1 -#!/usr/bin/env node
2 -/* -*- Mode: js; js-indent-level: 2; -*- */
3 -/*
4 - * Copyright 2011 Mozilla Foundation and contributors
5 - * Licensed under the New BSD license. See LICENSE or:
6 - * http://opensource.org/licenses/BSD-3-Clause
7 - */
8 -var assert = require('assert');
9 -var fs = require('fs');
10 -var path = require('path');
11 -var util = require('./source-map/util');
12 -
13 -function run(tests) {
14 - var total = 0;
15 - var passed = 0;
16 -
17 - for (var i = 0; i < tests.length; i++) {
18 - for (var k in tests[i].testCase) {
19 - if (/^test/.test(k)) {
20 - total++;
21 - try {
22 - tests[i].testCase[k](assert, util);
23 - passed++;
24 - }
25 - catch (e) {
26 - console.log('FAILED ' + tests[i].name + ': ' + k + '!');
27 - console.log(e.stack);
28 - }
29 - }
30 - }
31 - }
32 -
33 - console.log('');
34 - console.log(passed + ' / ' + total + ' tests passed.');
35 - console.log('');
36 -
37 - return total - passed;
38 -}
39 -
40 -function isTestFile(f) {
41 - var testToRun = process.argv[2];
42 - return testToRun
43 - ? path.basename(testToRun) === f
44 - : /^test\-.*?\.js/.test(f);
45 -}
46 -
47 -function toModule(f) {
48 - return './source-map/' + f.replace(/\.js$/, '');
49 -}
50 -
51 -var requires = fs.readdirSync(path.join(__dirname, 'source-map'))
52 - .filter(isTestFile)
53 - .map(toModule);
54 -
55 -var code = run(requires.map(require).map(function (mod, i) {
56 - return {
57 - name: requires[i],
58 - testCase: mod
59 - };
60 -}));
61 -
62 -process.exit(code);
1 -/* -*- Mode: js; js-indent-level: 2; -*- */
2 -/*
3 - * Copyright 2012 Mozilla Foundation and contributors
4 - * Licensed under the New BSD license. See LICENSE or:
5 - * http://opensource.org/licenses/BSD-3-Clause
6 - */
7 -if (typeof define !== 'function') {
8 - var define = require('amdefine')(module, require);
9 -}
10 -define(function (require, exports, module) {
11 -
12 - var sourceMap;
13 - try {
14 - sourceMap = require('../../lib/source-map');
15 - } catch (e) {
16 - sourceMap = {};
17 - Components.utils.import('resource:///modules/devtools/SourceMap.jsm', sourceMap);
18 - }
19 -
20 - exports['test that the api is properly exposed in the top level'] = function (assert, util) {
21 - assert.equal(typeof sourceMap.SourceMapGenerator, "function");
22 - assert.equal(typeof sourceMap.SourceMapConsumer, "function");
23 - assert.equal(typeof sourceMap.SourceNode, "function");
24 - };
25 -
26 -});
1 -/* -*- Mode: js; js-indent-level: 2; -*- */
2 -/*
3 - * Copyright 2011 Mozilla Foundation and contributors
4 - * Licensed under the New BSD license. See LICENSE or:
5 - * http://opensource.org/licenses/BSD-3-Clause
6 - */
7 -if (typeof define !== 'function') {
8 - var define = require('amdefine')(module, require);
9 -}
10 -define(function (require, exports, module) {
11 -
12 - var ArraySet = require('../../lib/source-map/array-set').ArraySet;
13 -
14 - function makeTestSet() {
15 - var set = new ArraySet();
16 - for (var i = 0; i < 100; i++) {
17 - set.add(String(i));
18 - }
19 - return set;
20 - }
21 -
22 - exports['test .has() membership'] = function (assert, util) {
23 - var set = makeTestSet();
24 - for (var i = 0; i < 100; i++) {
25 - assert.ok(set.has(String(i)));
26 - }
27 - };
28 -
29 - exports['test .indexOf() elements'] = function (assert, util) {
30 - var set = makeTestSet();
31 - for (var i = 0; i < 100; i++) {
32 - assert.strictEqual(set.indexOf(String(i)), i);
33 - }
34 - };
35 -
36 - exports['test .at() indexing'] = function (assert, util) {
37 - var set = makeTestSet();
38 - for (var i = 0; i < 100; i++) {
39 - assert.strictEqual(set.at(i), String(i));
40 - }
41 - };
42 -
43 - exports['test creating from an array'] = function (assert, util) {
44 - var set = ArraySet.fromArray(['foo', 'bar', 'baz', 'quux', 'hasOwnProperty']);
45 -
46 - assert.ok(set.has('foo'));
47 - assert.ok(set.has('bar'));
48 - assert.ok(set.has('baz'));
49 - assert.ok(set.has('quux'));
50 - assert.ok(set.has('hasOwnProperty'));
51 -
52 - assert.strictEqual(set.indexOf('foo'), 0);
53 - assert.strictEqual(set.indexOf('bar'), 1);
54 - assert.strictEqual(set.indexOf('baz'), 2);
55 - assert.strictEqual(set.indexOf('quux'), 3);
56 -
57 - assert.strictEqual(set.at(0), 'foo');
58 - assert.strictEqual(set.at(1), 'bar');
59 - assert.strictEqual(set.at(2), 'baz');
60 - assert.strictEqual(set.at(3), 'quux');
61 - };
62 -
63 - exports['test that you can add __proto__; see github issue #30'] = function (assert, util) {
64 - var set = new ArraySet();
65 - set.add('__proto__');
66 - assert.ok(set.has('__proto__'));
67 - assert.strictEqual(set.at(0), '__proto__');
68 - assert.strictEqual(set.indexOf('__proto__'), 0);
69 - };
70 -
71 - exports['test .fromArray() with duplicates'] = function (assert, util) {
72 - var set = ArraySet.fromArray(['foo', 'foo']);
73 - assert.ok(set.has('foo'));
74 - assert.strictEqual(set.at(0), 'foo');
75 - assert.strictEqual(set.indexOf('foo'), 0);
76 - assert.strictEqual(set.toArray().length, 1);
77 -
78 - set = ArraySet.fromArray(['foo', 'foo'], true);
79 - assert.ok(set.has('foo'));
80 - assert.strictEqual(set.at(0), 'foo');
81 - assert.strictEqual(set.at(1), 'foo');
82 - assert.strictEqual(set.indexOf('foo'), 0);
83 - assert.strictEqual(set.toArray().length, 2);
84 - };
85 -
86 - exports['test .add() with duplicates'] = function (assert, util) {
87 - var set = new ArraySet();
88 - set.add('foo');
89 -
90 - set.add('foo');
91 - assert.ok(set.has('foo'));
92 - assert.strictEqual(set.at(0), 'foo');
93 - assert.strictEqual(set.indexOf('foo'), 0);
94 - assert.strictEqual(set.toArray().length, 1);
95 -
96 - set.add('foo', true);
97 - assert.ok(set.has('foo'));
98 - assert.strictEqual(set.at(0), 'foo');
99 - assert.strictEqual(set.at(1), 'foo');
100 - assert.strictEqual(set.indexOf('foo'), 0);
101 - assert.strictEqual(set.toArray().length, 2);
102 - };
103 -
104 -});
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.