all da files
1
0Ao5u1U6KYND7dFVkcnJRNUtHWUNKamxoRGg4ZzNiT3c.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
[{"name":"Sweet Bar Bakery","address":"2355 Broadway","city":"Oakland","state":"Ca","long":"-122.266011839473","lat":"37.8129222733119","geoaccuracy":"house","country":"USA","wifipassword":"cupcakes","outlets":"yes","couch":"no","largetable":"yes","brewing":"","outdoorseating":"yes","hexcolor":"#A0FD14","rowNumber":1},{"name":"Awaken Cafe","address":"1429 Broadway","city":"Oakland","state":"Ca","long":"-122.271131495076","lat":"37.8046753170488","geoaccuracy":"house","country":"USA","wifipassword":"iced coffee","outlets":"yes","couch":"yes","largetable":"yes","brewing":"Four Barrel","outdoorseating":"","hexcolor":"#A0FD14","rowNumber":2},{"name":"Panther Coffee","address":"2390 NW 2nd Ave","city":"Miami","state":"Fl","long":"-80.1991536666667","lat":"25.8000021666667","geoaccuracy":"house","country":"USA","wifipassword":"espresso","outlets":"yes","couch":"no","largetable":"yes","brewing":"In-house","outdoorseating":"yes","hexcolor":"#A0FD14","rowNumber":3},{"name":"Haddon Hill Cafe","address":"504 Wesley Ave","city":"Oakland","state":"Ca","long":"-122.2488474","lat":"37.8049159","geoaccuracy":"cafe","country":"USA","wifipassword":"haddon10","outlets":"yes","couch":"no","largetable":"yes","brewing":"Sight Glass","outdoorseating":"yes","hexcolor":"#A0FD14","rowNumber":4},{"name":"Subrosa","address":"419 40th Street","city":"Oakland","state":"Ca","long":"-122.2604838","lat":"37.8283586","geoaccuracy":"cafe","country":"USA","wifipassword":"-","outlets":"yes","couch":"no","largetable":"no","brewing":"Four Barrel","outdoorseating":"yes","hexcolor":"#A0FD14","rowNumber":5}]
|
55
css/site.css
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/* Page Specific CSS */
|
||||||
|
|
||||||
|
body {font-family: Merriweather; background: #FFFEF8; color: #333; font-size: 16px; border: 10px #F1EFDE solid; margin: 0px; padding: 20px 20px 200px 20px; }
|
||||||
|
h1, h2, h3, h4, h5, h6 {font-family: Amatic SC;}
|
||||||
|
h1 {font-size: 40px;}
|
||||||
|
|
||||||
|
h3.functionH {/*background-color: #47CCFC; color: #fff;*/ padding: 4px 8px; margin-top: 52px; border-top: 3px solid #47CCFC; border-left: 3px solid #47CCFC; border-right: 3px solid #47CCFC; margin-left: -14px; padding-left: 14px;
|
||||||
|
padding-top: 9px; }
|
||||||
|
img {width: 100%;}
|
||||||
|
|
||||||
|
p a, a {color: #333; text-decoration: none; padding-bottom: 0px; border-bottom: 2px #FD9393 solid;}
|
||||||
|
p a:visted {color: #ff00ff;}
|
||||||
|
a:hover {color: #47CCFC;}
|
||||||
|
a:visited {color: #333;}
|
||||||
|
small {padding: 10px 0px;}
|
||||||
|
p {line-height: 24px;}
|
||||||
|
ol {line-height: 24px;}
|
||||||
|
a.button {border: none;}
|
||||||
|
|
||||||
|
#map {height: 400px; max-width: 530px; background: #DADADA;}
|
||||||
|
#map a {border: none;}
|
||||||
|
|
||||||
|
|
||||||
|
::selection {background: #ff00ff;} /*#44FFB4*/
|
||||||
|
::-moz-selection {background: #ff00ff;}
|
||||||
|
|
||||||
|
/*.goToTop {font-size: 9px; font-family: Helvetica; text-transform: uppercase; }*/
|
||||||
|
|
||||||
|
#menu {/*background: #47CCFC;*/ color: #fff; padding: 20px; float: left; position: fixed; left: 40px; top: 40px; max-width: 300px; font-family: Helvetica; font-size: 14px;}
|
||||||
|
#menu ul {list-style: none; margin: 0px; padding: 0px;}
|
||||||
|
#menu li {line-height: 34px;}
|
||||||
|
#menu li a {padding: 4px 8px; background-color: #F0F0F0; text-decoration: none; border: none;}
|
||||||
|
#menu li a.a2 {background-color: #CCF4FF;}
|
||||||
|
#menu li a:hover {background-color: #e7e7e7; color: #333;}
|
||||||
|
|
||||||
|
#wrapper {margin: 0px auto; max-width: 900px; padding-top: 40px; /*margin-left: 250px;*/}
|
||||||
|
pre {word-wrap: break-word; padding: 14px; background: #F0F0F0; }
|
||||||
|
code {font-family: "Consolas", "Ubuntu Mono", monospace; line-height: 22px; font-size: 13px; color: #636363; font-weight: normal;}
|
||||||
|
.button {padding: 5px 4px; background-color: #fff; font-size: 10px;}
|
||||||
|
.dotted {margin: 20px -28px; padding: 20px 28px; background-color: #CCF4FF; border: 8px solid #47CCFC; margin-top: 44px; padding-top: 0px;}
|
||||||
|
.dotted li {padding: 0px 2px;}
|
||||||
|
.dotted h2 {margin-top: inherit;}
|
||||||
|
|
||||||
|
.leaflet-popup-content h2 {margin-bottom: 4px; margin-top: auto;}
|
||||||
|
|
||||||
|
#latestSpot, #selectedSpot {height: 400px; max-width: 350px; width: 100%; float: right;}
|
||||||
|
#selectedSpot {display: none;}
|
||||||
|
#latestSpot ul, #selectedSpot ul {list-style: none; margin: 0px; padding: 0px;}
|
||||||
|
#latestSpot li, #selectedSpot li{line-height: 34px;}
|
||||||
|
|
||||||
|
#hackSpotsTable {cursor: pointer; margin-top: 80px;}
|
||||||
|
#hackSpotsTable .tHeader {padding: 4px 8px; background: #FF7031;}
|
||||||
|
.spotRow:hover {color: #FF7031;}
|
||||||
|
.spotRow {border-left: 3px solid #ff00ff;}
|
||||||
|
.hideRow {display: none;}
|
53
css/style.css
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/* General */
|
||||||
|
|
||||||
|
/* body {margin: 0px auto;}
|
||||||
|
a {color: #333;}
|
||||||
|
small {padding: 10px 0px;}
|
||||||
|
#wrapper {margin: 0px auto; max-width: 600px;}
|
||||||
|
.button {padding: 5px 4px; background-color: #fff; font-size: 10px;}*/
|
||||||
|
.button:hover {cursor: hand;}
|
||||||
|
input:focus {outline: none;}
|
||||||
|
|
||||||
|
/* Table */
|
||||||
|
|
||||||
|
table {text-align: left; width: 100%}
|
||||||
|
th {padding: 10px 0px;}
|
||||||
|
td, text {padding: 3px 20px 3px 0px; font-size: 14px;}
|
||||||
|
#tableFilter, #basicFilter, #dogFilter {margin: 12px 0px; border: none; border-bottom: 1px solid #333; background-color: transparent; padding: 0px; font-family: Merriweather; color: #fff; font-size: 13px; height: 22px;}
|
||||||
|
.noMatches {margin-left: 20px; font-size: 11px; font-style: italic; visibility: hidden;}
|
||||||
|
|
||||||
|
/* Containers */
|
||||||
|
.container {margin: 14px 0px;}
|
||||||
|
#map {height: 400px; max-width: 800px; background: #DADADA;}
|
||||||
|
#holder {height: 400px; max-width: 600px; background: #FFE4E4;}
|
||||||
|
#bar2 {height: 320px; max-width: 600px; background: #F8CDCD;}
|
||||||
|
|
||||||
|
/* Bar Chart */
|
||||||
|
|
||||||
|
.labels text {text-align: right;}
|
||||||
|
.bar .labels text {fill: #333;}
|
||||||
|
.bar rect {fill: #e6e6e6;}
|
||||||
|
.axis {shape-rendering: crispEdges;}
|
||||||
|
.x.axis line {stroke: #FFE4E4; /*stroke-opacity: .2;*/ fill: none;}
|
||||||
|
.x.axis path {fill: none;}
|
||||||
|
.x.axis text {fill: #333;}
|
||||||
|
.xLabel {font-family: sans-serif; font-size: 9px;}
|
||||||
|
|
||||||
|
/* Line Chart */
|
||||||
|
|
||||||
|
/* .axis {shape-rendering: crispEdges;}
|
||||||
|
.x.axis .minor, .y.axis .minor {stroke-opacity: .5;}
|
||||||
|
.x.axis {stroke-opacity: 1;}*/
|
||||||
|
/* .y.axis line, .y.axis path, .x.axis path {fill: none; stroke: #acacac; stroke-width: 1;}
|
||||||
|
.x.axis line {stroke: #acacac; stroke-opacity: .75;}*/
|
||||||
|
/* .bigg {-webkit-transition: all .2s ease-in-out; -webkit-transform: scale(2);}
|
||||||
|
path.chartLine {stroke: #14ECC8; stroke-width: 3; fill: none;}*/
|
||||||
|
div.tooltip {position: absolute; text-align: left; padding: 4px 8px; width: auto; font-size: 10px; height: auto; background: #fff; border: 0px; pointer-events: none;}
|
||||||
|
/*circle {fill: #fff;}*/
|
||||||
|
|
||||||
|
/* Map */
|
||||||
|
|
||||||
|
.leaflet-popup-content {font-family: Merriweather;}
|
||||||
|
.leaflet-popup-content h2 {margin-bottom: 4px;}
|
||||||
|
|
||||||
|
img.petThumbs {height: 80px; width: 80px; border-radius: 1000px;}
|
BIN
favico.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
favicon-p.png
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
img/fbi_spinner.gif
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
img/hexcolors.png
Normal file
After Width: | Height: | Size: 115 KiB |
BIN
img/key.png
Normal file
After Width: | Height: | Size: 39 KiB |
BIN
img/latlong.png
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
img/nonos.png
Normal file
After Width: | Height: | Size: 49 KiB |
BIN
img/publish.png
Normal file
After Width: | Height: | Size: 49 KiB |
BIN
img/sheetsee-03.png
Normal file
After Width: | Height: | Size: 75 KiB |
BIN
img/spreadsheettodata.png
Normal file
After Width: | Height: | Size: 78 KiB |
BIN
img/webconsole.png
Normal file
After Width: | Height: | Size: 35 KiB |
123
index.html
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Hack Spots</title>
|
||||||
|
<script type="text/javascript" src="js/ICanHaz.js"></script>
|
||||||
|
<script src='http://api.tiles.mapbox.com/mapbox.js/v1.0.0/mapbox.js'></script>
|
||||||
|
<script src='js/jquery.js '></script>
|
||||||
|
<script type="text/javascript" src='js/d3.js'></script>
|
||||||
|
<script type="text/javascript" src='js/sheetsee.js'></script>
|
||||||
|
<link rel="shortcut icon" href="https://raw.github.com/jllord/sheetsee-cache/master/favicon-p.png"/>
|
||||||
|
|
||||||
|
|
||||||
|
<link href='http://api.tiles.mapbox.com/mapbox.js/v1.0.0/mapbox.css' rel='stylesheet' />
|
||||||
|
<link media="screen" rel="stylesheet" type="text/css" href="/css/style.css">
|
||||||
|
<link media="screen" rel="stylesheet" type="text/css" href="/css/site.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="wrapper">
|
||||||
|
<h1>Hack Spots</h1>
|
||||||
|
<div id="container">
|
||||||
|
|
||||||
|
<div id="latestSpot"></div>
|
||||||
|
<div id="selectedSpot"></div>
|
||||||
|
<div id="map"></div>
|
||||||
|
</div>
|
||||||
|
<div id="hackSpotsTable"></div>
|
||||||
|
|
||||||
|
|
||||||
|
</div><!-- end wrapper -->
|
||||||
|
|
||||||
|
<script id="hackSpotsTable" type="text/html">
|
||||||
|
<table>
|
||||||
|
<tr><th class="tHeader">Name</th><th class="tHeader">Address</th><th class="tHeader">City</th><th class="tHeader">State</th><th class="tHeader">Country</th></tr>
|
||||||
|
{{#rows}}
|
||||||
|
<tr id="{{rowNumber}}" class="spotRow"><td>{{name}}</td><td>{{address}}</td><td>{{city}}</td><td>{{state}}</td><td>{{country}}</td><td><a class="button" href="https://maps.google.com/maps?q={{address}},{{city}},{{state}}" target="_blank">Map it!</a></td></tr>
|
||||||
|
<tr class="hideRow"><td>wifi: {{wifipassword}}</td></tr>
|
||||||
|
{{/rows}}
|
||||||
|
</table>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script id="latestSpot" type="text/html">
|
||||||
|
{{#rows}}
|
||||||
|
<h2>Recently Added</h2>
|
||||||
|
<h3>{{name}}</h3>
|
||||||
|
<p>{{address}}, {{city}}, {{state}}
|
||||||
|
<ul>
|
||||||
|
<li>Wifi: {{wifipassword}}</li>
|
||||||
|
<li>Outlets: {{outlets}}</li>
|
||||||
|
<li>Couch: {{couch}}</li>
|
||||||
|
<li>Large Table: {{largetable}}</li>
|
||||||
|
<li>Outdoor Seating: {{outdoorseating}}</li>
|
||||||
|
<li>Brewing: {{brewing}}</li>
|
||||||
|
</ul>
|
||||||
|
{{/rows}}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script id="selectedSpot" type="text/html">
|
||||||
|
{{#rows}}
|
||||||
|
<h2>Selected Spot</h2>
|
||||||
|
<h3>{{name}}</h3>
|
||||||
|
<p>{{address}}, {{city}}, {{state}}
|
||||||
|
<ul>
|
||||||
|
<li>Wifi: {{wifipassword}}</li>
|
||||||
|
<li>Outlets: {{outlets}}</li>
|
||||||
|
<li>Couch: {{couch}}</li>
|
||||||
|
<li>Large Table: {{largetable}}</li>
|
||||||
|
<li>Outdoor Seating: {{outdoorseating}}</li>
|
||||||
|
<li>Brewing: {{brewing}}</li>
|
||||||
|
</ul>
|
||||||
|
{{/rows}}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
Sheetsee.makeTable(gData, "#hackSpotsTable")
|
||||||
|
|
||||||
|
$('.spotRow').click(function(event) {
|
||||||
|
var rowNumber = $(this).closest("tr").attr("id")
|
||||||
|
console.log(rowNumber)
|
||||||
|
var dataElement = Sheetsee.getMatches(gData, rowNumber, "rowNumber")
|
||||||
|
console.log(dataElement)
|
||||||
|
var selectedSpot = ich.selectedSpot({
|
||||||
|
rows: dataElement
|
||||||
|
})
|
||||||
|
$('#latestSpot').css("display", "none")
|
||||||
|
$('#selectedSpot').html(selectedSpot).css("display", "inline")
|
||||||
|
var selectedCoords = [dataElement[0].lat, dataElement[0].long]
|
||||||
|
console.log(selectedCoords)
|
||||||
|
map.setView(selectedCoords, 17)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
var theLatestSpot = gData.reverse()[0]
|
||||||
|
var latestSpot = ich.latestSpot({
|
||||||
|
rows: theLatestSpot
|
||||||
|
})
|
||||||
|
$('#latestSpot').html(latestSpot)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
var optionsJSON = ["name", "address", "city", "rownumber"]
|
||||||
|
var geoJSON = Sheetsee.createGeoJSON(gData, optionsJSON)
|
||||||
|
var map = Sheetsee.loadMap("map")
|
||||||
|
Sheetsee.addTileLayer(map, 'examples.map-20v6611k')
|
||||||
|
var markerLayer = Sheetsee.addMarkerLayer(geoJSON, map, 11)
|
||||||
|
addPopups(map, markerLayer)
|
||||||
|
|
||||||
|
function addPopups(map, markerLayer) {
|
||||||
|
markerLayer.on('click', function(e) {
|
||||||
|
var feature = e.layer.feature
|
||||||
|
var popupContent = '<h2>' + feature.opts.name + '</h2>' +
|
||||||
|
'<h3>' + feature.opts.address + ', ' + feature.opts.city + '</h3>'
|
||||||
|
e.layer.bindPopup(popupContent,{closeButton: false,})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
console.log(gData)
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
26
index.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
window.Tabletop = require('./tabletop.js').Tabletop
|
||||||
|
var fs = require('filesystem-browserify')
|
||||||
|
|
||||||
|
module.exports = SheetSee
|
||||||
|
|
||||||
|
function SheetSee(URL){
|
||||||
|
console.log("this is fs", fs)
|
||||||
|
var self = this
|
||||||
|
Tabletop.init( { key: URL,
|
||||||
|
callback: function(data, tabletop) {self.readyData(data, tabletop)},
|
||||||
|
simpleSheet: true } )
|
||||||
|
this.sheetData = []
|
||||||
|
}
|
||||||
|
|
||||||
|
SheetSee.prototype.readyData = function(data, tabletop, callback){
|
||||||
|
this.sheetData = data
|
||||||
|
|
||||||
|
fs.writeFile('message.txt', 'Hello Node', function (err) {
|
||||||
|
if (err) throw err;
|
||||||
|
console.log('It\'s saved!');
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("the datas", this.sheetData)
|
||||||
|
callback(this.sheetData)
|
||||||
|
}
|
||||||
|
|
542
js/ICanHaz.js
Normal file
@ -0,0 +1,542 @@
|
|||||||
|
/*!
|
||||||
|
ICanHaz.js version 0.10 -- by @HenrikJoreteg
|
||||||
|
More info at: http://icanhazjs.com
|
||||||
|
*/
|
||||||
|
(function () {
|
||||||
|
/*
|
||||||
|
mustache.js — Logic-less templates in JavaScript
|
||||||
|
|
||||||
|
See http://mustache.github.com/ for more info.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var Mustache = function () {
|
||||||
|
var _toString = Object.prototype.toString;
|
||||||
|
|
||||||
|
Array.isArray = Array.isArray || function (obj) {
|
||||||
|
return _toString.call(obj) == "[object Array]";
|
||||||
|
}
|
||||||
|
|
||||||
|
var _trim = String.prototype.trim, trim;
|
||||||
|
|
||||||
|
if (_trim) {
|
||||||
|
trim = function (text) {
|
||||||
|
return text == null ? "" : _trim.call(text);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var trimLeft, trimRight;
|
||||||
|
|
||||||
|
// IE doesn't match non-breaking spaces with \s.
|
||||||
|
if ((/\S/).test("\xA0")) {
|
||||||
|
trimLeft = /^[\s\xA0]+/;
|
||||||
|
trimRight = /[\s\xA0]+$/;
|
||||||
|
} else {
|
||||||
|
trimLeft = /^\s+/;
|
||||||
|
trimRight = /\s+$/;
|
||||||
|
}
|
||||||
|
|
||||||
|
trim = function (text) {
|
||||||
|
return text == null ? "" :
|
||||||
|
text.toString().replace(trimLeft, "").replace(trimRight, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var escapeMap = {
|
||||||
|
"&": "&",
|
||||||
|
"<": "<",
|
||||||
|
">": ">",
|
||||||
|
'"': '"',
|
||||||
|
"'": '''
|
||||||
|
};
|
||||||
|
|
||||||
|
function escapeHTML(string) {
|
||||||
|
return String(string).replace(/&(?!\w+;)|[<>"']/g, function (s) {
|
||||||
|
return escapeMap[s] || s;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var regexCache = {};
|
||||||
|
var Renderer = function () {};
|
||||||
|
|
||||||
|
Renderer.prototype = {
|
||||||
|
otag: "{{",
|
||||||
|
ctag: "}}",
|
||||||
|
pragmas: {},
|
||||||
|
buffer: [],
|
||||||
|
pragmas_implemented: {
|
||||||
|
"IMPLICIT-ITERATOR": true
|
||||||
|
},
|
||||||
|
context: {},
|
||||||
|
|
||||||
|
render: function (template, context, partials, in_recursion) {
|
||||||
|
// reset buffer & set context
|
||||||
|
if (!in_recursion) {
|
||||||
|
this.context = context;
|
||||||
|
this.buffer = []; // TODO: make this non-lazy
|
||||||
|
}
|
||||||
|
|
||||||
|
// fail fast
|
||||||
|
if (!this.includes("", template)) {
|
||||||
|
if (in_recursion) {
|
||||||
|
return template;
|
||||||
|
} else {
|
||||||
|
this.send(template);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the pragmas together
|
||||||
|
template = this.render_pragmas(template);
|
||||||
|
|
||||||
|
// render the template
|
||||||
|
var html = this.render_section(template, context, partials);
|
||||||
|
|
||||||
|
// render_section did not find any sections, we still need to render the tags
|
||||||
|
if (html === false) {
|
||||||
|
html = this.render_tags(template, context, partials, in_recursion);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_recursion) {
|
||||||
|
return html;
|
||||||
|
} else {
|
||||||
|
this.sendLines(html);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
Sends parsed lines
|
||||||
|
*/
|
||||||
|
send: function (line) {
|
||||||
|
if (line !== "") {
|
||||||
|
this.buffer.push(line);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
sendLines: function (text) {
|
||||||
|
if (text) {
|
||||||
|
var lines = text.split("\n");
|
||||||
|
for (var i = 0; i < lines.length; i++) {
|
||||||
|
this.send(lines[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
Looks for %PRAGMAS
|
||||||
|
*/
|
||||||
|
render_pragmas: function (template) {
|
||||||
|
// no pragmas
|
||||||
|
if (!this.includes("%", template)) {
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
|
||||||
|
var that = this;
|
||||||
|
var regex = this.getCachedRegex("render_pragmas", function (otag, ctag) {
|
||||||
|
return new RegExp(otag + "%([\\w-]+) ?([\\w]+=[\\w]+)?" + ctag, "g");
|
||||||
|
});
|
||||||
|
|
||||||
|
return template.replace(regex, function (match, pragma, options) {
|
||||||
|
if (!that.pragmas_implemented[pragma]) {
|
||||||
|
throw({message:
|
||||||
|
"This implementation of mustache doesn't understand the '" +
|
||||||
|
pragma + "' pragma"});
|
||||||
|
}
|
||||||
|
that.pragmas[pragma] = {};
|
||||||
|
if (options) {
|
||||||
|
var opts = options.split("=");
|
||||||
|
that.pragmas[pragma][opts[0]] = opts[1];
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
// ignore unknown pragmas silently
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
Tries to find a partial in the curent scope and render it
|
||||||
|
*/
|
||||||
|
render_partial: function (name, context, partials) {
|
||||||
|
name = trim(name);
|
||||||
|
if (!partials || partials[name] === undefined) {
|
||||||
|
throw({message: "unknown_partial '" + name + "'"});
|
||||||
|
}
|
||||||
|
if (!context || typeof context[name] != "object") {
|
||||||
|
return this.render(partials[name], context, partials, true);
|
||||||
|
}
|
||||||
|
return this.render(partials[name], context[name], partials, true);
|
||||||
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
Renders inverted (^) and normal (#) sections
|
||||||
|
*/
|
||||||
|
render_section: function (template, context, partials) {
|
||||||
|
if (!this.includes("#", template) && !this.includes("^", template)) {
|
||||||
|
// did not render anything, there were no sections
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var that = this;
|
||||||
|
|
||||||
|
var regex = this.getCachedRegex("render_section", function (otag, ctag) {
|
||||||
|
// This regex matches _the first_ section ({{#foo}}{{/foo}}), and captures the remainder
|
||||||
|
return new RegExp(
|
||||||
|
"^([\\s\\S]*?)" + // all the crap at the beginning that is not {{*}} ($1)
|
||||||
|
|
||||||
|
otag + // {{
|
||||||
|
"(\\^|\\#)\\s*(.+)\\s*" + // #foo (# == $2, foo == $3)
|
||||||
|
ctag + // }}
|
||||||
|
|
||||||
|
"\n*([\\s\\S]*?)" + // between the tag ($2). leading newlines are dropped
|
||||||
|
|
||||||
|
otag + // {{
|
||||||
|
"\\/\\s*\\3\\s*" + // /foo (backreference to the opening tag).
|
||||||
|
ctag + // }}
|
||||||
|
|
||||||
|
"\\s*([\\s\\S]*)$", // everything else in the string ($4). leading whitespace is dropped.
|
||||||
|
|
||||||
|
"g");
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// for each {{#foo}}{{/foo}} section do...
|
||||||
|
return template.replace(regex, function (match, before, type, name, content, after) {
|
||||||
|
// before contains only tags, no sections
|
||||||
|
var renderedBefore = before ? that.render_tags(before, context, partials, true) : "",
|
||||||
|
|
||||||
|
// after may contain both sections and tags, so use full rendering function
|
||||||
|
renderedAfter = after ? that.render(after, context, partials, true) : "",
|
||||||
|
|
||||||
|
// will be computed below
|
||||||
|
renderedContent,
|
||||||
|
|
||||||
|
value = that.find(name, context);
|
||||||
|
|
||||||
|
if (type === "^") { // inverted section
|
||||||
|
if (!value || Array.isArray(value) && value.length === 0) {
|
||||||
|
// false or empty list, render it
|
||||||
|
renderedContent = that.render(content, context, partials, true);
|
||||||
|
} else {
|
||||||
|
renderedContent = "";
|
||||||
|
}
|
||||||
|
} else if (type === "#") { // normal section
|
||||||
|
if (Array.isArray(value)) { // Enumerable, Let's loop!
|
||||||
|
renderedContent = that.map(value, function (row) {
|
||||||
|
return that.render(content, that.create_context(row), partials, true);
|
||||||
|
}).join("");
|
||||||
|
} else if (that.is_object(value)) { // Object, Use it as subcontext!
|
||||||
|
renderedContent = that.render(content, that.create_context(value),
|
||||||
|
partials, true);
|
||||||
|
} else if (typeof value == "function") {
|
||||||
|
// higher order section
|
||||||
|
renderedContent = value.call(context, content, function (text) {
|
||||||
|
return that.render(text, context, partials, true);
|
||||||
|
});
|
||||||
|
} else if (value) { // boolean section
|
||||||
|
renderedContent = that.render(content, context, partials, true);
|
||||||
|
} else {
|
||||||
|
renderedContent = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return renderedBefore + renderedContent + renderedAfter;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
Replace {{foo}} and friends with values from our view
|
||||||
|
*/
|
||||||
|
render_tags: function (template, context, partials, in_recursion) {
|
||||||
|
// tit for tat
|
||||||
|
var that = this;
|
||||||
|
|
||||||
|
var new_regex = function () {
|
||||||
|
return that.getCachedRegex("render_tags", function (otag, ctag) {
|
||||||
|
return new RegExp(otag + "(=|!|>|&|\\{|%)?([^#\\^]+?)\\1?" + ctag + "+", "g");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var regex = new_regex();
|
||||||
|
var tag_replace_callback = function (match, operator, name) {
|
||||||
|
switch(operator) {
|
||||||
|
case "!": // ignore comments
|
||||||
|
return "";
|
||||||
|
case "=": // set new delimiters, rebuild the replace regexp
|
||||||
|
that.set_delimiters(name);
|
||||||
|
regex = new_regex();
|
||||||
|
return "";
|
||||||
|
case ">": // render partial
|
||||||
|
return that.render_partial(name, context, partials);
|
||||||
|
case "{": // the triple mustache is unescaped
|
||||||
|
case "&": // & operator is an alternative unescape method
|
||||||
|
return that.find(name, context);
|
||||||
|
default: // escape the value
|
||||||
|
return escapeHTML(that.find(name, context));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var lines = template.split("\n");
|
||||||
|
for(var i = 0; i < lines.length; i++) {
|
||||||
|
lines[i] = lines[i].replace(regex, tag_replace_callback, this);
|
||||||
|
if (!in_recursion) {
|
||||||
|
this.send(lines[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_recursion) {
|
||||||
|
return lines.join("\n");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
set_delimiters: function (delimiters) {
|
||||||
|
var dels = delimiters.split(" ");
|
||||||
|
this.otag = this.escape_regex(dels[0]);
|
||||||
|
this.ctag = this.escape_regex(dels[1]);
|
||||||
|
},
|
||||||
|
|
||||||
|
escape_regex: function (text) {
|
||||||
|
// thank you Simon Willison
|
||||||
|
if (!arguments.callee.sRE) {
|
||||||
|
var specials = [
|
||||||
|
'/', '.', '*', '+', '?', '|',
|
||||||
|
'(', ')', '[', ']', '{', '}', '\\'
|
||||||
|
];
|
||||||
|
arguments.callee.sRE = new RegExp(
|
||||||
|
'(\\' + specials.join('|\\') + ')', 'g'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return text.replace(arguments.callee.sRE, '\\$1');
|
||||||
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
find `name` in current `context`. That is find me a value
|
||||||
|
from the view object
|
||||||
|
*/
|
||||||
|
find: function (name, context) {
|
||||||
|
name = trim(name);
|
||||||
|
|
||||||
|
// Checks whether a value is thruthy or false or 0
|
||||||
|
function is_kinda_truthy(bool) {
|
||||||
|
return bool === false || bool === 0 || bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
var value;
|
||||||
|
|
||||||
|
// check for dot notation eg. foo.bar
|
||||||
|
if (name.match(/([a-z_]+)\./ig)) {
|
||||||
|
var childValue = this.walk_context(name, context);
|
||||||
|
if (is_kinda_truthy(childValue)) {
|
||||||
|
value = childValue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (is_kinda_truthy(context[name])) {
|
||||||
|
value = context[name];
|
||||||
|
} else if (is_kinda_truthy(this.context[name])) {
|
||||||
|
value = this.context[name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof value == "function") {
|
||||||
|
return value.apply(context);
|
||||||
|
}
|
||||||
|
if (value !== undefined) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
// silently ignore unkown variables
|
||||||
|
return "";
|
||||||
|
},
|
||||||
|
|
||||||
|
walk_context: function (name, context) {
|
||||||
|
var path = name.split('.');
|
||||||
|
// if the var doesn't exist in current context, check the top level context
|
||||||
|
var value_context = (context[path[0]] != undefined) ? context : this.context;
|
||||||
|
var value = value_context[path.shift()];
|
||||||
|
while (value != undefined && path.length > 0) {
|
||||||
|
value_context = value;
|
||||||
|
value = value[path.shift()];
|
||||||
|
}
|
||||||
|
// if the value is a function, call it, binding the correct context
|
||||||
|
if (typeof value == "function") {
|
||||||
|
return value.apply(value_context);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
},
|
||||||
|
|
||||||
|
// Utility methods
|
||||||
|
|
||||||
|
/* includes tag */
|
||||||
|
includes: function (needle, haystack) {
|
||||||
|
return haystack.indexOf(this.otag + needle) != -1;
|
||||||
|
},
|
||||||
|
|
||||||
|
// by @langalex, support for arrays of strings
|
||||||
|
create_context: function (_context) {
|
||||||
|
if (this.is_object(_context)) {
|
||||||
|
return _context;
|
||||||
|
} else {
|
||||||
|
var iterator = ".";
|
||||||
|
if (this.pragmas["IMPLICIT-ITERATOR"]) {
|
||||||
|
iterator = this.pragmas["IMPLICIT-ITERATOR"].iterator;
|
||||||
|
}
|
||||||
|
var ctx = {};
|
||||||
|
ctx[iterator] = _context;
|
||||||
|
return ctx;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
is_object: function (a) {
|
||||||
|
return a && typeof a == "object";
|
||||||
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
Why, why, why? Because IE. Cry, cry cry.
|
||||||
|
*/
|
||||||
|
map: function (array, fn) {
|
||||||
|
if (typeof array.map == "function") {
|
||||||
|
return array.map(fn);
|
||||||
|
} else {
|
||||||
|
var r = [];
|
||||||
|
var l = array.length;
|
||||||
|
for(var i = 0; i < l; i++) {
|
||||||
|
r.push(fn(array[i]));
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getCachedRegex: function (name, generator) {
|
||||||
|
var byOtag = regexCache[this.otag];
|
||||||
|
if (!byOtag) {
|
||||||
|
byOtag = regexCache[this.otag] = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
var byCtag = byOtag[this.ctag];
|
||||||
|
if (!byCtag) {
|
||||||
|
byCtag = byOtag[this.ctag] = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
var regex = byCtag[name];
|
||||||
|
if (!regex) {
|
||||||
|
regex = byCtag[name] = generator(this.otag, this.ctag);
|
||||||
|
}
|
||||||
|
|
||||||
|
return regex;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return({
|
||||||
|
name: "mustache.js",
|
||||||
|
version: "0.4.0",
|
||||||
|
|
||||||
|
/*
|
||||||
|
Turns a template and view into HTML
|
||||||
|
*/
|
||||||
|
to_html: function (template, view, partials, send_fun) {
|
||||||
|
var renderer = new Renderer();
|
||||||
|
if (send_fun) {
|
||||||
|
renderer.send = send_fun;
|
||||||
|
}
|
||||||
|
renderer.render(template, view || {}, partials);
|
||||||
|
if (!send_fun) {
|
||||||
|
return renderer.buffer.join("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}();
|
||||||
|
/*!
|
||||||
|
ICanHaz.js -- by @HenrikJoreteg
|
||||||
|
*/
|
||||||
|
/*global */
|
||||||
|
(function () {
|
||||||
|
function trim(stuff) {
|
||||||
|
if (''.trim) return stuff.trim();
|
||||||
|
else return stuff.replace(/^\s+/, '').replace(/\s+$/, '');
|
||||||
|
}
|
||||||
|
var ich = {
|
||||||
|
VERSION: "0.10",
|
||||||
|
templates: {},
|
||||||
|
|
||||||
|
// grab jquery or zepto if it's there
|
||||||
|
$: (typeof window !== 'undefined') ? window.jQuery || window.Zepto || null : null,
|
||||||
|
|
||||||
|
// public function for adding templates
|
||||||
|
// can take a name and template string arguments
|
||||||
|
// or can take an object with name/template pairs
|
||||||
|
// We're enforcing uniqueness to avoid accidental template overwrites.
|
||||||
|
// If you want a different template, it should have a different name.
|
||||||
|
addTemplate: function (name, templateString) {
|
||||||
|
if (typeof name === 'object') {
|
||||||
|
for (var template in name) {
|
||||||
|
this.addTemplate(template, name[template]);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ich[name]) {
|
||||||
|
console.error("Invalid name: " + name + ".");
|
||||||
|
} else if (ich.templates[name]) {
|
||||||
|
console.error("Template \"" + name + " \" exists");
|
||||||
|
} else {
|
||||||
|
ich.templates[name] = templateString;
|
||||||
|
ich[name] = function (data, raw) {
|
||||||
|
data = data || {};
|
||||||
|
var result = Mustache.to_html(ich.templates[name], data, ich.templates);
|
||||||
|
return (ich.$ && !raw) ? ich.$(result) : result;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// clears all retrieval functions and empties cache
|
||||||
|
clearAll: function () {
|
||||||
|
for (var key in ich.templates) {
|
||||||
|
delete ich[key];
|
||||||
|
}
|
||||||
|
ich.templates = {};
|
||||||
|
},
|
||||||
|
|
||||||
|
// clears/grabs
|
||||||
|
refresh: function () {
|
||||||
|
ich.clearAll();
|
||||||
|
ich.grabTemplates();
|
||||||
|
},
|
||||||
|
|
||||||
|
// grabs templates from the DOM and caches them.
|
||||||
|
// Loop through and add templates.
|
||||||
|
// Whitespace at beginning and end of all templates inside <script> tags will
|
||||||
|
// be trimmed. If you want whitespace around a partial, add it in the parent,
|
||||||
|
// not the partial. Or do it explicitly using <br/> or
|
||||||
|
grabTemplates: function () {
|
||||||
|
var i,
|
||||||
|
scripts = document.getElementsByTagName('script'),
|
||||||
|
script,
|
||||||
|
trash = [];
|
||||||
|
for (i = 0, l = scripts.length; i < l; i++) {
|
||||||
|
script = scripts[i];
|
||||||
|
if (script && script.innerHTML && script.id && (script.type === "text/html" || script.type === "text/x-icanhaz")) {
|
||||||
|
ich.addTemplate(script.id, trim(script.innerHTML));
|
||||||
|
trash.unshift(script);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (i = 0, l = trash.length; i < l; i++) {
|
||||||
|
trash[i].parentNode.removeChild(trash[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Use CommonJS if applicable
|
||||||
|
if (typeof require !== 'undefined') {
|
||||||
|
module.exports = ich;
|
||||||
|
} else {
|
||||||
|
// else attach it to the window
|
||||||
|
window.ich = ich;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof document !== 'undefined') {
|
||||||
|
if (ich.$) {
|
||||||
|
ich.$(function () {
|
||||||
|
ich.grabTemplates();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
ich.grabTemplates();
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})();
|
||||||
|
})();
|
2
js/jquery.js
vendored
Normal file
751
js/sheetsee.js
Normal file
@ -0,0 +1,751 @@
|
|||||||
|
function exportFunctions(exports) {
|
||||||
|
|
||||||
|
// // // // // // // // // // // // // // // // // // // // // // // // // //
|
||||||
|
//
|
||||||
|
// // // Make Table, Sort and Filter Interactions
|
||||||
|
//
|
||||||
|
// // // // // // // // // // // // // // // // // // // // // // // // // //
|
||||||
|
|
||||||
|
function initiateTableFilter(data, filterDiv, tableDiv) {
|
||||||
|
$('.clear').on("click", function() {
|
||||||
|
console.log(this)
|
||||||
|
$(this.id + ".noMatches").css("visibility", "hidden")
|
||||||
|
$(this.id + filterDiv).val("")
|
||||||
|
makeTable(data, tableDiv)
|
||||||
|
})
|
||||||
|
$(filterDiv).keyup(function(e) {
|
||||||
|
var text = $(e.target).val()
|
||||||
|
searchTable(data, text, tableDiv)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function searchTable(data, searchTerm, tableDiv) {
|
||||||
|
var filteredList = []
|
||||||
|
data.forEach(function(object) {
|
||||||
|
var stringObject = JSON.stringify(object).toLowerCase()
|
||||||
|
if (stringObject.match(searchTerm)) filteredList.push(object)
|
||||||
|
})
|
||||||
|
// if ($('#tableFilter').val("")) makeTable(data, tableDiv)
|
||||||
|
if (filteredList.length === 0) {
|
||||||
|
console.log("no matchie")
|
||||||
|
$(".noMatches").css("visibility", "inherit")
|
||||||
|
makeTable("no matches", tableDiv)
|
||||||
|
}
|
||||||
|
else $(".noMatches").css("visibility", "hidden")
|
||||||
|
makeTable(filteredList, tableDiv)
|
||||||
|
return filteredList
|
||||||
|
}
|
||||||
|
|
||||||
|
function sortThings(data, sorter, sorted, tableDiv) {
|
||||||
|
data.sort(function(a,b){
|
||||||
|
if (a[sorter]<b[sorter]) return -1
|
||||||
|
if (a[sorter]>b[sorter]) return 1
|
||||||
|
return 0
|
||||||
|
})
|
||||||
|
if (sorted === "descending") data.reverse()
|
||||||
|
makeTable(data, tableDiv)
|
||||||
|
var header
|
||||||
|
$(tableDiv + " .tHeader").each(function(i, el){
|
||||||
|
var contents = resolveDataTitle($(el).text())
|
||||||
|
if (contents === sorter) header = el
|
||||||
|
})
|
||||||
|
$(header).attr("data-sorted", sorted)
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveDataTitle(string) {
|
||||||
|
var adjusted = string.toLowerCase().replace(/\s/g, '').replace(/\W/g, '')
|
||||||
|
return adjusted
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendToSort(event) {
|
||||||
|
var tableDiv = "#" + $(event.target).closest("div").attr("id")
|
||||||
|
console.log("came from this table",tableDiv)
|
||||||
|
// var dataset = $(tableDiv).attr('dataset')
|
||||||
|
// console.log("made with this data", dataset, typeof dataset)
|
||||||
|
var sorted = $(event.target).attr("data-sorted")
|
||||||
|
if (sorted) {
|
||||||
|
if (sorted === "descending") sorted = "ascending"
|
||||||
|
else sorted = "descending"
|
||||||
|
}
|
||||||
|
else { sorted = "ascending" }
|
||||||
|
var sorter = resolveDataTitle(event.target.innerHTML)
|
||||||
|
sortThings(gData, sorter, sorted, tableDiv)
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).on("click", ".tHeader", sendToSort)
|
||||||
|
|
||||||
|
function makeTable(data, targetDiv) {
|
||||||
|
var templateID = targetDiv.replace("#", "")
|
||||||
|
var tableContents = ich[templateID]({
|
||||||
|
rows: data
|
||||||
|
})
|
||||||
|
$(targetDiv).html(tableContents)
|
||||||
|
}
|
||||||
|
|
||||||
|
// // // // // // // // // // // // // // // // // // // // // // // // // //
|
||||||
|
//
|
||||||
|
// // // Sorting, Ordering Data
|
||||||
|
//
|
||||||
|
// // // // // // // // // // // // // // // // // // // // // // // // // //
|
||||||
|
|
||||||
|
function getGroupCount(data, groupTerm) {
|
||||||
|
var group = []
|
||||||
|
data.forEach(function (d) {
|
||||||
|
if (d.status.match(groupTerm)) group.push(d)
|
||||||
|
})
|
||||||
|
return group.length
|
||||||
|
if (group = []) return "0"
|
||||||
|
}
|
||||||
|
|
||||||
|
function getColumnTotal(data, column){
|
||||||
|
var total = []
|
||||||
|
data.forEach(function (d) {
|
||||||
|
if (d[column] === "") return
|
||||||
|
total.push(+d[column])
|
||||||
|
})
|
||||||
|
return total.reduce(function(a,b) {
|
||||||
|
return a + b
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function getColumnAverage(data, column) {
|
||||||
|
var total = getColumnTotal(data, column)
|
||||||
|
var average = total / data.length
|
||||||
|
return average
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMax(data, column){
|
||||||
|
var result = []
|
||||||
|
data.forEach(function (element){
|
||||||
|
if (result.length === 0) return result.push(element)
|
||||||
|
else {
|
||||||
|
if (element[column].valueOf() > result[0][column].valueOf()) {
|
||||||
|
result.length = 0
|
||||||
|
return result.push(element)
|
||||||
|
}
|
||||||
|
if (element[column].valueOf() === result[0][column].valueOf()) {
|
||||||
|
return result.push(element)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMin(data, column){
|
||||||
|
var result = []
|
||||||
|
data.forEach(function (element){
|
||||||
|
if (result.length === 0) return result.push(element)
|
||||||
|
else {
|
||||||
|
if (element[column].valueOf() < result[0][column].valueOf()) {
|
||||||
|
result.length = 0
|
||||||
|
return result.push(element)
|
||||||
|
}
|
||||||
|
if (element[column].valueOf() === result[0][column].valueOf()) {
|
||||||
|
return result.push(element)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// out of the data, filter something from a category
|
||||||
|
function getMatches(data, filter, category) {
|
||||||
|
var matches = []
|
||||||
|
data.forEach(function (element) {
|
||||||
|
if (category === 'rowNumber') {
|
||||||
|
var projectType = element[category].toString()
|
||||||
|
if (projectType === filter) matches.push(element)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var projectType = element[category].toLowerCase()
|
||||||
|
if (projectType === filter.toLowerCase()) matches.push(element)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return matches
|
||||||
|
}
|
||||||
|
|
||||||
|
function mostFrequent(data, category) {
|
||||||
|
var count = {}
|
||||||
|
for (var i = 0; i < data.length; i++) {
|
||||||
|
if (!count[data[i][category]]) {
|
||||||
|
count[data[i][category]] = 0
|
||||||
|
}
|
||||||
|
count[data[i][category]]++
|
||||||
|
}
|
||||||
|
var sortable = []
|
||||||
|
for (var category in count) {
|
||||||
|
sortable.push([category, count[category]])
|
||||||
|
}
|
||||||
|
sortable.sort(function(a, b) {return b[1] - a[1]})
|
||||||
|
return sortable
|
||||||
|
// returns array of arrays, in order
|
||||||
|
}
|
||||||
|
|
||||||
|
// thank you! http://james.padolsey.com/javascript/deep-copying-of-objects-and-arrays/
|
||||||
|
function deepCopy(obj) {
|
||||||
|
if (Object.prototype.toString.call(obj) === '[object Array]') {
|
||||||
|
var out = [], i = 0, len = obj.length;
|
||||||
|
for ( ; i < len; i++ ) {
|
||||||
|
out[i] = arguments.callee(obj[i]);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
if (typeof obj === 'object') {
|
||||||
|
var out = {}, i;
|
||||||
|
for ( i in obj ) {
|
||||||
|
out[i] = arguments.callee(obj[i]);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addUnitsLabels(arrayObj, oldLabel, oldUnits) {
|
||||||
|
var newArray = deepCopy(arrayObj)
|
||||||
|
for (var i = 0; i < newArray.length; i++) {
|
||||||
|
newArray[i].label = newArray[i][oldLabel]
|
||||||
|
newArray[i].units = newArray[i][oldUnits]
|
||||||
|
delete newArray[i][oldLabel]
|
||||||
|
delete newArray[i][oldUnits]
|
||||||
|
}
|
||||||
|
return newArray
|
||||||
|
}
|
||||||
|
|
||||||
|
function getOccurance(data, category) {
|
||||||
|
var occuranceCount = {}
|
||||||
|
for (var i = 0; i < data.length; i++) {
|
||||||
|
if (!occuranceCount[data[i][category]]) {
|
||||||
|
occuranceCount[data[i][category]] = 0
|
||||||
|
}
|
||||||
|
occuranceCount[data[i][category]]++
|
||||||
|
}
|
||||||
|
return occuranceCount
|
||||||
|
// returns object, keys alphabetical
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeColorArrayOfObject(data, colors) {
|
||||||
|
var keys = Object.keys(data)
|
||||||
|
var counter = 1
|
||||||
|
var colorIndex
|
||||||
|
return keys.map(function(key){
|
||||||
|
if (keys.length > colors.length || keys.length <= colors.length ) {
|
||||||
|
colorIndex = counter % colors.length
|
||||||
|
}
|
||||||
|
var h = {label: key, units: data[key], hexcolor: colors[colorIndex]}
|
||||||
|
counter++
|
||||||
|
colorIndex = counter
|
||||||
|
return h
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function makeArrayOfObject(data) {
|
||||||
|
var keys = Object.keys(data)
|
||||||
|
return keys.map(function(key){
|
||||||
|
// var h = {label: key, units: data[key], hexcolor: "#FDBDBD"}
|
||||||
|
var h = {label: key, units: data[key]}
|
||||||
|
return h
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// // // // // // // // // // // // // // // // // // // // // // // // //
|
||||||
|
//
|
||||||
|
// // // // Mapbox + Leaflet Map
|
||||||
|
//
|
||||||
|
// // // // // // // // // // // // // // // // // // // // // // // // //
|
||||||
|
|
||||||
|
function buildOptionObject(optionsJSON, lineItem) {
|
||||||
|
var newObj = {}
|
||||||
|
optionsJSON.forEach(function(option) {
|
||||||
|
newObj[option] = lineItem[option]
|
||||||
|
})
|
||||||
|
return newObj
|
||||||
|
}
|
||||||
|
|
||||||
|
// for geocoding: http://mapbox.com/tilemill/docs/guides/google-docs/#geocoding
|
||||||
|
// create geoJSON from your spreadsheet's coordinates
|
||||||
|
function createGeoJSON(data, optionsJSON) {
|
||||||
|
var geoJSON = []
|
||||||
|
data.forEach(function(lineItem){
|
||||||
|
if (optionsJSON) var optionObj = buildOptionObject(optionsJSON, lineItem)
|
||||||
|
var feature = {
|
||||||
|
type: 'Feature',
|
||||||
|
"geometry": {"type": "Point", "coordinates": [lineItem.long, lineItem.lat]},
|
||||||
|
"properties": {
|
||||||
|
"marker-size": "small",
|
||||||
|
"marker-color": lineItem.hexcolor
|
||||||
|
},
|
||||||
|
"opts": optionObj,
|
||||||
|
}
|
||||||
|
geoJSON.push(feature)
|
||||||
|
})
|
||||||
|
return geoJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
// load basic map with tiles
|
||||||
|
function loadMap(mapDiv) {
|
||||||
|
var map = L.mapbox.map(mapDiv)
|
||||||
|
// map.setView(, 4)
|
||||||
|
// map.addLayer(L.tileLayer('http://{s}.tile.stamen.com/toner/{z}/{x}/{y}.png'))
|
||||||
|
map.touchZoom.disable()
|
||||||
|
map.doubleClickZoom.disable()
|
||||||
|
map.scrollWheelZoom.disable()
|
||||||
|
return map
|
||||||
|
}
|
||||||
|
|
||||||
|
function addTileLayer(map, tileLayer) {
|
||||||
|
var layer = L.mapbox.tileLayer(tileLayer)
|
||||||
|
layer.addTo(map)
|
||||||
|
}
|
||||||
|
|
||||||
|
function addMarkerLayer(geoJSON, map, zoomLevel) {
|
||||||
|
var viewCoords = [geoJSON[0].geometry.coordinates[1], geoJSON[0].geometry.coordinates[0]]
|
||||||
|
var markerLayer = L.mapbox.markerLayer(geoJSON)
|
||||||
|
markerLayer.setGeoJSON(geoJSON)
|
||||||
|
map.setView(viewCoords, zoomLevel)
|
||||||
|
// map.fitBounds(geoJSON)
|
||||||
|
markerLayer.addTo(map)
|
||||||
|
return markerLayer
|
||||||
|
}
|
||||||
|
|
||||||
|
// moved to be used on the .html page for now
|
||||||
|
// until I find a better way for users to pass in their
|
||||||
|
// customized popup html styles
|
||||||
|
// function addPopups(map, markerLayer, popupContent) {
|
||||||
|
// markerLayer.on('click', function(e) {
|
||||||
|
// var feature = e.layer.feature
|
||||||
|
// var popupContent = '<h2>' + feature.opts.city + '</h2>' +
|
||||||
|
// '<h3>' + feature.opts.placename + '</h3>'
|
||||||
|
// e.layer.bindPopup(popupContent,{closeButton: false,})
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // // // // // // // // // // // // // // // // // // // // // // // //
|
||||||
|
//
|
||||||
|
// // // // // D3 Charts
|
||||||
|
//
|
||||||
|
// // // // // // // // // // // // // // // // // // // // // // // // //
|
||||||
|
|
||||||
|
// Bar Chart
|
||||||
|
// Adapted mostly from http://bl.ocks.org/mbostock/3885705
|
||||||
|
|
||||||
|
function d3BarChart(data, options) {
|
||||||
|
|
||||||
|
// m = [t0, r1, b2, l3]
|
||||||
|
var m = options.m,
|
||||||
|
w = options.w - m[1] - m[3],
|
||||||
|
h = options.h - (m[0] + m[2])
|
||||||
|
var format = d3.format(",.0f")
|
||||||
|
|
||||||
|
var x = d3.scale.linear().range([0, w]),
|
||||||
|
y = d3.scale.ordinal().rangeRoundBands([0, h], .1)
|
||||||
|
|
||||||
|
var xAxis = d3.svg.axis().scale(x).orient("top").tickSize(-h).tickFormat(d3.format("1s")),
|
||||||
|
yAxis = d3.svg.axis().scale(y).orient("left").tickSize(0)
|
||||||
|
|
||||||
|
var svg = d3.select(options.div).append("svg")
|
||||||
|
.attr("width", w + m[1] + m[3])
|
||||||
|
.attr("height", h + m[0] + m[2])
|
||||||
|
.append("g")
|
||||||
|
.attr("transform", "translate(" + m[3] + "," + m[0] + ")")
|
||||||
|
|
||||||
|
x.domain([0, d3.max(data, function(d) { return d.units })]) // 0 to max of units
|
||||||
|
y.domain(data.map(function(d) { return d.label })) // makes array of labels
|
||||||
|
|
||||||
|
var mouseOver = function() {
|
||||||
|
var rect = d3.select(this)
|
||||||
|
var indexValue = rect.attr("index_value")
|
||||||
|
|
||||||
|
var barSelector = "." + "rect-" + indexValue
|
||||||
|
var selectedBar = d3.selectAll(barSelector)
|
||||||
|
selectedBar.style("fill", options.hiColor)
|
||||||
|
|
||||||
|
var valueSelector = "." + "value-" + indexValue
|
||||||
|
var selectedValue = d3.selectAll(valueSelector)
|
||||||
|
selectedValue.style("fill", options.hiColor)
|
||||||
|
|
||||||
|
var textSelector = "." + "labels-" + indexValue
|
||||||
|
var selectedText = d3.selectAll(textSelector)
|
||||||
|
selectedText.style("fill", options.hiColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
var mouseOut = function() {
|
||||||
|
var rect = d3.select(this)
|
||||||
|
var indexValue = rect.attr("index_value")
|
||||||
|
|
||||||
|
var barSelector = "." + "rect-" + indexValue
|
||||||
|
var selectedBar = d3.selectAll(barSelector)
|
||||||
|
selectedBar.style("fill", function(d) { return d.hexcolor})
|
||||||
|
|
||||||
|
var valueSelector = "." + "value-" + indexValue
|
||||||
|
var selectedValue = d3.selectAll(valueSelector)
|
||||||
|
selectedValue.style("fill", "#333333")
|
||||||
|
|
||||||
|
var textSelector = "." + "labels-" + indexValue
|
||||||
|
var selectedText = d3.selectAll(textSelector)
|
||||||
|
selectedText.style("fill", "#333")
|
||||||
|
}
|
||||||
|
|
||||||
|
var bar = svg.selectAll("g.bar")
|
||||||
|
.data(data)
|
||||||
|
.enter().append("g")
|
||||||
|
.attr("class", "bar")
|
||||||
|
.attr("transform", function(d) { return "translate(0," + y(d.label) + ")" })
|
||||||
|
|
||||||
|
bar.append("text")
|
||||||
|
.attr("x", function(d) { return x(d.units) })
|
||||||
|
.attr("y", y.rangeBand() / 2)
|
||||||
|
.attr("dx", 12)
|
||||||
|
.attr("dy", ".35em")
|
||||||
|
.attr("text-anchor", "end")
|
||||||
|
.attr("index_value", function(d, i) { return "index-" + i })
|
||||||
|
.text(function(d) { return format(d.units) })
|
||||||
|
.attr("class", function(d, i) { return "value-" + "index-" + i })
|
||||||
|
.on('mouseover', mouseOver)
|
||||||
|
.on("mouseout", mouseOut)
|
||||||
|
|
||||||
|
bar.append("text")
|
||||||
|
.attr("x", -5)
|
||||||
|
.attr("y", y.rangeBand() / 2)
|
||||||
|
.attr("dx", 0)
|
||||||
|
.attr("dy", ".35em")
|
||||||
|
.attr("text-anchor", "end")
|
||||||
|
.attr("index_value", function(d, i) { return "index-" + i })
|
||||||
|
.text(function(d) { return d.label })
|
||||||
|
.attr("class", function(d, i) { return "value-" + "index-" + i })
|
||||||
|
.on('mouseover', mouseOver)
|
||||||
|
.on("mouseout", mouseOut)
|
||||||
|
|
||||||
|
bar.append("rect")
|
||||||
|
.attr("width", function(d) { return x(d.units)})
|
||||||
|
.attr("height", y.rangeBand())
|
||||||
|
.attr("index_value", function(d, i) { return "index-" + i })
|
||||||
|
.style("fill", function(d) { return d.hexcolor})
|
||||||
|
.on('mouseover', mouseOver)
|
||||||
|
.on("mouseout", mouseOut)
|
||||||
|
.attr("class", function(d, i) { return "rect-" + "index-" + i })
|
||||||
|
|
||||||
|
svg.append("g")
|
||||||
|
.attr("class", "x axis")
|
||||||
|
.call(xAxis)
|
||||||
|
.append("text")
|
||||||
|
// .attr("transform", "rotate(-90)")
|
||||||
|
.attr("y", -20)
|
||||||
|
.attr("x", m[1])
|
||||||
|
.attr("class", "xLabel")
|
||||||
|
.style("text-anchor", "end")
|
||||||
|
.text(function() {
|
||||||
|
if (options.xaxis) return options.xaxis
|
||||||
|
return
|
||||||
|
})
|
||||||
|
|
||||||
|
d3.select("input").on("change", change)
|
||||||
|
|
||||||
|
function change() {
|
||||||
|
// Copy-on-write since in betweens are evaluated after a delay.
|
||||||
|
var y0 = y.domain(data.sort(this.checked
|
||||||
|
? function(a, b) { return b.units - a.units }
|
||||||
|
: function(a, b) { return d3.ascending(a.label, b.label) })
|
||||||
|
.map(function(d) { return d.label }))
|
||||||
|
.copy()
|
||||||
|
|
||||||
|
var transition = svg.transition().duration(750),
|
||||||
|
delay = function(d, i) { return i * 50 }
|
||||||
|
|
||||||
|
transition.selectAll(".bar")
|
||||||
|
.delay(delay)
|
||||||
|
.attr("transform", function(d) { return "translate(0," + y(d.label) + ")" })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pie Chart
|
||||||
|
|
||||||
|
function d3PieChart(data, options) {
|
||||||
|
var width = options.w,
|
||||||
|
height = options.h,
|
||||||
|
radius = Math.min(width, height) / 2.3
|
||||||
|
|
||||||
|
var arc = d3.svg.arc()
|
||||||
|
.outerRadius(radius - 10)
|
||||||
|
.innerRadius(0)
|
||||||
|
|
||||||
|
var arcOver = d3.svg.arc()
|
||||||
|
.outerRadius(radius + .1)
|
||||||
|
|
||||||
|
var pie = d3.layout.pie()
|
||||||
|
.sort(null)
|
||||||
|
.value(function(d) { return d.units })
|
||||||
|
|
||||||
|
var svg = d3.select(options.div).append("svg")
|
||||||
|
.attr("width", width)
|
||||||
|
.attr("height", height)
|
||||||
|
.append("g")
|
||||||
|
.attr("transform", "translate(" + width / 3 + "," + height / 2 + ")")
|
||||||
|
|
||||||
|
var data = data
|
||||||
|
|
||||||
|
data.forEach(function(d) {
|
||||||
|
d.units = +d.units
|
||||||
|
})
|
||||||
|
function mouseOver(d) {
|
||||||
|
d3.select(this).select("path").transition()
|
||||||
|
.duration(500)
|
||||||
|
.attr("d", arcOver)
|
||||||
|
var slice = d3.select(this)
|
||||||
|
var indexValue = slice.attr("index_value")
|
||||||
|
|
||||||
|
var pathSelector = "." + "path-" + indexValue
|
||||||
|
var selectedPath = d3.selectAll(pathSelector)
|
||||||
|
selectedPath.style("fill", options.hiColor)
|
||||||
|
|
||||||
|
var textSelector = "." + "labels-" + indexValue
|
||||||
|
var selectedText = d3.selectAll(textSelector)
|
||||||
|
selectedText.transition()
|
||||||
|
.duration(150)
|
||||||
|
.style("font-size", "12px").style("font-weight", "bold").style("fill", options.hiColor)
|
||||||
|
selectedText.attr("class", function(d, i) { return "labels-" + indexValue + " bigg" })
|
||||||
|
}
|
||||||
|
function mouseOut(d) {
|
||||||
|
d3.select(this).select("path").transition()
|
||||||
|
.duration(150)
|
||||||
|
.attr("d", arc)
|
||||||
|
var slice = d3.select(this)
|
||||||
|
var indexValue = slice.attr("index_value")
|
||||||
|
|
||||||
|
var pathSelector = "." + "path-" + indexValue
|
||||||
|
var selectedPath = d3.selectAll(pathSelector)
|
||||||
|
selectedPath.style("fill", function(d) { return d.data.hexcolor })
|
||||||
|
|
||||||
|
var textSelector = "." + "labels-" + indexValue
|
||||||
|
var selectedText = d3.selectAll(textSelector)
|
||||||
|
selectedText.transition()
|
||||||
|
.duration(200)
|
||||||
|
.style("font-size", "10px").style("font-weight", "normal").style("fill", function(d) { return d.hexcolor })
|
||||||
|
}
|
||||||
|
|
||||||
|
var g = svg.selectAll(".arc")
|
||||||
|
.data(pie(data))
|
||||||
|
.enter().append("g")
|
||||||
|
.attr("index_value", function(d, i) { return "index-" + i })
|
||||||
|
.attr("class", function(d, i) { return "slice-" + "index-" + i + " slice arc" })
|
||||||
|
.on("mouseover", mouseOver)
|
||||||
|
.on("mouseout", mouseOut)
|
||||||
|
|
||||||
|
var path = g.append("path")
|
||||||
|
.attr("d", arc)
|
||||||
|
.attr("index_value", function(d, i) { return "index-" + i })
|
||||||
|
.attr("class", function(d, i) { return "path-" + "index-" + i })
|
||||||
|
.style("fill", function(d) { return d.data.hexcolor})
|
||||||
|
.attr("fill", function(d) { return d.data.hexcolor})
|
||||||
|
|
||||||
|
// g.append("text")
|
||||||
|
// .attr("transform", function(d) { return "translate(" + arc.centroid(d) + ")" })
|
||||||
|
// .attr("dy", ".35em")
|
||||||
|
// .attr("dx", ".35em")
|
||||||
|
// .attr("class", "pieTip")
|
||||||
|
// .style("text-anchor", "middle")
|
||||||
|
// .text(function(d) { return d.data.units })
|
||||||
|
|
||||||
|
// var labelr = radius + 8 // radius for label anchor
|
||||||
|
// g.append("text")
|
||||||
|
// .attr("transform", function(d) {
|
||||||
|
// var c = arc.centroid(d),
|
||||||
|
// x = c[0],
|
||||||
|
// y = c[1],
|
||||||
|
// // pythagorean theorem for hypotenuse
|
||||||
|
// h = Math.sqrt(x*x + y*y)
|
||||||
|
// return "translate(" + (x/h * labelr) + ',' +
|
||||||
|
// (y/h * labelr) + ")"
|
||||||
|
// })
|
||||||
|
// .attr("dy", ".35em")
|
||||||
|
// .attr("fill", "#333")
|
||||||
|
// .attr("class", "pieTip")
|
||||||
|
// .attr("text-anchor", function(d) {
|
||||||
|
// // are we past the center?
|
||||||
|
// return (d.endAngle + d.startAngle)/2 > Math.PI ?
|
||||||
|
// "end" : "start"
|
||||||
|
// })
|
||||||
|
// .text(function(d) { return d.data.units })
|
||||||
|
|
||||||
|
// svg.selectAll("rect")
|
||||||
|
// .data(data)
|
||||||
|
// .enter().append("g")
|
||||||
|
// .append("rect")
|
||||||
|
// .attr("width", 100)
|
||||||
|
// .attr("height", 26)
|
||||||
|
// .attr("fill", function(d) { return d.hexcolor })
|
||||||
|
// .attr("x", 0)
|
||||||
|
// .attr("y", "-140px") // Controls padding to place text above bars
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
svg.selectAll("g.labels")
|
||||||
|
.data(data)
|
||||||
|
.enter().append("g") // Append legend elements
|
||||||
|
.append("text")
|
||||||
|
.attr("text-anchor", "start")
|
||||||
|
.attr("x", width / 2.5)
|
||||||
|
.attr("y", function(d, i) { return data.length + i*(data.length * 2)})
|
||||||
|
.attr("dx", 0)
|
||||||
|
.attr("dy", "-140px") // Controls padding to place text above bars
|
||||||
|
.text(function(d) { return d.label + ", " + d.units})
|
||||||
|
.style("fill", function(d) { return d.hexcolor })
|
||||||
|
.attr("index_value", function(d, i) { return "index-" + i })
|
||||||
|
.attr("class", function(d, i) { return "labels-" + "index-" + i + " aLabel "})
|
||||||
|
.on('mouseover', mouseOver)
|
||||||
|
.on("mouseout", mouseOut)
|
||||||
|
|
||||||
|
d3.select("input").on("change", change)
|
||||||
|
|
||||||
|
function change() {
|
||||||
|
console.log("checked/unchecked")
|
||||||
|
// Copy-on-write since in betweens are evaluated after a delay.
|
||||||
|
// pie.sort(function(a, b) { return b.units - a.units })
|
||||||
|
path = path.data(pie(data).sort(function(a, b) { return b.units - a.units; })); // update the data
|
||||||
|
path.attr("d", arc)
|
||||||
|
// path.transition().duration(750).attrTween("d", arcTween)
|
||||||
|
|
||||||
|
// var pie = d3.layout.pie()
|
||||||
|
// .sort(null)
|
||||||
|
// .value(function(d) { return d.units })
|
||||||
|
|
||||||
|
// function change() {
|
||||||
|
// clearTimeout(timeout);
|
||||||
|
// path = path.data(pie(dataset[this.value])); // update the data
|
||||||
|
// path.attr("d", arc); // redraw the arcs
|
||||||
|
// }
|
||||||
|
|
||||||
|
function arcTween(a) {
|
||||||
|
var i = d3.interpolate(this._current, a);
|
||||||
|
this._current = i(0);
|
||||||
|
return function(t) {
|
||||||
|
return arc(i(t));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
var transition = svg.transition().duration(750),
|
||||||
|
delay = function(d, i) { return i * 50 }
|
||||||
|
|
||||||
|
transition.selectAll(".path")
|
||||||
|
.delay(delay)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Line Chart
|
||||||
|
|
||||||
|
function d3LineChart(data, options){
|
||||||
|
// Adapted from http://bl.ocks.org/1166403 and
|
||||||
|
// http://www.d3noob.org/2013/01/adding-tooltips-to-d3js-graph.html
|
||||||
|
|
||||||
|
var m = options.m
|
||||||
|
var w = options.w - m[1] - m[3]
|
||||||
|
var h = options.h - m[0] - m[2]
|
||||||
|
var data = data
|
||||||
|
|
||||||
|
var x = d3.scale.ordinal().rangeRoundBands([0, w], 1)
|
||||||
|
x.domain(data.map(function(d) { return d.label }))
|
||||||
|
var y = d3.scale.linear().range([0, h])
|
||||||
|
y.domain([d3.max(data, function(d) { return d.units }) + 2, 0])
|
||||||
|
|
||||||
|
var line = d3.svg.line()
|
||||||
|
.x(function(d, i) { return x(i) })
|
||||||
|
.y(function(d) { return y(d) })
|
||||||
|
|
||||||
|
var graph = d3.select(options.div).append("svg:svg")
|
||||||
|
.attr("width", w + m[1] + m[3])
|
||||||
|
.attr("height", h + m[0] + m[2])
|
||||||
|
.append("svg:g")
|
||||||
|
.attr("transform", "translate(" + m[3] + "," + m[0] + ")")
|
||||||
|
|
||||||
|
var div = d3.select(options.div).append("div")
|
||||||
|
.attr("class", "tooltip")
|
||||||
|
.style("opacity", 0)
|
||||||
|
|
||||||
|
// create yAxis
|
||||||
|
var xAxis = d3.svg.axis().scale(x).tickSize(-h).tickSubdivide(true)
|
||||||
|
// Add the x-axis.
|
||||||
|
graph.append("svg:g")
|
||||||
|
.attr("class", "x axis")
|
||||||
|
.attr("transform", "translate(0," + h + ")")
|
||||||
|
.call(xAxis)
|
||||||
|
.selectAll("text")
|
||||||
|
.style("text-anchor", "end")
|
||||||
|
.attr("dy", "-.5em")
|
||||||
|
.attr('dx', "-1em")
|
||||||
|
.attr("transform", "rotate(-80)")
|
||||||
|
.call(xAxis)
|
||||||
|
|
||||||
|
// create left yAxis
|
||||||
|
var yAxisLeft = d3.svg.axis().scale(y).ticks(4).tickSize(-w).tickSubdivide(true).orient("left")
|
||||||
|
// Add the y-axis to the left
|
||||||
|
graph.append("svg:g")
|
||||||
|
.attr("class", "y axis")
|
||||||
|
.attr("dx", "25")
|
||||||
|
.attr("transform", "translate(0,0)")
|
||||||
|
.call(yAxisLeft)
|
||||||
|
.append("text")
|
||||||
|
.attr("transform", "rotate(-90)")
|
||||||
|
.attr("y", -40)
|
||||||
|
.attr("dy", 0)
|
||||||
|
.style("text-anchor", "end")
|
||||||
|
.text(function() {
|
||||||
|
if (options.yaxis) return options.yaxis
|
||||||
|
return
|
||||||
|
})
|
||||||
|
|
||||||
|
var lineData = data.map(function(d) { return d.units })
|
||||||
|
graph.append("svg:path")
|
||||||
|
.attr("d", line(lineData))
|
||||||
|
.attr("class", "chartLine")
|
||||||
|
.attr("index_value", function(d, i) { return i })
|
||||||
|
// .attr("stroke", options.hiColor).attr("fill", "none")
|
||||||
|
|
||||||
|
graph.selectAll("dot")
|
||||||
|
.data(data)
|
||||||
|
.enter().append("circle")
|
||||||
|
.attr("r", 3.5)
|
||||||
|
.attr("fill", options.hiColor)
|
||||||
|
.attr("cx", function(d) { return x(d.label); })
|
||||||
|
.attr("cy", function(d) { return y(d.units); })
|
||||||
|
.on("mouseover", function(d) {
|
||||||
|
div.transition().duration(200).style("opacity", .9)
|
||||||
|
div .html(d.label + ", " + d.units)
|
||||||
|
.style("left", (d3.event.pageX) + "px")
|
||||||
|
.style("top", (d3.event.pageY - 28) + "px")
|
||||||
|
})
|
||||||
|
.on("mouseout", function(d) {
|
||||||
|
div.transition().duration(500).style("opacity", 0)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// tables
|
||||||
|
exports.searchTable = searchTable
|
||||||
|
exports.initiateTableFilter = initiateTableFilter
|
||||||
|
exports.makeTable = makeTable
|
||||||
|
exports.sendToSort = sendToSort
|
||||||
|
exports.resolveDataTitle = resolveDataTitle
|
||||||
|
exports.sortThings = sortThings
|
||||||
|
// charts
|
||||||
|
exports.d3LineChart = d3LineChart
|
||||||
|
exports.d3PieChart = d3PieChart
|
||||||
|
exports.d3BarChart = d3BarChart
|
||||||
|
// maps
|
||||||
|
exports.createGeoJSON = createGeoJSON
|
||||||
|
// exports.addPopups = addPopups
|
||||||
|
exports.addMarkerLayer = addMarkerLayer
|
||||||
|
exports.addTileLayer = addTileLayer
|
||||||
|
exports.loadMap = loadMap
|
||||||
|
// data
|
||||||
|
exports.makeArrayOfObject = makeArrayOfObject
|
||||||
|
exports.makeColorArrayOfObject = makeColorArrayOfObject
|
||||||
|
exports.mostFrequent = mostFrequent
|
||||||
|
exports.addUnitsLabels = addUnitsLabels
|
||||||
|
exports.getOccurance = getOccurance
|
||||||
|
exports.getMatches = getMatches
|
||||||
|
exports.getGroupCount = getGroupCount
|
||||||
|
exports.getColumnTotal = getColumnTotal
|
||||||
|
exports.getMax = getMax
|
||||||
|
exports.getMin = getMin
|
||||||
|
exports.getColumnAverage = getColumnAverage
|
||||||
|
}
|
||||||
|
var Sheetsee = {}
|
||||||
|
exportFunctions(Sheetsee)
|
34
license.md
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# Hi License!
|
||||||
|
|
||||||
|
## This repo is BSD licensed.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms, with or
|
||||||
|
without modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of Yahoo! Inc. nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of Yahoo! Inc.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
1
node_modules/.bin/beefy
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../beefy/bin/beefy
|
1
node_modules/.bin/browserify
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../browserify/bin/cmd.js
|
1
node_modules/.bin/browservefy
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../browservefy/bin/browservefy
|
1
node_modules/.bin/ecstatic
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../ecstatic/lib/ecstatic.js
|
1
node_modules/.bin/marked
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../marked/bin/marked
|
1
node_modules/beefy/.npmignore
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
node_modules
|
60
node_modules/beefy/README.md
generated
vendored
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
# beefy
|
||||||
|
|
||||||
|
a local development server designed to work with browserify.
|
||||||
|
|
||||||
|
it:
|
||||||
|
|
||||||
|
* can live relaod your browser when your code changes (if you want)
|
||||||
|
* works with whatever version of browserify; globally installed or
|
||||||
|
locally installed to `node_modules/browserify`.
|
||||||
|
* will spit compile errors out into the browser so you don't have that
|
||||||
|
1-2 seconds of cognitive dissonance and profound ennui that follows
|
||||||
|
refreshing the page only to get a blank screen.
|
||||||
|
* will spit out a default `index.html` for missing routes so you don't
|
||||||
|
need to even muck about with HTML to get started
|
||||||
|
* serves up static files with grace and aplomb (and also appropriate
|
||||||
|
mimetypes)
|
||||||
|
* makes it easy to sanity check your [testling ci tape test suite](http://npm.im/tape/).
|
||||||
|
* loves you, unconditionally
|
||||||
|
|
||||||
|
## how do I get it?
|
||||||
|
|
||||||
|
`npm install -g beefy`; and if you want to always have a browserify available
|
||||||
|
for beefy to use, `npm install -g browserify`.
|
||||||
|
|
||||||
|
## usage
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
$ cd directory/you/want/served
|
||||||
|
$ beefy path/to/thing/you/want/browserified.js PORT -- [browserify args]
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `path/to/file.js`
|
||||||
|
|
||||||
|
the path to the file you want browserified. can be just a normal node module.
|
||||||
|
you can also alias it: `path/to/file.js:bundle.js` if you want -- so all requests
|
||||||
|
to `bundle.js` will browserify `path/to/file.js`. this is helpful for when you're
|
||||||
|
writing `gh-pages`-style sites that already have an index.html, and expect the
|
||||||
|
bundle to be pregenerated and available at a certain path.
|
||||||
|
|
||||||
|
#### `--browserify command`
|
||||||
|
|
||||||
|
use `command` instead of `browserify` or `./node_modules/.bin/browserify`.
|
||||||
|
|
||||||
|
in theory, you could even get this working with `r.js`, but that would probably
|
||||||
|
be scary and bats would fly out of it. but it's there if you need it!
|
||||||
|
|
||||||
|
#### `--live`
|
||||||
|
|
||||||
|
enable live reloading. this'll start up a sideband server and an `fs` watch on
|
||||||
|
the current working directory -- if you save a file, your browser will refresh.
|
||||||
|
|
||||||
|
## the fake index
|
||||||
|
|
||||||
|
by default, if you get a URL that doesn't exist (with an `Accept` header that has `html` in it someplace), you'll get the "fake index." this page is setup so that
|
||||||
|
it automatically includes both the live reload script (if it's enabled) **and** the
|
||||||
|
path you want browserified.
|
||||||
|
|
||||||
|
## license
|
||||||
|
|
||||||
|
MIT
|
2
node_modules/beefy/bin/beefy
generated
vendored
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
require('../index')
|
11
node_modules/beefy/fake_index.html
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Browservefy</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{{ EXTRA }}
|
||||||
|
<script src="{{ PATH }}" type="text/javascript"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
38
node_modules/beefy/help.js
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
module.exports = help
|
||||||
|
|
||||||
|
function help() {
|
||||||
|
/*
|
||||||
|
beefy path/to/entry.js[:as.js] [PORT] -- [arguments to forward to browserify command]
|
||||||
|
|
||||||
|
Spins up a development server on ``http://localhost:PORT`` for working with static
|
||||||
|
files and browserifiable JavaScript modules.
|
||||||
|
|
||||||
|
If there's a path it doesn't recognize, it will serve up an empty HTML file with
|
||||||
|
your javascript entry point included as a script tag. Otherwise you can provide
|
||||||
|
your own ``index.html``.
|
||||||
|
|
||||||
|
All arguments after ``--`` are forwarded to the ``browserify-command``.
|
||||||
|
|
||||||
|
When the browser requests your entry point, it will run ``browserify-command`` with
|
||||||
|
the forwarded arguments on the file and pipe the results into the response.
|
||||||
|
|
||||||
|
If no PORT is defined, it defaults to 9966.
|
||||||
|
|
||||||
|
If you specify your file in the form ``realfile.js:as-file.js``, any request to
|
||||||
|
``as-file.js`` will browserify ``realfile.js`` and return it as the output.
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
|
||||||
|
--browserify command The command to run to compile your entry point.
|
||||||
|
If not provided, defaults to ``./node_modules/.bin/browserify``,
|
||||||
|
and falls back to ``which browserify`` if that's not
|
||||||
|
available.
|
||||||
|
|
||||||
|
--live Enable live reloading. Reloads the page every time
|
||||||
|
your JavaScript changes.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var str = help+''
|
||||||
|
|
||||||
|
process.stdout.write(str.slice(str.indexOf('/*')+3, str.indexOf('*/')))
|
||||||
|
}
|
216
node_modules/beefy/index.js
generated
vendored
Normal file
@ -0,0 +1,216 @@
|
|||||||
|
var http = require('http')
|
||||||
|
, spawn = require('child_process').spawn
|
||||||
|
, url = require('url')
|
||||||
|
, path = require('path')
|
||||||
|
, fs = require('fs')
|
||||||
|
|
||||||
|
var filed = require('filed')
|
||||||
|
, LiveReloadServer = require('live-reload')
|
||||||
|
, response_stream = require('response-stream')
|
||||||
|
, optimist = require('optimist').argv
|
||||||
|
, colors = require('colors')
|
||||||
|
, through = require('through')
|
||||||
|
|
||||||
|
var help = require('./help')
|
||||||
|
, fake_index_html = fs.readFileSync(path.join(__dirname, 'fake_index.html'), 'utf8')
|
||||||
|
|
||||||
|
var argv = process.argv.slice(/node/.test(process.argv[0]) ? 2 : 1)
|
||||||
|
, CWD = process.cwd()
|
||||||
|
, browserify_path = which_browserify()
|
||||||
|
, browserify_args = null
|
||||||
|
, ENTRY_POINT_TARGET
|
||||||
|
, ENTRY_POINT_URL
|
||||||
|
, LIVE_PORT
|
||||||
|
, PORT
|
||||||
|
|
||||||
|
if(!get_args()) {
|
||||||
|
return process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
info('using '+browserify_path.replace(CWD, '.'))
|
||||||
|
|
||||||
|
var RESPONSE_MAP = [
|
||||||
|
'grey'
|
||||||
|
, 'grey'
|
||||||
|
, 'green'
|
||||||
|
, 'magenta'
|
||||||
|
, 'yellow'
|
||||||
|
, 'red'
|
||||||
|
]
|
||||||
|
|
||||||
|
http.createServer(function(req, resp) {
|
||||||
|
var parsed = url.parse(req.url, true)
|
||||||
|
, pathname = parsed.pathname.slice(1) || 'index.html'
|
||||||
|
, filepath = path.resolve(path.join(CWD, pathname))
|
||||||
|
, logged_pathname = '/'+pathname
|
||||||
|
, logged_color = null
|
||||||
|
, query = parsed.query || {}
|
||||||
|
, start = Date.now()
|
||||||
|
, bytesize = 0
|
||||||
|
, stream
|
||||||
|
, args
|
||||||
|
, bfy
|
||||||
|
|
||||||
|
if(pathname === ENTRY_POINT_URL || 'browserify' in query) {
|
||||||
|
args = [
|
||||||
|
pathname === ENTRY_POINT_URL ? ENTRY_POINT_TARGET : filepath
|
||||||
|
].concat(browserify_args)
|
||||||
|
|
||||||
|
logged_pathname = logged_pathname + ' -> ' + [browserify_path]
|
||||||
|
.concat(args)
|
||||||
|
.map(function(xxx) { return xxx.replace(CWD, '.') })
|
||||||
|
.join(' ').magenta
|
||||||
|
|
||||||
|
bfy = spawn(browserify_path, args)
|
||||||
|
stream = response_stream(bfy.stdout)
|
||||||
|
|
||||||
|
logged_color = 'underline'
|
||||||
|
stream.setHeader('content-type', 'text/javascript')
|
||||||
|
|
||||||
|
bfy.stderr.pipe(process.stdout)
|
||||||
|
var error = []
|
||||||
|
bfy.stderr.on('data', [].push.bind(error))
|
||||||
|
bfy.stderr.on('end', function() {
|
||||||
|
if(error.length) {
|
||||||
|
bfyerror(error.join(''))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else if(fs.existsSync(filepath)) {
|
||||||
|
stream = fs.createReadStream(filepath)
|
||||||
|
} else if(/html/.test(req.headers.accept || '')) {
|
||||||
|
logged_pathname = logged_pathname.blue + ' ' + '(generated)'.grey
|
||||||
|
stream = response_stream(fake_index(query))
|
||||||
|
stream.setHeader('content-type', 'text/html')
|
||||||
|
} else {
|
||||||
|
stream = response_stream(through())
|
||||||
|
stream.writeHead(404, {'content-type': 'text/plain'})
|
||||||
|
process.nextTick(function() {
|
||||||
|
stream.end('not found')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
stream.pipe(resp)
|
||||||
|
stream.on('end', log)
|
||||||
|
stream.on('data', function(data) {
|
||||||
|
bytesize += data.length
|
||||||
|
})
|
||||||
|
|
||||||
|
function log() {
|
||||||
|
var code = resp.statusCode + ''
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
code[RESPONSE_MAP[code.charAt(0)]] + ' '
|
||||||
|
+ pad(Date.now() - start + 'ms', 6) + ' '
|
||||||
|
+ pad(sized(bytesize), 9).grey + ' '
|
||||||
|
+ logged_pathname
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function bfyerror(data) {
|
||||||
|
resp.end('('+function(error) {
|
||||||
|
var pre = document.createElement('pre')
|
||||||
|
pre.textContent = error
|
||||||
|
document.body.children.length ?
|
||||||
|
document.body.insertBefore(pre, document.body.children[0]) :
|
||||||
|
document.body.appendChild(pre)
|
||||||
|
}+'('+JSON.stringify(data+'')+'))')
|
||||||
|
}
|
||||||
|
}).listen(PORT)
|
||||||
|
|
||||||
|
if(optimist.live) {
|
||||||
|
LIVE_PORT = optimist.live === true ? 9967 : optimist.live
|
||||||
|
|
||||||
|
LiveReloadServer({
|
||||||
|
port: LIVE_PORT
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function fake_index(query) {
|
||||||
|
var stream = through()
|
||||||
|
, index_path
|
||||||
|
, live_text
|
||||||
|
, html
|
||||||
|
|
||||||
|
index_path = query.p || ENTRY_POINT_URL.replace(CWD, '')
|
||||||
|
|
||||||
|
if(query.p) {
|
||||||
|
index_path += '?browserify'
|
||||||
|
}
|
||||||
|
|
||||||
|
live_text = '<script src="http://localhost:' + LIVE_PORT + '"></script>'
|
||||||
|
html = fake_index_html
|
||||||
|
.replace('{{ PATH }}', index_path)
|
||||||
|
.replace('{{ EXTRA }}', LIVE_PORT ? live_text : '')
|
||||||
|
|
||||||
|
process.nextTick(function() {
|
||||||
|
stream.end(html)
|
||||||
|
})
|
||||||
|
|
||||||
|
return stream
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_args() {
|
||||||
|
if(!argv.length || optimist.h || optimist.help) {
|
||||||
|
return help()
|
||||||
|
}
|
||||||
|
|
||||||
|
for(var i = 0, len = argv.length; i < len; ++i) {
|
||||||
|
if(argv[i] === '--') {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
browserify_args = argv.splice(i+1, argv.length - i)
|
||||||
|
|
||||||
|
argv[0] = argv[0].split(':')
|
||||||
|
ENTRY_POINT_TARGET = argv[0][0]
|
||||||
|
ENTRY_POINT_URL = argv[0][~~(1 % argv[0].length)]
|
||||||
|
ENTRY_POINT_TARGET = path.resolve(
|
||||||
|
path.join(CWD, ENTRY_POINT_TARGET)
|
||||||
|
)
|
||||||
|
ENTRY_POINT_URL = ENTRY_POINT_URL.replace(/^\.\//g, '')
|
||||||
|
|
||||||
|
|
||||||
|
PORT = +argv[1] || 9966
|
||||||
|
info('listening on '+PORT)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
function which_browserify() {
|
||||||
|
if(optimist.browserify) {
|
||||||
|
return optimist.browserify
|
||||||
|
}
|
||||||
|
|
||||||
|
var local = path.join(CWD, 'node_modules/.bin/browserify')
|
||||||
|
if(fs.existsSync(local)) {
|
||||||
|
return local
|
||||||
|
}
|
||||||
|
return 'browserify'
|
||||||
|
}
|
||||||
|
|
||||||
|
function info(what) {
|
||||||
|
console.log(what.grey)
|
||||||
|
}
|
||||||
|
|
||||||
|
function sized(bytesize) {
|
||||||
|
var powers = ['B', 'KB', 'MB', 'GB']
|
||||||
|
, curr
|
||||||
|
, next
|
||||||
|
|
||||||
|
for(var i = 0, len = powers.length; i < len; ++i) {
|
||||||
|
curr = Math.pow(1024, i)
|
||||||
|
next = Math.pow(1024, i + 1)
|
||||||
|
|
||||||
|
if(bytesize < next) {
|
||||||
|
return (bytesize / curr).toFixed(2).replace(/\.?0+$/g, '') + powers[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (bytesize / curr) + 'gib'
|
||||||
|
}
|
||||||
|
|
||||||
|
function pad(s, n, w) {
|
||||||
|
while(s.length < n) {
|
||||||
|
s = (w || ' ') + s
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
1
node_modules/beefy/node_modules/.bin/live-reload
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../live-reload/bin/reload.js
|
22
node_modules/beefy/node_modules/colors/MIT-LICENSE.txt
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
Copyright (c) 2010
|
||||||
|
|
||||||
|
Marak Squires
|
||||||
|
Alexis Sellier (cloudhead)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
77
node_modules/beefy/node_modules/colors/ReadMe.md
generated
vendored
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
# colors.js - get color and style in your node.js console ( and browser ) like what
|
||||||
|
|
||||||
|
<img src="http://i.imgur.com/goJdO.png" border = "0"/>
|
||||||
|
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
npm install colors
|
||||||
|
|
||||||
|
## colors and styles!
|
||||||
|
|
||||||
|
- bold
|
||||||
|
- italic
|
||||||
|
- underline
|
||||||
|
- inverse
|
||||||
|
- yellow
|
||||||
|
- cyan
|
||||||
|
- white
|
||||||
|
- magenta
|
||||||
|
- green
|
||||||
|
- red
|
||||||
|
- grey
|
||||||
|
- blue
|
||||||
|
- rainbow
|
||||||
|
- zebra
|
||||||
|
- random
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
``` js
|
||||||
|
var colors = require('./colors');
|
||||||
|
|
||||||
|
console.log('hello'.green); // outputs green text
|
||||||
|
console.log('i like cake and pies'.underline.red) // outputs red underlined text
|
||||||
|
console.log('inverse the color'.inverse); // inverses the color
|
||||||
|
console.log('OMG Rainbows!'.rainbow); // rainbow (ignores spaces)
|
||||||
|
```
|
||||||
|
|
||||||
|
# Creating Custom themes
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
|
var require('colors');
|
||||||
|
|
||||||
|
colors.setTheme({
|
||||||
|
silly: 'rainbow',
|
||||||
|
input: 'grey',
|
||||||
|
verbose: 'cyan',
|
||||||
|
prompt: 'grey',
|
||||||
|
info: 'green',
|
||||||
|
data: 'grey',
|
||||||
|
help: 'cyan',
|
||||||
|
warn: 'yellow',
|
||||||
|
debug: 'blue',
|
||||||
|
error: 'red'
|
||||||
|
});
|
||||||
|
|
||||||
|
// outputs red text
|
||||||
|
console.log("this is an error".error);
|
||||||
|
|
||||||
|
// outputs yellow text
|
||||||
|
console.log("this is a warning".warn);
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Contributors
|
||||||
|
|
||||||
|
Marak (Marak Squires)
|
||||||
|
Alexis Sellier (cloudhead)
|
||||||
|
mmalecki (Maciej Małecki)
|
||||||
|
nicoreed (Nico Reed)
|
||||||
|
morganrallen (Morgan Allen)
|
||||||
|
JustinCampbell (Justin Campbell)
|
||||||
|
ded (Dustin Diaz)
|
||||||
|
|
||||||
|
|
||||||
|
#### , Marak Squires , Justin Campbell, Dustin Diaz (@ded)
|
269
node_modules/beefy/node_modules/colors/colors.js
generated
vendored
Normal file
@ -0,0 +1,269 @@
|
|||||||
|
/*
|
||||||
|
colors.js
|
||||||
|
|
||||||
|
Copyright (c) 2010
|
||||||
|
|
||||||
|
Marak Squires
|
||||||
|
Alexis Sellier (cloudhead)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
var isHeadless = false;
|
||||||
|
|
||||||
|
if (typeof module !== 'undefined') {
|
||||||
|
isHeadless = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isHeadless) {
|
||||||
|
var exports = {};
|
||||||
|
var module = {};
|
||||||
|
var colors = exports;
|
||||||
|
exports.mode = "browser";
|
||||||
|
} else {
|
||||||
|
exports.mode = "console";
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prototypes the string object to have additional method calls that add terminal colors
|
||||||
|
//
|
||||||
|
var addProperty = function (color, func) {
|
||||||
|
var allowOverride = ['bold'];
|
||||||
|
exports[color] = function(str) {
|
||||||
|
return func.apply(str);
|
||||||
|
};
|
||||||
|
String.prototype.__defineGetter__(color, func);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Iterate through all default styles and colors
|
||||||
|
//
|
||||||
|
|
||||||
|
var x = ['bold', 'underline', 'italic', 'inverse', 'grey', 'black', 'yellow', 'red', 'green', 'blue', 'white', 'cyan', 'magenta'];
|
||||||
|
x.forEach(function (style) {
|
||||||
|
|
||||||
|
// __defineGetter__ at the least works in more browsers
|
||||||
|
// http://robertnyman.com/javascript/javascript-getters-setters.html
|
||||||
|
// Object.defineProperty only works in Chrome
|
||||||
|
addProperty(style, function () {
|
||||||
|
return stylize(this, style);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function sequencer(map) {
|
||||||
|
return function () {
|
||||||
|
if (!isHeadless) {
|
||||||
|
return this.replace(/( )/, '$1');
|
||||||
|
}
|
||||||
|
var exploded = this.split("");
|
||||||
|
var i = 0;
|
||||||
|
exploded = exploded.map(map);
|
||||||
|
return exploded.join("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var rainbowMap = (function () {
|
||||||
|
var rainbowColors = ['red','yellow','green','blue','magenta']; //RoY G BiV
|
||||||
|
return function (letter, i, exploded) {
|
||||||
|
if (letter == " ") {
|
||||||
|
return letter;
|
||||||
|
} else {
|
||||||
|
return stylize(letter, rainbowColors[i++ % rainbowColors.length]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
exports.addSequencer = function (name, map) {
|
||||||
|
addProperty(name, sequencer(map));
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.addSequencer('rainbow', rainbowMap);
|
||||||
|
exports.addSequencer('zebra', function (letter, i, exploded) {
|
||||||
|
return i % 2 === 0 ? letter : letter.inverse;
|
||||||
|
});
|
||||||
|
|
||||||
|
exports.setTheme = function (theme) {
|
||||||
|
Object.keys(theme).forEach(function(prop){
|
||||||
|
addProperty(prop, function(){
|
||||||
|
return exports[theme[prop]](this);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function stylize(str, style) {
|
||||||
|
|
||||||
|
if (exports.mode == 'console') {
|
||||||
|
var styles = {
|
||||||
|
//styles
|
||||||
|
'bold' : ['\033[1m', '\033[22m'],
|
||||||
|
'italic' : ['\033[3m', '\033[23m'],
|
||||||
|
'underline' : ['\033[4m', '\033[24m'],
|
||||||
|
'inverse' : ['\033[7m', '\033[27m'],
|
||||||
|
//grayscale
|
||||||
|
'white' : ['\033[37m', '\033[39m'],
|
||||||
|
'grey' : ['\033[90m', '\033[39m'],
|
||||||
|
'black' : ['\033[30m', '\033[39m'],
|
||||||
|
//colors
|
||||||
|
'blue' : ['\033[34m', '\033[39m'],
|
||||||
|
'cyan' : ['\033[36m', '\033[39m'],
|
||||||
|
'green' : ['\033[32m', '\033[39m'],
|
||||||
|
'magenta' : ['\033[35m', '\033[39m'],
|
||||||
|
'red' : ['\033[31m', '\033[39m'],
|
||||||
|
'yellow' : ['\033[33m', '\033[39m']
|
||||||
|
};
|
||||||
|
} else if (exports.mode == 'browser') {
|
||||||
|
var styles = {
|
||||||
|
//styles
|
||||||
|
'bold' : ['<b>', '</b>'],
|
||||||
|
'italic' : ['<i>', '</i>'],
|
||||||
|
'underline' : ['<u>', '</u>'],
|
||||||
|
'inverse' : ['<span style="background-color:black;color:white;">', '</span>'],
|
||||||
|
//grayscale
|
||||||
|
'white' : ['<span style="color:white;">', '</span>'],
|
||||||
|
'grey' : ['<span style="color:grey;">', '</span>'],
|
||||||
|
'black' : ['<span style="color:black;">', '</span>'],
|
||||||
|
//colors
|
||||||
|
'blue' : ['<span style="color:blue;">', '</span>'],
|
||||||
|
'cyan' : ['<span style="color:cyan;">', '</span>'],
|
||||||
|
'green' : ['<span style="color:green;">', '</span>'],
|
||||||
|
'magenta' : ['<span style="color:magenta;">', '</span>'],
|
||||||
|
'red' : ['<span style="color:red;">', '</span>'],
|
||||||
|
'yellow' : ['<span style="color:yellow;">', '</span>']
|
||||||
|
};
|
||||||
|
} else if (exports.mode == 'none') {
|
||||||
|
return str;
|
||||||
|
} else {
|
||||||
|
console.log('unsupported mode, try "browser", "console" or "none"');
|
||||||
|
}
|
||||||
|
return styles[style][0] + str + styles[style][1];
|
||||||
|
};
|
||||||
|
|
||||||
|
// don't summon zalgo
|
||||||
|
addProperty('zalgo', function () {
|
||||||
|
return zalgo(this);
|
||||||
|
});
|
||||||
|
|
||||||
|
// please no
|
||||||
|
function zalgo(text, options) {
|
||||||
|
var soul = {
|
||||||
|
"up" : [
|
||||||
|
'̍','̎','̄','̅',
|
||||||
|
'̿','̑','̆','̐',
|
||||||
|
'͒','͗','͑','̇',
|
||||||
|
'̈','̊','͂','̓',
|
||||||
|
'̈','͊','͋','͌',
|
||||||
|
'̃','̂','̌','͐',
|
||||||
|
'̀','́','̋','̏',
|
||||||
|
'̒','̓','̔','̽',
|
||||||
|
'̉','ͣ','ͤ','ͥ',
|
||||||
|
'ͦ','ͧ','ͨ','ͩ',
|
||||||
|
'ͪ','ͫ','ͬ','ͭ',
|
||||||
|
'ͮ','ͯ','̾','͛',
|
||||||
|
'͆','̚'
|
||||||
|
],
|
||||||
|
"down" : [
|
||||||
|
'̖','̗','̘','̙',
|
||||||
|
'̜','̝','̞','̟',
|
||||||
|
'̠','̤','̥','̦',
|
||||||
|
'̩','̪','̫','̬',
|
||||||
|
'̭','̮','̯','̰',
|
||||||
|
'̱','̲','̳','̹',
|
||||||
|
'̺','̻','̼','ͅ',
|
||||||
|
'͇','͈','͉','͍',
|
||||||
|
'͎','͓','͔','͕',
|
||||||
|
'͖','͙','͚','̣'
|
||||||
|
],
|
||||||
|
"mid" : [
|
||||||
|
'̕','̛','̀','́',
|
||||||
|
'͘','̡','̢','̧',
|
||||||
|
'̨','̴','̵','̶',
|
||||||
|
'͜','͝','͞',
|
||||||
|
'͟','͠','͢','̸',
|
||||||
|
'̷','͡',' ҉'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
all = [].concat(soul.up, soul.down, soul.mid),
|
||||||
|
zalgo = {};
|
||||||
|
|
||||||
|
function randomNumber(range) {
|
||||||
|
r = Math.floor(Math.random()*range);
|
||||||
|
return r;
|
||||||
|
};
|
||||||
|
|
||||||
|
function is_char(character) {
|
||||||
|
var bool = false;
|
||||||
|
all.filter(function(i){
|
||||||
|
bool = (i == character);
|
||||||
|
});
|
||||||
|
return bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
function heComes(text, options){
|
||||||
|
result = '';
|
||||||
|
options = options || {};
|
||||||
|
options["up"] = options["up"] || true;
|
||||||
|
options["mid"] = options["mid"] || true;
|
||||||
|
options["down"] = options["down"] || true;
|
||||||
|
options["size"] = options["size"] || "maxi";
|
||||||
|
var counts;
|
||||||
|
text = text.split('');
|
||||||
|
for(var l in text){
|
||||||
|
if(is_char(l)) { continue; }
|
||||||
|
result = result + text[l];
|
||||||
|
|
||||||
|
counts = {"up" : 0, "down" : 0, "mid" : 0};
|
||||||
|
|
||||||
|
switch(options.size) {
|
||||||
|
case 'mini':
|
||||||
|
counts.up = randomNumber(8);
|
||||||
|
counts.min= randomNumber(2);
|
||||||
|
counts.down = randomNumber(8);
|
||||||
|
break;
|
||||||
|
case 'maxi':
|
||||||
|
counts.up = randomNumber(16) + 3;
|
||||||
|
counts.min = randomNumber(4) + 1;
|
||||||
|
counts.down = randomNumber(64) + 3;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
counts.up = randomNumber(8) + 1;
|
||||||
|
counts.mid = randomNumber(6) / 2;
|
||||||
|
counts.down= randomNumber(8) + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
var arr = ["up", "mid", "down"];
|
||||||
|
for(var d in arr){
|
||||||
|
var index = arr[d];
|
||||||
|
for (var i = 0 ; i <= counts[index]; i++)
|
||||||
|
{
|
||||||
|
if(options[index]) {
|
||||||
|
result = result + soul[index][randomNumber(soul[index].length)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
return heComes(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
addProperty('stripColors', function() {
|
||||||
|
return ("" + this).replace(/\u001b\[\d+m/g,'');
|
||||||
|
});
|
74
node_modules/beefy/node_modules/colors/example.html
generated
vendored
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html lang="en-us">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||||
|
<title>Colors Example</title>
|
||||||
|
<script src="colors.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
var test = colors.red("hopefully colorless output");
|
||||||
|
|
||||||
|
document.write('Rainbows are fun!'.rainbow + '<br/>');
|
||||||
|
document.write('So '.italic + 'are'.underline + ' styles! '.bold + 'inverse'.inverse); // styles not widely supported
|
||||||
|
document.write('Chains are also cool.'.bold.italic.underline.red); // styles not widely supported
|
||||||
|
//document.write('zalgo time!'.zalgo);
|
||||||
|
document.write(test.stripColors);
|
||||||
|
document.write("a".grey + " b".black);
|
||||||
|
|
||||||
|
document.write("Zebras are so fun!".zebra);
|
||||||
|
|
||||||
|
document.write(colors.rainbow('Rainbows are fun!'));
|
||||||
|
document.write(colors.italic('So ') + colors.underline('are') + colors.bold(' styles! ') + colors.inverse('inverse')); // styles not widely supported
|
||||||
|
document.write(colors.bold(colors.italic(colors.underline(colors.red('Chains are also cool.'))))); // styles not widely supported
|
||||||
|
//document.write(colors.zalgo('zalgo time!'));
|
||||||
|
document.write(colors.stripColors(test));
|
||||||
|
document.write(colors.grey("a") + colors.black(" b"));
|
||||||
|
|
||||||
|
colors.addSequencer("america", function(letter, i, exploded) {
|
||||||
|
if(letter === " ") return letter;
|
||||||
|
switch(i%3) {
|
||||||
|
case 0: return letter.red;
|
||||||
|
case 1: return letter.white;
|
||||||
|
case 2: return letter.blue;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
colors.addSequencer("random", (function() {
|
||||||
|
var available = ['bold', 'underline', 'italic', 'inverse', 'grey', 'yellow', 'red', 'green', 'blue', 'white', 'cyan', 'magenta'];
|
||||||
|
|
||||||
|
return function(letter, i, exploded) {
|
||||||
|
return letter === " " ? letter : letter[available[Math.round(Math.random() * (available.length - 1))]];
|
||||||
|
};
|
||||||
|
})());
|
||||||
|
|
||||||
|
document.write("AMERICA! F--K YEAH!".america);
|
||||||
|
document.write("So apparently I've been to Mars, with all the little green men. But you know, I don't recall.".random);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Custom themes
|
||||||
|
//
|
||||||
|
|
||||||
|
colors.setTheme({
|
||||||
|
silly: 'rainbow',
|
||||||
|
input: 'grey',
|
||||||
|
verbose: 'cyan',
|
||||||
|
prompt: 'grey',
|
||||||
|
info: 'green',
|
||||||
|
data: 'grey',
|
||||||
|
help: 'cyan',
|
||||||
|
warn: 'yellow',
|
||||||
|
debug: 'blue',
|
||||||
|
error: 'red'
|
||||||
|
});
|
||||||
|
|
||||||
|
// outputs red text
|
||||||
|
document.write("this is an error".error);
|
||||||
|
|
||||||
|
// outputs yellow text
|
||||||
|
document.write("this is a warning".warn);
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
65
node_modules/beefy/node_modules/colors/example.js
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
var colors = require('./colors');
|
||||||
|
|
||||||
|
//colors.mode = "browser";
|
||||||
|
|
||||||
|
var test = colors.red("hopefully colorless output");
|
||||||
|
console.log('Rainbows are fun!'.rainbow);
|
||||||
|
console.log('So '.italic + 'are'.underline + ' styles! '.bold + 'inverse'.inverse); // styles not widely supported
|
||||||
|
console.log('Chains are also cool.'.bold.italic.underline.red); // styles not widely supported
|
||||||
|
//console.log('zalgo time!'.zalgo);
|
||||||
|
console.log(test.stripColors);
|
||||||
|
console.log("a".grey + " b".black);
|
||||||
|
|
||||||
|
console.log("Zebras are so fun!".zebra);
|
||||||
|
|
||||||
|
console.log(colors.rainbow('Rainbows are fun!'));
|
||||||
|
console.log(colors.italic('So ') + colors.underline('are') + colors.bold(' styles! ') + colors.inverse('inverse')); // styles not widely supported
|
||||||
|
console.log(colors.bold(colors.italic(colors.underline(colors.red('Chains are also cool.'))))); // styles not widely supported
|
||||||
|
//console.log(colors.zalgo('zalgo time!'));
|
||||||
|
console.log(colors.stripColors(test));
|
||||||
|
console.log(colors.grey("a") + colors.black(" b"));
|
||||||
|
|
||||||
|
colors.addSequencer("america", function(letter, i, exploded) {
|
||||||
|
if(letter === " ") return letter;
|
||||||
|
switch(i%3) {
|
||||||
|
case 0: return letter.red;
|
||||||
|
case 1: return letter.white;
|
||||||
|
case 2: return letter.blue;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
colors.addSequencer("random", (function() {
|
||||||
|
var available = ['bold', 'underline', 'italic', 'inverse', 'grey', 'yellow', 'red', 'green', 'blue', 'white', 'cyan', 'magenta'];
|
||||||
|
|
||||||
|
return function(letter, i, exploded) {
|
||||||
|
return letter === " " ? letter : letter[available[Math.round(Math.random() * (available.length - 1))]];
|
||||||
|
};
|
||||||
|
})());
|
||||||
|
|
||||||
|
console.log("AMERICA! F--K YEAH!".america);
|
||||||
|
console.log("So apparently I've been to Mars, with all the little green men. But you know, I don't recall.".random);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Custom themes
|
||||||
|
//
|
||||||
|
|
||||||
|
colors.setTheme({
|
||||||
|
silly: 'rainbow',
|
||||||
|
input: 'grey',
|
||||||
|
verbose: 'cyan',
|
||||||
|
prompt: 'grey',
|
||||||
|
info: 'green',
|
||||||
|
data: 'grey',
|
||||||
|
help: 'cyan',
|
||||||
|
warn: 'yellow',
|
||||||
|
debug: 'blue',
|
||||||
|
error: 'red'
|
||||||
|
});
|
||||||
|
|
||||||
|
// outputs red text
|
||||||
|
console.log("this is an error".error);
|
||||||
|
|
||||||
|
// outputs yellow text
|
||||||
|
console.log("this is a warning".warn);
|
||||||
|
|
||||||
|
|
19
node_modules/beefy/node_modules/colors/package.json
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"name": "colors",
|
||||||
|
"description": "get colors in your node.js console like what",
|
||||||
|
"version": "0.6.0-1",
|
||||||
|
"author": {
|
||||||
|
"name": "Marak Squires"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "http://github.com/Marak/colors.js.git"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.1.90"
|
||||||
|
},
|
||||||
|
"main": "colors",
|
||||||
|
"readme": "# colors.js - get color and style in your node.js console ( and browser ) like what\n\n<img src=\"http://i.imgur.com/goJdO.png\" border = \"0\"/>\n\n\n## Installation\n\n npm install colors\n\n## colors and styles!\n\n- bold\n- italic\n- underline\n- inverse\n- yellow\n- cyan\n- white\n- magenta\n- green\n- red\n- grey\n- blue\n- rainbow\n- zebra\n- random\n\n## Usage\n\n``` js\nvar colors = require('./colors');\n\nconsole.log('hello'.green); // outputs green text\nconsole.log('i like cake and pies'.underline.red) // outputs red underlined text\nconsole.log('inverse the color'.inverse); // inverses the color\nconsole.log('OMG Rainbows!'.rainbow); // rainbow (ignores spaces)\n```\n\n# Creating Custom themes\n\n```js\n\nvar require('colors');\n\ncolors.setTheme({\n silly: 'rainbow',\n input: 'grey',\n verbose: 'cyan',\n prompt: 'grey',\n info: 'green',\n data: 'grey',\n help: 'cyan',\n warn: 'yellow',\n debug: 'blue',\n error: 'red'\n});\n\n// outputs red text\nconsole.log(\"this is an error\".error);\n\n// outputs yellow text\nconsole.log(\"this is a warning\".warn);\n```\n\n\n### Contributors \n\nMarak (Marak Squires)\nAlexis Sellier (cloudhead)\nmmalecki (Maciej Małecki)\nnicoreed (Nico Reed)\nmorganrallen (Morgan Allen)\nJustinCampbell (Justin Campbell)\nded (Dustin Diaz)\n\n\n#### , Marak Squires , Justin Campbell, Dustin Diaz (@ded)\n",
|
||||||
|
"_id": "colors@0.6.0-1",
|
||||||
|
"_from": "colors@~0.6.0-1"
|
||||||
|
}
|
65
node_modules/beefy/node_modules/colors/test.js
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
var assert = require('assert'),
|
||||||
|
colors = require('./colors');
|
||||||
|
|
||||||
|
//
|
||||||
|
// This is a pretty nice example on how tests shouldn't be written. However,
|
||||||
|
// it's more about API stability than about really testing it (although it's
|
||||||
|
// a pretty complete test suite).
|
||||||
|
//
|
||||||
|
|
||||||
|
var s = 'string';
|
||||||
|
|
||||||
|
function a(s, code) {
|
||||||
|
return '\033[' + code.toString() + 'm' + s + '\033[39m';
|
||||||
|
}
|
||||||
|
|
||||||
|
function aE(s, color, code) {
|
||||||
|
assert.equal(s[color], a(s, code));
|
||||||
|
assert.equal(colors[color](s), a(s, code));
|
||||||
|
assert.equal(s[color], colors[color](s));
|
||||||
|
assert.equal(s[color].stripColors, s);
|
||||||
|
assert.equal(s[color].stripColors, colors.stripColors(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
function h(s, color) {
|
||||||
|
return '<span style="color:' + color + ';">' + s + '</span>';
|
||||||
|
// that's pretty dumb approach to testing it
|
||||||
|
}
|
||||||
|
|
||||||
|
var stylesColors = ['white', 'grey', 'black', 'blue', 'cyan', 'green', 'magenta', 'red', 'yellow'];
|
||||||
|
var stylesAll = stylesColors.concat(['bold', 'italic', 'underline', 'inverse', 'rainbow']);
|
||||||
|
|
||||||
|
colors.mode = 'console';
|
||||||
|
assert.equal(s.bold, '\033[1m' + s + '\033[22m');
|
||||||
|
assert.equal(s.italic, '\033[3m' + s + '\033[23m');
|
||||||
|
assert.equal(s.underline, '\033[4m' + s + '\033[24m');
|
||||||
|
assert.equal(s.inverse, '\033[7m' + s + '\033[27m');
|
||||||
|
assert.ok(s.rainbow);
|
||||||
|
aE(s, 'white', 37);
|
||||||
|
aE(s, 'grey', 90);
|
||||||
|
aE(s, 'black', 30);
|
||||||
|
aE(s, 'blue', 34);
|
||||||
|
aE(s, 'cyan', 36);
|
||||||
|
aE(s, 'green', 32);
|
||||||
|
aE(s, 'magenta', 35);
|
||||||
|
aE(s, 'red', 31);
|
||||||
|
aE(s, 'yellow', 33);
|
||||||
|
assert.equal(s, 'string');
|
||||||
|
|
||||||
|
colors.mode = 'browser';
|
||||||
|
assert.equal(s.bold, '<b>' + s + '</b>');
|
||||||
|
assert.equal(s.italic, '<i>' + s + '</i>');
|
||||||
|
assert.equal(s.underline, '<u>' + s + '</u>');
|
||||||
|
assert.equal(s.inverse, '<span style="background-color:black;color:white;">' + s + '</span>');
|
||||||
|
assert.ok(s.rainbow);
|
||||||
|
stylesColors.forEach(function (color) {
|
||||||
|
assert.equal(s[color], h(s, color));
|
||||||
|
assert.equal(colors[color](s), h(s, color));
|
||||||
|
});
|
||||||
|
|
||||||
|
colors.mode = 'none';
|
||||||
|
stylesAll.forEach(function (style) {
|
||||||
|
assert.equal(s[style], s);
|
||||||
|
assert.equal(colors[style](s), s);
|
||||||
|
});
|
||||||
|
|
76
node_modules/beefy/node_modules/filed/README.md
generated
vendored
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
# filed -- Simplified file library.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
npm install filed
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
## Super simple to use
|
||||||
|
|
||||||
|
Filed does a lazy stat call so you can actually open a file and begin writing to it and if the file isn't there it will just be created.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var filed = require('filed');
|
||||||
|
var f = filed('/newfile')
|
||||||
|
f.write('test')
|
||||||
|
f.end()
|
||||||
|
```
|
||||||
|
|
||||||
|
## Streaming
|
||||||
|
|
||||||
|
The returned file object is a stream so you can do standard stream stuff to it. Based on *what* you do the object it will be a read stream, a write stream.
|
||||||
|
|
||||||
|
So if you send data to it, it'll be a write stream.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
fs.createReadStream.pipe(filed('/newfile'))
|
||||||
|
```
|
||||||
|
|
||||||
|
If you pipe it to a destination it'll be a read stream.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
filed('/myfile').pipe(fs.createWriteStream('/out'))
|
||||||
|
```
|
||||||
|
|
||||||
|
And of course you can pipe a filed object from itself to itself and it'll figure it out.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
filed('/myfile').pipe(filed('/newfile'))
|
||||||
|
```
|
||||||
|
|
||||||
|
Those familiar with [request](http://github.com/mikeal/request) will be familiar seeing object capability detection when doing HTTP. filed does this as well.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
http.createServer(function (req, resp) {
|
||||||
|
filed('/data.json').pipe(resp)
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
Not only does the JSON file get streamed to the HTTP Response it will include an Etag, Last-Modified, Content-Length, and a Content-Type header based on the filed extension.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
http.createServer(function (req, resp) {
|
||||||
|
req.pipe(filed('/newfile')).pipe(resp)
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
When accepting a PUT request data will be streamed to the file and a 201 status will be sent on the HTTP Response when the upload is finished.
|
||||||
|
|
||||||
|
During a GET request a 404 Response will be sent if the file does not exist.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
http.createServer(function (req, resp) {
|
||||||
|
req.pipe(filed('/data.json')).pipe(resp)
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
The Etag and Last-Modified headers filed creates are based solely on the stat() call so if you pipe a request to an existing file the cache control headers will be taken into account; a 304 response will be sent if the cache control headers match a new stat() call. This can be very helpful in avoiding unnecessary disc reads.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
http.createServer(function (req, resp) {
|
||||||
|
req.pipe(filed('/directory')).pipe(resp)
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
Just to round out the full feature set and make it full file server if you give filed an existing directory it will actually check for an index.html file in that directory and serve it if it exists.
|
202
node_modules/beefy/node_modules/filed/main.js
generated
vendored
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
var fs = require('fs')
|
||||||
|
, util = require('util')
|
||||||
|
, crypto = require('crypto')
|
||||||
|
, stream = require('stream')
|
||||||
|
, path = require('path')
|
||||||
|
, mimetypes = require('./mimetypes')
|
||||||
|
, rfc822 = require('./rfc822')
|
||||||
|
;
|
||||||
|
|
||||||
|
function File (options) {
|
||||||
|
stream.Stream.call(this)
|
||||||
|
|
||||||
|
this.writable = true
|
||||||
|
this.readable = true
|
||||||
|
this.buffers = []
|
||||||
|
|
||||||
|
var self = this
|
||||||
|
|
||||||
|
if (typeof options === 'string') options = {path:options}
|
||||||
|
if (!options.index) options.index = 'index.html'
|
||||||
|
self.writable = (typeof options.writable === "undefined") ? true : options.writable
|
||||||
|
self.readable = (typeof options.readable === "undefined") ? true : options.readable
|
||||||
|
|
||||||
|
self.path = options.path
|
||||||
|
self.index = options.index
|
||||||
|
|
||||||
|
self.on('pipe', function (src) {
|
||||||
|
this.src = src
|
||||||
|
})
|
||||||
|
|
||||||
|
this.buffering = true
|
||||||
|
|
||||||
|
this.mimetype = options.mimetype || mimetypes.lookup(this.path.slice(this.path.lastIndexOf('.')+1))
|
||||||
|
|
||||||
|
var stopBuffering = function () {
|
||||||
|
self.buffering = false
|
||||||
|
while (self.buffers.length) {
|
||||||
|
self.emit('data', self.buffers.shift())
|
||||||
|
}
|
||||||
|
if (self.ended) self.emit('end')
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.stat(options.path, function (err, stats) {
|
||||||
|
|
||||||
|
var finish = function (err, stats) {
|
||||||
|
self.stat = stats
|
||||||
|
if (err && err.code === 'ENOENT' && !self.dest && !self.src) self.src = self.path
|
||||||
|
if (err && !self.dest && !self.src) return self.emit('error', err)
|
||||||
|
if (err && self.dest && !self.dest.writeHead) return self.emit('error', err)
|
||||||
|
|
||||||
|
// See if writes are disabled
|
||||||
|
if (self.src && self.src.method &&
|
||||||
|
!self.writable && self.dest.writeHead &&
|
||||||
|
(self.src.method === 'PUT' || self.src.method === 'POST')) {
|
||||||
|
self.dest.writeHead(405, {'content-type':'text/plain'})
|
||||||
|
self.dest.end(self.src.method+' Not Allowed')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!err) {
|
||||||
|
self.etag = crypto.createHash('md5').update(stats.ino+'/'+stats.mtime+'/'+stats.size).digest("hex")
|
||||||
|
self.lastmodified = rfc822.getRFC822Date(stats.mtime)
|
||||||
|
}
|
||||||
|
|
||||||
|
process.nextTick(function () {
|
||||||
|
stopBuffering()
|
||||||
|
})
|
||||||
|
|
||||||
|
// 404 and 500
|
||||||
|
if ( err && self.dest && self.dest.writeHead && // We have an error object and dest is an HTTP response
|
||||||
|
( // Either we have a source and it's a GET/HEAD or we don't have a src
|
||||||
|
(self.src && (self.src.method == 'GET' || self.src.method === 'HEAD')) || (!self.src)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
if (err.code === 'ENOENT') {
|
||||||
|
self.dest.statusCode = 404
|
||||||
|
self.dest.end('Not Found')
|
||||||
|
} else {
|
||||||
|
self.dest.statusCode = 500
|
||||||
|
self.dest.end(err.message)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Source is an HTTP Server Request
|
||||||
|
if (self.src && (self.src.method === 'GET' || self.src.method === 'HEAD') && self.dest) {
|
||||||
|
if (self.dest.setHeader) {
|
||||||
|
self.dest.setHeader('content-type', self.mimetype)
|
||||||
|
self.dest.setHeader('etag', self.etag)
|
||||||
|
self.dest.setHeader('last-modified', self.lastmodified)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self.dest.writeHead) {
|
||||||
|
if (self.src && self.src.headers) {
|
||||||
|
if (self.src.headers['if-none-match'] === self.etag ||
|
||||||
|
// Lazy last-modifed matching but it's faster than parsing Datetime
|
||||||
|
self.src.headers['if-modified-since'] === self.lastmodified) {
|
||||||
|
self.dest.statusCode = 304
|
||||||
|
self.dest.end()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// We're going to return the whole file
|
||||||
|
self.dest.statusCode = 200
|
||||||
|
self.dest.setHeader('content-length', stats.size)
|
||||||
|
} else {
|
||||||
|
// Destination is not an HTTP response, GET and HEAD method are not allowed
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self.src.method !== 'HEAD') {
|
||||||
|
fs.createReadStream(self.path).pipe(self.dest)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self.src && (self.src.method === 'PUT' || self.src.method === 'POST')) {
|
||||||
|
if (!err) {
|
||||||
|
// TODO handle overwrite case
|
||||||
|
return
|
||||||
|
}
|
||||||
|
stream.Stream.prototype.pipe.call(self, fs.createWriteStream(self.path))
|
||||||
|
if (self.dest && self.dest.writeHead) {
|
||||||
|
self.on('end', function () {
|
||||||
|
self.dest.statusCode = 201
|
||||||
|
self.dest.setHeader('content-length', 0)
|
||||||
|
self.dest.end()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Desination is an HTTP response, we already handled 404 and 500
|
||||||
|
if (self.dest && self.dest.writeHead) {
|
||||||
|
self.dest.statusCode = 200
|
||||||
|
self.dest.setHeader('content-type', self.mimetype)
|
||||||
|
self.dest.setHeader('etag', self.etag)
|
||||||
|
self.dest.setHeader('last-modified', self.lastmodified)
|
||||||
|
self.dest.setHeader('content-length', stats.size)
|
||||||
|
fs.createReadStream(self.path).pipe(self.dest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destination is not an HTTP request
|
||||||
|
|
||||||
|
if (self.src && !self.dest) {
|
||||||
|
stream.Stream.prototype.pipe.call(self, fs.createWriteStream(self.path))
|
||||||
|
} else if (self.dest && !self.src) {
|
||||||
|
fs.createReadStream(self.path).pipe(self.dest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!err && stats.isDirectory()) {
|
||||||
|
self.path = path.join(self.path, self.index)
|
||||||
|
self.mimetype = mimetypes.lookup(self.path.slice(self.path.lastIndexOf('.')+1))
|
||||||
|
fs.stat(self.path, finish)
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
finish(err, stats)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!self.src && !self.dest) {
|
||||||
|
if (self.buffers.length > 0) {
|
||||||
|
stream.Stream.prototype.pipe.call(self, fs.createWriteStream(self.path))
|
||||||
|
} else if (self.listeners('data').length > 0) {
|
||||||
|
fs.createReadStream(self.path).pipe(self.dest)
|
||||||
|
} else {
|
||||||
|
fs.createReadStream(self.path).pipe(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
util.inherits(File, stream.Stream)
|
||||||
|
File.prototype.pipe = function (dest, options) {
|
||||||
|
this.dest = dest
|
||||||
|
this.destOptions = options
|
||||||
|
dest.emit('pipe', this)
|
||||||
|
// stream.Stream.prototype.pipe.call(this, dest, options)
|
||||||
|
}
|
||||||
|
File.prototype.write = function (chunk, encoding) {
|
||||||
|
if (encoding) chunk = chunk.toString(encoding)
|
||||||
|
if (this.buffering) {
|
||||||
|
this.buffers.push(chunk)
|
||||||
|
} else {
|
||||||
|
this.emit('data', chunk)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
File.prototype.end = function (chunk) {
|
||||||
|
if (chunk) this.write(chunk)
|
||||||
|
if (this.buffering) {
|
||||||
|
this.ended = true
|
||||||
|
} else {
|
||||||
|
this.emit('end')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = function (options) {
|
||||||
|
return new File(options)
|
||||||
|
}
|
||||||
|
module.exports.File = File
|
147
node_modules/beefy/node_modules/filed/mimetypes.js
generated
vendored
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
// from http://github.com/felixge/node-paperboy
|
||||||
|
exports.types = {
|
||||||
|
"aiff":"audio/x-aiff",
|
||||||
|
"arj":"application/x-arj-compressed",
|
||||||
|
"asf":"video/x-ms-asf",
|
||||||
|
"asx":"video/x-ms-asx",
|
||||||
|
"au":"audio/ulaw",
|
||||||
|
"avi":"video/x-msvideo",
|
||||||
|
"bcpio":"application/x-bcpio",
|
||||||
|
"ccad":"application/clariscad",
|
||||||
|
"cod":"application/vnd.rim.cod",
|
||||||
|
"com":"application/x-msdos-program",
|
||||||
|
"cpio":"application/x-cpio",
|
||||||
|
"cpt":"application/mac-compactpro",
|
||||||
|
"csh":"application/x-csh",
|
||||||
|
"css":"text/css",
|
||||||
|
"deb":"application/x-debian-package",
|
||||||
|
"dl":"video/dl",
|
||||||
|
"doc":"application/msword",
|
||||||
|
"drw":"application/drafting",
|
||||||
|
"dvi":"application/x-dvi",
|
||||||
|
"dwg":"application/acad",
|
||||||
|
"dxf":"application/dxf",
|
||||||
|
"dxr":"application/x-director",
|
||||||
|
"etx":"text/x-setext",
|
||||||
|
"ez":"application/andrew-inset",
|
||||||
|
"fli":"video/x-fli",
|
||||||
|
"flv":"video/x-flv",
|
||||||
|
"gif":"image/gif",
|
||||||
|
"gl":"video/gl",
|
||||||
|
"gtar":"application/x-gtar",
|
||||||
|
"gz":"application/x-gzip",
|
||||||
|
"hdf":"application/x-hdf",
|
||||||
|
"hqx":"application/mac-binhex40",
|
||||||
|
"html":"text/html",
|
||||||
|
"ice":"x-conference/x-cooltalk",
|
||||||
|
"ico":"image/x-icon",
|
||||||
|
"ief":"image/ief",
|
||||||
|
"igs":"model/iges",
|
||||||
|
"ips":"application/x-ipscript",
|
||||||
|
"ipx":"application/x-ipix",
|
||||||
|
"jad":"text/vnd.sun.j2me.app-descriptor",
|
||||||
|
"jar":"application/java-archive",
|
||||||
|
"jpeg":"image/jpeg",
|
||||||
|
"jpg":"image/jpeg",
|
||||||
|
"js":"text/javascript",
|
||||||
|
"json":"application/json",
|
||||||
|
"latex":"application/x-latex",
|
||||||
|
"lsp":"application/x-lisp",
|
||||||
|
"lzh":"application/octet-stream",
|
||||||
|
"m":"text/plain",
|
||||||
|
"m3u":"audio/x-mpegurl",
|
||||||
|
"man":"application/x-troff-man",
|
||||||
|
"me":"application/x-troff-me",
|
||||||
|
"midi":"audio/midi",
|
||||||
|
"mif":"application/x-mif",
|
||||||
|
"mime":"www/mime",
|
||||||
|
"movie":"video/x-sgi-movie",
|
||||||
|
"mustache":"text/plain",
|
||||||
|
"mp4":"video/mp4",
|
||||||
|
"mpg":"video/mpeg",
|
||||||
|
"mpga":"audio/mpeg",
|
||||||
|
"ms":"application/x-troff-ms",
|
||||||
|
"nc":"application/x-netcdf",
|
||||||
|
"oda":"application/oda",
|
||||||
|
"ogm":"application/ogg",
|
||||||
|
"pbm":"image/x-portable-bitmap",
|
||||||
|
"pdf":"application/pdf",
|
||||||
|
"pgm":"image/x-portable-graymap",
|
||||||
|
"pgn":"application/x-chess-pgn",
|
||||||
|
"pgp":"application/pgp",
|
||||||
|
"pm":"application/x-perl",
|
||||||
|
"png":"image/png",
|
||||||
|
"pnm":"image/x-portable-anymap",
|
||||||
|
"ppm":"image/x-portable-pixmap",
|
||||||
|
"ppz":"application/vnd.ms-powerpoint",
|
||||||
|
"pre":"application/x-freelance",
|
||||||
|
"prt":"application/pro_eng",
|
||||||
|
"ps":"application/postscript",
|
||||||
|
"qt":"video/quicktime",
|
||||||
|
"ra":"audio/x-realaudio",
|
||||||
|
"rar":"application/x-rar-compressed",
|
||||||
|
"ras":"image/x-cmu-raster",
|
||||||
|
"rgb":"image/x-rgb",
|
||||||
|
"rm":"audio/x-pn-realaudio",
|
||||||
|
"rpm":"audio/x-pn-realaudio-plugin",
|
||||||
|
"rtf":"text/rtf",
|
||||||
|
"rtx":"text/richtext",
|
||||||
|
"scm":"application/x-lotusscreencam",
|
||||||
|
"set":"application/set",
|
||||||
|
"sgml":"text/sgml",
|
||||||
|
"sh":"application/x-sh",
|
||||||
|
"shar":"application/x-shar",
|
||||||
|
"silo":"model/mesh",
|
||||||
|
"sit":"application/x-stuffit",
|
||||||
|
"skt":"application/x-koan",
|
||||||
|
"smil":"application/smil",
|
||||||
|
"snd":"audio/basic",
|
||||||
|
"sol":"application/solids",
|
||||||
|
"spl":"application/x-futuresplash",
|
||||||
|
"src":"application/x-wais-source",
|
||||||
|
"stl":"application/SLA",
|
||||||
|
"stp":"application/STEP",
|
||||||
|
"sv4cpio":"application/x-sv4cpio",
|
||||||
|
"sv4crc":"application/x-sv4crc",
|
||||||
|
"svg":"image/svg+xml",
|
||||||
|
"swf":"application/x-shockwave-flash",
|
||||||
|
"tar":"application/x-tar",
|
||||||
|
"tcl":"application/x-tcl",
|
||||||
|
"tex":"application/x-tex",
|
||||||
|
"texinfo":"application/x-texinfo",
|
||||||
|
"tgz":"application/x-tar-gz",
|
||||||
|
"tiff":"image/tiff",
|
||||||
|
"tr":"application/x-troff",
|
||||||
|
"tsi":"audio/TSP-audio",
|
||||||
|
"tsp":"application/dsptype",
|
||||||
|
"tsv":"text/tab-separated-values",
|
||||||
|
"txt":"text/plain",
|
||||||
|
"unv":"application/i-deas",
|
||||||
|
"ustar":"application/x-ustar",
|
||||||
|
"vcd":"application/x-cdlink",
|
||||||
|
"vda":"application/vda",
|
||||||
|
"vivo":"video/vnd.vivo",
|
||||||
|
"vrm":"x-world/x-vrml",
|
||||||
|
"wav":"audio/x-wav",
|
||||||
|
"wax":"audio/x-ms-wax",
|
||||||
|
"wma":"audio/x-ms-wma",
|
||||||
|
"wmv":"video/x-ms-wmv",
|
||||||
|
"wmx":"video/x-ms-wmx",
|
||||||
|
"wrl":"model/vrml",
|
||||||
|
"wvx":"video/x-ms-wvx",
|
||||||
|
"xbm":"image/x-xbitmap",
|
||||||
|
"xlw":"application/vnd.ms-excel",
|
||||||
|
"xml":"text/xml",
|
||||||
|
"xpm":"image/x-xpixmap",
|
||||||
|
"xwd":"image/x-xwindowdump",
|
||||||
|
"xyz":"chemical/x-pdb",
|
||||||
|
"zip":"application/zip",
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.lookup = function(ext, defaultType) {
|
||||||
|
defaultType = defaultType || 'application/octet-stream';
|
||||||
|
|
||||||
|
return (ext in exports.types)
|
||||||
|
? exports.types[ext]
|
||||||
|
: defaultType;
|
||||||
|
};
|
23
node_modules/beefy/node_modules/filed/package.json
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"name": "filed",
|
||||||
|
"description": "Simplified file library.",
|
||||||
|
"version": "0.0.7",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/mikeal/filed.git"
|
||||||
|
},
|
||||||
|
"author": {
|
||||||
|
"name": "Mikeal Rogers",
|
||||||
|
"email": "mikeal.rogers@gmail.com"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "*"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "node test/test.js"
|
||||||
|
},
|
||||||
|
"main": "./main",
|
||||||
|
"readme": "# filed -- Simplified file library.\n\n## Install\n\n<pre>\n npm install filed\n</pre>\n\n## Super simple to use\n\nFiled does a lazy stat call so you can actually open a file and begin writing to it and if the file isn't there it will just be created.\n\n```javascript\nvar filed = require('filed');\nvar f = filed('/newfile')\nf.write('test')\nf.end()\n```\n\n## Streaming\n\nThe returned file object is a stream so you can do standard stream stuff to it. Based on *what* you do the object it will be a read stream, a write stream.\n\nSo if you send data to it, it'll be a write stream.\n\n```javascript\nfs.createReadStream.pipe(filed('/newfile'))\n```\n\nIf you pipe it to a destination it'll be a read stream.\n\n```javascript\nfiled('/myfile').pipe(fs.createWriteStream('/out'))\n```\n\nAnd of course you can pipe a filed object from itself to itself and it'll figure it out.\n\n```javascript\nfiled('/myfile').pipe(filed('/newfile'))\n```\n\nThose familiar with [request](http://github.com/mikeal/request) will be familiar seeing object capability detection when doing HTTP. filed does this as well.\n\n```javascript\nhttp.createServer(function (req, resp) {\n filed('/data.json').pipe(resp)\n})\n```\n\nNot only does the JSON file get streamed to the HTTP Response it will include an Etag, Last-Modified, Content-Length, and a Content-Type header based on the filed extension.\n\n```javascript\nhttp.createServer(function (req, resp) {\n req.pipe(filed('/newfile')).pipe(resp)\n})\n```\n\nWhen accepting a PUT request data will be streamed to the file and a 201 status will be sent on the HTTP Response when the upload is finished.\n\nDuring a GET request a 404 Response will be sent if the file does not exist.\n\n```javascript\nhttp.createServer(function (req, resp) {\n req.pipe(filed('/data.json')).pipe(resp)\n})\n```\n\nThe Etag and Last-Modified headers filed creates are based solely on the stat() call so if you pipe a request to an existing file the cache control headers will be taken into account; a 304 response will be sent if the cache control headers match a new stat() call. This can be very helpful in avoiding unnecessary disc reads.\n\n```javascript\nhttp.createServer(function (req, resp) {\n req.pipe(filed('/directory')).pipe(resp)\n})\n```\n\nJust to round out the full feature set and make it full file server if you give filed an existing directory it will actually check for an index.html file in that directory and serve it if it exists.\n",
|
||||||
|
"_id": "filed@0.0.7",
|
||||||
|
"_from": "filed@0.0.7"
|
||||||
|
}
|
47
node_modules/beefy/node_modules/filed/rfc822.js
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// Support for rfc822, worst standard EVAR!
|
||||||
|
|
||||||
|
// require('./date')
|
||||||
|
|
||||||
|
function getRFC822Date(oDate)
|
||||||
|
{
|
||||||
|
var aMonths = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||||
|
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
|
||||||
|
|
||||||
|
var aDays = new Array( "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
|
||||||
|
var dtm = new String();
|
||||||
|
|
||||||
|
dtm = aDays[oDate.getDay()] + ", ";
|
||||||
|
dtm += padWithZero(oDate.getDate()) + " ";
|
||||||
|
dtm += aMonths[oDate.getMonth()] + " ";
|
||||||
|
dtm += oDate.getFullYear() + " ";
|
||||||
|
dtm += padWithZero(oDate.getHours()) + ":";
|
||||||
|
dtm += padWithZero(oDate.getMinutes()) + ":";
|
||||||
|
dtm += padWithZero(oDate.getSeconds()) + " " ;
|
||||||
|
dtm += getTZOString(oDate.getTimezoneOffset());
|
||||||
|
return dtm;
|
||||||
|
}
|
||||||
|
//Pads numbers with a preceding 0 if the number is less than 10.
|
||||||
|
function padWithZero(val)
|
||||||
|
{
|
||||||
|
if (parseInt(val) < 10)
|
||||||
|
{
|
||||||
|
return "0" + val;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* accepts the client's time zone offset from GMT in minutes as a parameter.
|
||||||
|
returns the timezone offset in the format [+|-}DDDD */
|
||||||
|
function getTZOString(timezoneOffset)
|
||||||
|
{
|
||||||
|
var hours = Math.floor(timezoneOffset/60);
|
||||||
|
var modMin = Math.abs(timezoneOffset%60);
|
||||||
|
var s = new String();
|
||||||
|
s += (hours > 0) ? "-" : "+";
|
||||||
|
var absHours = Math.abs(hours)
|
||||||
|
s += (absHours < 10) ? "0" + absHours :absHours;
|
||||||
|
s += ((modMin == 0) ? "00" : modMin);
|
||||||
|
return(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.getRFC822Date = getRFC822Date;
|
1
node_modules/beefy/node_modules/filed/test/index.html
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
test
|
20
node_modules/beefy/node_modules/filed/test/server.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
var http = require('http')
|
||||||
|
|
||||||
|
function createServer () {
|
||||||
|
var s = http.createServer(function (req, resp) {
|
||||||
|
resp.___end = resp.end
|
||||||
|
resp.end = function (chunk) {
|
||||||
|
s.completed[req.url] = true
|
||||||
|
resp.___end(chunk)
|
||||||
|
if (Object.keys(s._events).filter(function(n){return n[0] === '/'}).length === Object.keys(s.completed).length) {
|
||||||
|
setTimeout(function () {
|
||||||
|
s.close()
|
||||||
|
}, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s.emit(req.url, req, resp)
|
||||||
|
})
|
||||||
|
s.completed = {}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
module.exports = createServer;
|
209
node_modules/beefy/node_modules/filed/test/test.js
generated
vendored
Normal file
@ -0,0 +1,209 @@
|
|||||||
|
var filed = require('../main')
|
||||||
|
, server = require('./server')
|
||||||
|
, fs = require('fs')
|
||||||
|
, path = require('path')
|
||||||
|
, assert = require('assert')
|
||||||
|
, request = require('request')
|
||||||
|
, test1buffer = ''
|
||||||
|
, testfile = path.join(__dirname, 'test.js')
|
||||||
|
, writefile = path.join(__dirname, 'testdump-')
|
||||||
|
, cleanup = []
|
||||||
|
, validations = []
|
||||||
|
, port = 9090
|
||||||
|
, i = 0
|
||||||
|
, url = 'http://localhost:'+port
|
||||||
|
;
|
||||||
|
|
||||||
|
while (i < 50) {
|
||||||
|
try {fs.unlinkSync(writefile+i)}
|
||||||
|
catch (e) {}
|
||||||
|
i += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function FileValidator (path) {
|
||||||
|
this.path = path
|
||||||
|
this.buffers = []
|
||||||
|
this.len = 0
|
||||||
|
this.writable = true
|
||||||
|
}
|
||||||
|
FileValidator.prototype.write = function (chunk) {
|
||||||
|
this.buffers.push(chunk)
|
||||||
|
this.len += chunk.length
|
||||||
|
}
|
||||||
|
FileValidator.prototype.end = function () {
|
||||||
|
var body = new Buffer(this.len)
|
||||||
|
var i = 0
|
||||||
|
this.buffers.forEach(function (chunk) {
|
||||||
|
chunk.copy(body, i, 0, chunk.length)
|
||||||
|
i += chunk.length
|
||||||
|
})
|
||||||
|
var f = fs.readFileSync(this.path)
|
||||||
|
assert.equal(body.length, f.length)
|
||||||
|
assert.deepEqual(body, f)
|
||||||
|
}
|
||||||
|
FileValidator.prototype.on = function () {}
|
||||||
|
FileValidator.prototype.removeListener = function () {}
|
||||||
|
FileValidator.prototype.emit = function () {}
|
||||||
|
|
||||||
|
function equalSync (f1, f2) {
|
||||||
|
f1 = fs.readFileSync(f1)
|
||||||
|
f2 = fs.readFileSync(f2)
|
||||||
|
assert.equal(f1.length, f2.length)
|
||||||
|
assert.deepEqual(f1, f2)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test reading
|
||||||
|
filed(testfile).pipe(new FileValidator(testfile))
|
||||||
|
|
||||||
|
// Test writing
|
||||||
|
|
||||||
|
function testwrites () {
|
||||||
|
var x = filed(writefile+1)
|
||||||
|
, y = fs.createReadStream(testfile)
|
||||||
|
;
|
||||||
|
y.pipe(x)
|
||||||
|
x.on('end', function () {
|
||||||
|
setTimeout(function () {
|
||||||
|
equalSync(writefile+1, testfile)
|
||||||
|
console.log("Passed writing files")
|
||||||
|
}, 1000)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
testwrites()
|
||||||
|
|
||||||
|
function testhttp () {
|
||||||
|
// Test HTTP use cases
|
||||||
|
var s = server()
|
||||||
|
s.on('/test-req', function (req, resp) {
|
||||||
|
// Take a request and write it, do not send filed to the response
|
||||||
|
req.pipe(filed(writefile+2))
|
||||||
|
req.on('end', function () {
|
||||||
|
resp.writeHead(201)
|
||||||
|
resp.end()
|
||||||
|
setTimeout(function () {
|
||||||
|
equalSync(writefile+2, testfile)
|
||||||
|
console.log("Passed PUT file with pipe req only")
|
||||||
|
}, 1000)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
s.on('/test-req-resp', function (req, resp) {
|
||||||
|
// Take a request and write it and pipe filed to the response
|
||||||
|
var x = filed(writefile+3)
|
||||||
|
req.pipe(x)
|
||||||
|
x.pipe(resp)
|
||||||
|
req.on('end', function () {
|
||||||
|
setTimeout(function () {
|
||||||
|
equalSync(writefile+3, testfile)
|
||||||
|
console.log("Passed PUT file with pipe req and resp")
|
||||||
|
}, 1000)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
s.on('/test-resp', function (req, resp) {
|
||||||
|
// Send a file to an HTTP response
|
||||||
|
filed(testfile).pipe(resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
var fullpipe = function (req, resp) {
|
||||||
|
var x = filed(testfile)
|
||||||
|
req.pipe(x)
|
||||||
|
x.pipe(resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
s.on('/test-etags-wo', function (req, resp) {
|
||||||
|
fullpipe(req, resp)
|
||||||
|
})
|
||||||
|
s.on('/test-etags-with', function (req, resp) {
|
||||||
|
fullpipe(req, resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
s.on('/test-lastmodified-wo', function (req, resp) {
|
||||||
|
fullpipe(req, resp)
|
||||||
|
})
|
||||||
|
s.on('/test-lastmodified-with', function (req, resp) {
|
||||||
|
fullpipe(req, resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
s.on('/test-index', function (req, resp) {
|
||||||
|
var x = filed(__dirname)
|
||||||
|
x.pipe(resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
s.on('/test-index-full', function (req, resp) {
|
||||||
|
var x = filed(__dirname)
|
||||||
|
req.pipe(x)
|
||||||
|
x.pipe(resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
s.on('/test-not-found', function (req, resp) {
|
||||||
|
var x = filed(__dirname + "/there-is-no-such-file-here.no-extension")
|
||||||
|
req.pipe(x)
|
||||||
|
x.pipe(resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
s.listen(port, function () {
|
||||||
|
|
||||||
|
fs.createReadStream(testfile).pipe(request.put(url+'/test-req'))
|
||||||
|
|
||||||
|
fs.createReadStream(testfile).pipe(request.put(url+'/test-req-resp', function (e, resp) {
|
||||||
|
assert.equal(resp.statusCode, 201)
|
||||||
|
assert.equal(resp.headers['content-length'], '0')
|
||||||
|
}))
|
||||||
|
|
||||||
|
var x = request.get(url+'/test-resp', function (e, resp) {
|
||||||
|
if (e) throw e
|
||||||
|
assert.equal(resp.statusCode, 200)
|
||||||
|
assert.equal(resp.headers['content-type'], 'text/javascript')
|
||||||
|
console.log("Passed GET file without piping request")
|
||||||
|
})
|
||||||
|
x.pipe(new FileValidator(testfile))
|
||||||
|
|
||||||
|
request.get(url+'/test-etags-wo', function (e, resp, body) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 200) throw new Error('Status code is not 200 it is '+resp.statusCode)
|
||||||
|
request.get({url:url+'/test-etags-with', headers:{'if-none-match':resp.headers.etag}}, function (e, resp) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 304) throw new Error('Status code is not 304 it is '+resp.statusCode)
|
||||||
|
console.log("Passed GET with etag")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
request.get(url+'/test-lastmodified-wo', function (e, resp, body) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 200) throw new Error('Status code is not 200 it is '+resp.statusCode)
|
||||||
|
request.get({url:url+'/test-lastmodified-with', headers:{'if-modified-since':resp.headers['last-modified']}}, function (e, resp) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 304) throw new Error('Status code is not 304 it is '+resp.statusCode)
|
||||||
|
console.log("Passed GET with if-modified-since")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
request.get(url+'/test-index', function (e, resp, body) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 200) throw new Error('Status code is not 200 it is '+resp.statusCode)
|
||||||
|
assert.equal(resp.headers['content-type'], 'text/html')
|
||||||
|
assert.equal(body, fs.readFileSync(path.join(__dirname, 'index.html')).toString())
|
||||||
|
console.log("Passed GET of directory index")
|
||||||
|
})
|
||||||
|
|
||||||
|
request.get(url+'/test-index-full', function (e, resp, body) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 200) throw new Error('Status code is not 200 it is '+resp.statusCode)
|
||||||
|
assert.equal(resp.headers['content-type'], 'text/html')
|
||||||
|
assert.equal(body, fs.readFileSync(path.join(__dirname, 'index.html')).toString())
|
||||||
|
console.log("Passed GET of directory index, full pipe")
|
||||||
|
})
|
||||||
|
|
||||||
|
request.get(url+'/test-not-found', function (e, resp, body) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 404) throw new Error('Status code is not 404 it is '+resp.statusCode)
|
||||||
|
console.log("Passed Not Found produces 404")
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
testhttp()
|
||||||
|
|
||||||
|
process.on('exit', function () {console.log('All tests passed.')})
|
209
node_modules/beefy/node_modules/filed/test/testdump-1
generated
vendored
Normal file
@ -0,0 +1,209 @@
|
|||||||
|
var filed = require('../main')
|
||||||
|
, server = require('./server')
|
||||||
|
, fs = require('fs')
|
||||||
|
, path = require('path')
|
||||||
|
, assert = require('assert')
|
||||||
|
, request = require('request')
|
||||||
|
, test1buffer = ''
|
||||||
|
, testfile = path.join(__dirname, 'test.js')
|
||||||
|
, writefile = path.join(__dirname, 'testdump-')
|
||||||
|
, cleanup = []
|
||||||
|
, validations = []
|
||||||
|
, port = 9090
|
||||||
|
, i = 0
|
||||||
|
, url = 'http://localhost:'+port
|
||||||
|
;
|
||||||
|
|
||||||
|
while (i < 50) {
|
||||||
|
try {fs.unlinkSync(writefile+i)}
|
||||||
|
catch (e) {}
|
||||||
|
i += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function FileValidator (path) {
|
||||||
|
this.path = path
|
||||||
|
this.buffers = []
|
||||||
|
this.len = 0
|
||||||
|
this.writable = true
|
||||||
|
}
|
||||||
|
FileValidator.prototype.write = function (chunk) {
|
||||||
|
this.buffers.push(chunk)
|
||||||
|
this.len += chunk.length
|
||||||
|
}
|
||||||
|
FileValidator.prototype.end = function () {
|
||||||
|
var body = new Buffer(this.len)
|
||||||
|
var i = 0
|
||||||
|
this.buffers.forEach(function (chunk) {
|
||||||
|
chunk.copy(body, i, 0, chunk.length)
|
||||||
|
i += chunk.length
|
||||||
|
})
|
||||||
|
var f = fs.readFileSync(this.path)
|
||||||
|
assert.equal(body.length, f.length)
|
||||||
|
assert.deepEqual(body, f)
|
||||||
|
}
|
||||||
|
FileValidator.prototype.on = function () {}
|
||||||
|
FileValidator.prototype.removeListener = function () {}
|
||||||
|
FileValidator.prototype.emit = function () {}
|
||||||
|
|
||||||
|
function equalSync (f1, f2) {
|
||||||
|
f1 = fs.readFileSync(f1)
|
||||||
|
f2 = fs.readFileSync(f2)
|
||||||
|
assert.equal(f1.length, f2.length)
|
||||||
|
assert.deepEqual(f1, f2)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test reading
|
||||||
|
filed(testfile).pipe(new FileValidator(testfile))
|
||||||
|
|
||||||
|
// Test writing
|
||||||
|
|
||||||
|
function testwrites () {
|
||||||
|
var x = filed(writefile+1)
|
||||||
|
, y = fs.createReadStream(testfile)
|
||||||
|
;
|
||||||
|
y.pipe(x)
|
||||||
|
x.on('end', function () {
|
||||||
|
setTimeout(function () {
|
||||||
|
equalSync(writefile+1, testfile)
|
||||||
|
console.log("Passed writing files")
|
||||||
|
}, 1000)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
testwrites()
|
||||||
|
|
||||||
|
function testhttp () {
|
||||||
|
// Test HTTP use cases
|
||||||
|
var s = server()
|
||||||
|
s.on('/test-req', function (req, resp) {
|
||||||
|
// Take a request and write it, do not send filed to the response
|
||||||
|
req.pipe(filed(writefile+2))
|
||||||
|
req.on('end', function () {
|
||||||
|
resp.writeHead(201)
|
||||||
|
resp.end()
|
||||||
|
setTimeout(function () {
|
||||||
|
equalSync(writefile+2, testfile)
|
||||||
|
console.log("Passed PUT file with pipe req only")
|
||||||
|
}, 1000)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
s.on('/test-req-resp', function (req, resp) {
|
||||||
|
// Take a request and write it and pipe filed to the response
|
||||||
|
var x = filed(writefile+3)
|
||||||
|
req.pipe(x)
|
||||||
|
x.pipe(resp)
|
||||||
|
req.on('end', function () {
|
||||||
|
setTimeout(function () {
|
||||||
|
equalSync(writefile+3, testfile)
|
||||||
|
console.log("Passed PUT file with pipe req and resp")
|
||||||
|
}, 1000)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
s.on('/test-resp', function (req, resp) {
|
||||||
|
// Send a file to an HTTP response
|
||||||
|
filed(testfile).pipe(resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
var fullpipe = function (req, resp) {
|
||||||
|
var x = filed(testfile)
|
||||||
|
req.pipe(x)
|
||||||
|
x.pipe(resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
s.on('/test-etags-wo', function (req, resp) {
|
||||||
|
fullpipe(req, resp)
|
||||||
|
})
|
||||||
|
s.on('/test-etags-with', function (req, resp) {
|
||||||
|
fullpipe(req, resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
s.on('/test-lastmodified-wo', function (req, resp) {
|
||||||
|
fullpipe(req, resp)
|
||||||
|
})
|
||||||
|
s.on('/test-lastmodified-with', function (req, resp) {
|
||||||
|
fullpipe(req, resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
s.on('/test-index', function (req, resp) {
|
||||||
|
var x = filed(__dirname)
|
||||||
|
x.pipe(resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
s.on('/test-index-full', function (req, resp) {
|
||||||
|
var x = filed(__dirname)
|
||||||
|
req.pipe(x)
|
||||||
|
x.pipe(resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
s.on('/test-not-found', function (req, resp) {
|
||||||
|
var x = filed(__dirname + "/there-is-no-such-file-here.no-extension")
|
||||||
|
req.pipe(x)
|
||||||
|
x.pipe(resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
s.listen(port, function () {
|
||||||
|
|
||||||
|
fs.createReadStream(testfile).pipe(request.put(url+'/test-req'))
|
||||||
|
|
||||||
|
fs.createReadStream(testfile).pipe(request.put(url+'/test-req-resp', function (e, resp) {
|
||||||
|
assert.equal(resp.statusCode, 201)
|
||||||
|
assert.equal(resp.headers['content-length'], '0')
|
||||||
|
}))
|
||||||
|
|
||||||
|
var x = request.get(url+'/test-resp', function (e, resp) {
|
||||||
|
if (e) throw e
|
||||||
|
assert.equal(resp.statusCode, 200)
|
||||||
|
assert.equal(resp.headers['content-type'], 'text/javascript')
|
||||||
|
console.log("Passed GET file without piping request")
|
||||||
|
})
|
||||||
|
x.pipe(new FileValidator(testfile))
|
||||||
|
|
||||||
|
request.get(url+'/test-etags-wo', function (e, resp, body) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 200) throw new Error('Status code is not 200 it is '+resp.statusCode)
|
||||||
|
request.get({url:url+'/test-etags-with', headers:{'if-none-match':resp.headers.etag}}, function (e, resp) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 304) throw new Error('Status code is not 304 it is '+resp.statusCode)
|
||||||
|
console.log("Passed GET with etag")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
request.get(url+'/test-lastmodified-wo', function (e, resp, body) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 200) throw new Error('Status code is not 200 it is '+resp.statusCode)
|
||||||
|
request.get({url:url+'/test-lastmodified-with', headers:{'if-modified-since':resp.headers['last-modified']}}, function (e, resp) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 304) throw new Error('Status code is not 304 it is '+resp.statusCode)
|
||||||
|
console.log("Passed GET with if-modified-since")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
request.get(url+'/test-index', function (e, resp, body) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 200) throw new Error('Status code is not 200 it is '+resp.statusCode)
|
||||||
|
assert.equal(resp.headers['content-type'], 'text/html')
|
||||||
|
assert.equal(body, fs.readFileSync(path.join(__dirname, 'index.html')).toString())
|
||||||
|
console.log("Passed GET of directory index")
|
||||||
|
})
|
||||||
|
|
||||||
|
request.get(url+'/test-index-full', function (e, resp, body) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 200) throw new Error('Status code is not 200 it is '+resp.statusCode)
|
||||||
|
assert.equal(resp.headers['content-type'], 'text/html')
|
||||||
|
assert.equal(body, fs.readFileSync(path.join(__dirname, 'index.html')).toString())
|
||||||
|
console.log("Passed GET of directory index, full pipe")
|
||||||
|
})
|
||||||
|
|
||||||
|
request.get(url+'/test-not-found', function (e, resp, body) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 404) throw new Error('Status code is not 404 it is '+resp.statusCode)
|
||||||
|
console.log("Passed Not Found produces 404")
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
testhttp()
|
||||||
|
|
||||||
|
process.on('exit', function () {console.log('All tests passed.')})
|
209
node_modules/beefy/node_modules/filed/test/testdump-2
generated
vendored
Normal file
@ -0,0 +1,209 @@
|
|||||||
|
var filed = require('../main')
|
||||||
|
, server = require('./server')
|
||||||
|
, fs = require('fs')
|
||||||
|
, path = require('path')
|
||||||
|
, assert = require('assert')
|
||||||
|
, request = require('request')
|
||||||
|
, test1buffer = ''
|
||||||
|
, testfile = path.join(__dirname, 'test.js')
|
||||||
|
, writefile = path.join(__dirname, 'testdump-')
|
||||||
|
, cleanup = []
|
||||||
|
, validations = []
|
||||||
|
, port = 9090
|
||||||
|
, i = 0
|
||||||
|
, url = 'http://localhost:'+port
|
||||||
|
;
|
||||||
|
|
||||||
|
while (i < 50) {
|
||||||
|
try {fs.unlinkSync(writefile+i)}
|
||||||
|
catch (e) {}
|
||||||
|
i += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function FileValidator (path) {
|
||||||
|
this.path = path
|
||||||
|
this.buffers = []
|
||||||
|
this.len = 0
|
||||||
|
this.writable = true
|
||||||
|
}
|
||||||
|
FileValidator.prototype.write = function (chunk) {
|
||||||
|
this.buffers.push(chunk)
|
||||||
|
this.len += chunk.length
|
||||||
|
}
|
||||||
|
FileValidator.prototype.end = function () {
|
||||||
|
var body = new Buffer(this.len)
|
||||||
|
var i = 0
|
||||||
|
this.buffers.forEach(function (chunk) {
|
||||||
|
chunk.copy(body, i, 0, chunk.length)
|
||||||
|
i += chunk.length
|
||||||
|
})
|
||||||
|
var f = fs.readFileSync(this.path)
|
||||||
|
assert.equal(body.length, f.length)
|
||||||
|
assert.deepEqual(body, f)
|
||||||
|
}
|
||||||
|
FileValidator.prototype.on = function () {}
|
||||||
|
FileValidator.prototype.removeListener = function () {}
|
||||||
|
FileValidator.prototype.emit = function () {}
|
||||||
|
|
||||||
|
function equalSync (f1, f2) {
|
||||||
|
f1 = fs.readFileSync(f1)
|
||||||
|
f2 = fs.readFileSync(f2)
|
||||||
|
assert.equal(f1.length, f2.length)
|
||||||
|
assert.deepEqual(f1, f2)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test reading
|
||||||
|
filed(testfile).pipe(new FileValidator(testfile))
|
||||||
|
|
||||||
|
// Test writing
|
||||||
|
|
||||||
|
function testwrites () {
|
||||||
|
var x = filed(writefile+1)
|
||||||
|
, y = fs.createReadStream(testfile)
|
||||||
|
;
|
||||||
|
y.pipe(x)
|
||||||
|
x.on('end', function () {
|
||||||
|
setTimeout(function () {
|
||||||
|
equalSync(writefile+1, testfile)
|
||||||
|
console.log("Passed writing files")
|
||||||
|
}, 1000)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
testwrites()
|
||||||
|
|
||||||
|
function testhttp () {
|
||||||
|
// Test HTTP use cases
|
||||||
|
var s = server()
|
||||||
|
s.on('/test-req', function (req, resp) {
|
||||||
|
// Take a request and write it, do not send filed to the response
|
||||||
|
req.pipe(filed(writefile+2))
|
||||||
|
req.on('end', function () {
|
||||||
|
resp.writeHead(201)
|
||||||
|
resp.end()
|
||||||
|
setTimeout(function () {
|
||||||
|
equalSync(writefile+2, testfile)
|
||||||
|
console.log("Passed PUT file with pipe req only")
|
||||||
|
}, 1000)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
s.on('/test-req-resp', function (req, resp) {
|
||||||
|
// Take a request and write it and pipe filed to the response
|
||||||
|
var x = filed(writefile+3)
|
||||||
|
req.pipe(x)
|
||||||
|
x.pipe(resp)
|
||||||
|
req.on('end', function () {
|
||||||
|
setTimeout(function () {
|
||||||
|
equalSync(writefile+3, testfile)
|
||||||
|
console.log("Passed PUT file with pipe req and resp")
|
||||||
|
}, 1000)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
s.on('/test-resp', function (req, resp) {
|
||||||
|
// Send a file to an HTTP response
|
||||||
|
filed(testfile).pipe(resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
var fullpipe = function (req, resp) {
|
||||||
|
var x = filed(testfile)
|
||||||
|
req.pipe(x)
|
||||||
|
x.pipe(resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
s.on('/test-etags-wo', function (req, resp) {
|
||||||
|
fullpipe(req, resp)
|
||||||
|
})
|
||||||
|
s.on('/test-etags-with', function (req, resp) {
|
||||||
|
fullpipe(req, resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
s.on('/test-lastmodified-wo', function (req, resp) {
|
||||||
|
fullpipe(req, resp)
|
||||||
|
})
|
||||||
|
s.on('/test-lastmodified-with', function (req, resp) {
|
||||||
|
fullpipe(req, resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
s.on('/test-index', function (req, resp) {
|
||||||
|
var x = filed(__dirname)
|
||||||
|
x.pipe(resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
s.on('/test-index-full', function (req, resp) {
|
||||||
|
var x = filed(__dirname)
|
||||||
|
req.pipe(x)
|
||||||
|
x.pipe(resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
s.on('/test-not-found', function (req, resp) {
|
||||||
|
var x = filed(__dirname + "/there-is-no-such-file-here.no-extension")
|
||||||
|
req.pipe(x)
|
||||||
|
x.pipe(resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
s.listen(port, function () {
|
||||||
|
|
||||||
|
fs.createReadStream(testfile).pipe(request.put(url+'/test-req'))
|
||||||
|
|
||||||
|
fs.createReadStream(testfile).pipe(request.put(url+'/test-req-resp', function (e, resp) {
|
||||||
|
assert.equal(resp.statusCode, 201)
|
||||||
|
assert.equal(resp.headers['content-length'], '0')
|
||||||
|
}))
|
||||||
|
|
||||||
|
var x = request.get(url+'/test-resp', function (e, resp) {
|
||||||
|
if (e) throw e
|
||||||
|
assert.equal(resp.statusCode, 200)
|
||||||
|
assert.equal(resp.headers['content-type'], 'text/javascript')
|
||||||
|
console.log("Passed GET file without piping request")
|
||||||
|
})
|
||||||
|
x.pipe(new FileValidator(testfile))
|
||||||
|
|
||||||
|
request.get(url+'/test-etags-wo', function (e, resp, body) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 200) throw new Error('Status code is not 200 it is '+resp.statusCode)
|
||||||
|
request.get({url:url+'/test-etags-with', headers:{'if-none-match':resp.headers.etag}}, function (e, resp) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 304) throw new Error('Status code is not 304 it is '+resp.statusCode)
|
||||||
|
console.log("Passed GET with etag")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
request.get(url+'/test-lastmodified-wo', function (e, resp, body) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 200) throw new Error('Status code is not 200 it is '+resp.statusCode)
|
||||||
|
request.get({url:url+'/test-lastmodified-with', headers:{'if-modified-since':resp.headers['last-modified']}}, function (e, resp) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 304) throw new Error('Status code is not 304 it is '+resp.statusCode)
|
||||||
|
console.log("Passed GET with if-modified-since")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
request.get(url+'/test-index', function (e, resp, body) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 200) throw new Error('Status code is not 200 it is '+resp.statusCode)
|
||||||
|
assert.equal(resp.headers['content-type'], 'text/html')
|
||||||
|
assert.equal(body, fs.readFileSync(path.join(__dirname, 'index.html')).toString())
|
||||||
|
console.log("Passed GET of directory index")
|
||||||
|
})
|
||||||
|
|
||||||
|
request.get(url+'/test-index-full', function (e, resp, body) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 200) throw new Error('Status code is not 200 it is '+resp.statusCode)
|
||||||
|
assert.equal(resp.headers['content-type'], 'text/html')
|
||||||
|
assert.equal(body, fs.readFileSync(path.join(__dirname, 'index.html')).toString())
|
||||||
|
console.log("Passed GET of directory index, full pipe")
|
||||||
|
})
|
||||||
|
|
||||||
|
request.get(url+'/test-not-found', function (e, resp, body) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 404) throw new Error('Status code is not 404 it is '+resp.statusCode)
|
||||||
|
console.log("Passed Not Found produces 404")
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
testhttp()
|
||||||
|
|
||||||
|
process.on('exit', function () {console.log('All tests passed.')})
|
209
node_modules/beefy/node_modules/filed/test/testdump-3
generated
vendored
Normal file
@ -0,0 +1,209 @@
|
|||||||
|
var filed = require('../main')
|
||||||
|
, server = require('./server')
|
||||||
|
, fs = require('fs')
|
||||||
|
, path = require('path')
|
||||||
|
, assert = require('assert')
|
||||||
|
, request = require('request')
|
||||||
|
, test1buffer = ''
|
||||||
|
, testfile = path.join(__dirname, 'test.js')
|
||||||
|
, writefile = path.join(__dirname, 'testdump-')
|
||||||
|
, cleanup = []
|
||||||
|
, validations = []
|
||||||
|
, port = 9090
|
||||||
|
, i = 0
|
||||||
|
, url = 'http://localhost:'+port
|
||||||
|
;
|
||||||
|
|
||||||
|
while (i < 50) {
|
||||||
|
try {fs.unlinkSync(writefile+i)}
|
||||||
|
catch (e) {}
|
||||||
|
i += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function FileValidator (path) {
|
||||||
|
this.path = path
|
||||||
|
this.buffers = []
|
||||||
|
this.len = 0
|
||||||
|
this.writable = true
|
||||||
|
}
|
||||||
|
FileValidator.prototype.write = function (chunk) {
|
||||||
|
this.buffers.push(chunk)
|
||||||
|
this.len += chunk.length
|
||||||
|
}
|
||||||
|
FileValidator.prototype.end = function () {
|
||||||
|
var body = new Buffer(this.len)
|
||||||
|
var i = 0
|
||||||
|
this.buffers.forEach(function (chunk) {
|
||||||
|
chunk.copy(body, i, 0, chunk.length)
|
||||||
|
i += chunk.length
|
||||||
|
})
|
||||||
|
var f = fs.readFileSync(this.path)
|
||||||
|
assert.equal(body.length, f.length)
|
||||||
|
assert.deepEqual(body, f)
|
||||||
|
}
|
||||||
|
FileValidator.prototype.on = function () {}
|
||||||
|
FileValidator.prototype.removeListener = function () {}
|
||||||
|
FileValidator.prototype.emit = function () {}
|
||||||
|
|
||||||
|
function equalSync (f1, f2) {
|
||||||
|
f1 = fs.readFileSync(f1)
|
||||||
|
f2 = fs.readFileSync(f2)
|
||||||
|
assert.equal(f1.length, f2.length)
|
||||||
|
assert.deepEqual(f1, f2)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test reading
|
||||||
|
filed(testfile).pipe(new FileValidator(testfile))
|
||||||
|
|
||||||
|
// Test writing
|
||||||
|
|
||||||
|
function testwrites () {
|
||||||
|
var x = filed(writefile+1)
|
||||||
|
, y = fs.createReadStream(testfile)
|
||||||
|
;
|
||||||
|
y.pipe(x)
|
||||||
|
x.on('end', function () {
|
||||||
|
setTimeout(function () {
|
||||||
|
equalSync(writefile+1, testfile)
|
||||||
|
console.log("Passed writing files")
|
||||||
|
}, 1000)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
testwrites()
|
||||||
|
|
||||||
|
function testhttp () {
|
||||||
|
// Test HTTP use cases
|
||||||
|
var s = server()
|
||||||
|
s.on('/test-req', function (req, resp) {
|
||||||
|
// Take a request and write it, do not send filed to the response
|
||||||
|
req.pipe(filed(writefile+2))
|
||||||
|
req.on('end', function () {
|
||||||
|
resp.writeHead(201)
|
||||||
|
resp.end()
|
||||||
|
setTimeout(function () {
|
||||||
|
equalSync(writefile+2, testfile)
|
||||||
|
console.log("Passed PUT file with pipe req only")
|
||||||
|
}, 1000)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
s.on('/test-req-resp', function (req, resp) {
|
||||||
|
// Take a request and write it and pipe filed to the response
|
||||||
|
var x = filed(writefile+3)
|
||||||
|
req.pipe(x)
|
||||||
|
x.pipe(resp)
|
||||||
|
req.on('end', function () {
|
||||||
|
setTimeout(function () {
|
||||||
|
equalSync(writefile+3, testfile)
|
||||||
|
console.log("Passed PUT file with pipe req and resp")
|
||||||
|
}, 1000)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
s.on('/test-resp', function (req, resp) {
|
||||||
|
// Send a file to an HTTP response
|
||||||
|
filed(testfile).pipe(resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
var fullpipe = function (req, resp) {
|
||||||
|
var x = filed(testfile)
|
||||||
|
req.pipe(x)
|
||||||
|
x.pipe(resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
s.on('/test-etags-wo', function (req, resp) {
|
||||||
|
fullpipe(req, resp)
|
||||||
|
})
|
||||||
|
s.on('/test-etags-with', function (req, resp) {
|
||||||
|
fullpipe(req, resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
s.on('/test-lastmodified-wo', function (req, resp) {
|
||||||
|
fullpipe(req, resp)
|
||||||
|
})
|
||||||
|
s.on('/test-lastmodified-with', function (req, resp) {
|
||||||
|
fullpipe(req, resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
s.on('/test-index', function (req, resp) {
|
||||||
|
var x = filed(__dirname)
|
||||||
|
x.pipe(resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
s.on('/test-index-full', function (req, resp) {
|
||||||
|
var x = filed(__dirname)
|
||||||
|
req.pipe(x)
|
||||||
|
x.pipe(resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
s.on('/test-not-found', function (req, resp) {
|
||||||
|
var x = filed(__dirname + "/there-is-no-such-file-here.no-extension")
|
||||||
|
req.pipe(x)
|
||||||
|
x.pipe(resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
s.listen(port, function () {
|
||||||
|
|
||||||
|
fs.createReadStream(testfile).pipe(request.put(url+'/test-req'))
|
||||||
|
|
||||||
|
fs.createReadStream(testfile).pipe(request.put(url+'/test-req-resp', function (e, resp) {
|
||||||
|
assert.equal(resp.statusCode, 201)
|
||||||
|
assert.equal(resp.headers['content-length'], '0')
|
||||||
|
}))
|
||||||
|
|
||||||
|
var x = request.get(url+'/test-resp', function (e, resp) {
|
||||||
|
if (e) throw e
|
||||||
|
assert.equal(resp.statusCode, 200)
|
||||||
|
assert.equal(resp.headers['content-type'], 'text/javascript')
|
||||||
|
console.log("Passed GET file without piping request")
|
||||||
|
})
|
||||||
|
x.pipe(new FileValidator(testfile))
|
||||||
|
|
||||||
|
request.get(url+'/test-etags-wo', function (e, resp, body) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 200) throw new Error('Status code is not 200 it is '+resp.statusCode)
|
||||||
|
request.get({url:url+'/test-etags-with', headers:{'if-none-match':resp.headers.etag}}, function (e, resp) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 304) throw new Error('Status code is not 304 it is '+resp.statusCode)
|
||||||
|
console.log("Passed GET with etag")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
request.get(url+'/test-lastmodified-wo', function (e, resp, body) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 200) throw new Error('Status code is not 200 it is '+resp.statusCode)
|
||||||
|
request.get({url:url+'/test-lastmodified-with', headers:{'if-modified-since':resp.headers['last-modified']}}, function (e, resp) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 304) throw new Error('Status code is not 304 it is '+resp.statusCode)
|
||||||
|
console.log("Passed GET with if-modified-since")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
request.get(url+'/test-index', function (e, resp, body) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 200) throw new Error('Status code is not 200 it is '+resp.statusCode)
|
||||||
|
assert.equal(resp.headers['content-type'], 'text/html')
|
||||||
|
assert.equal(body, fs.readFileSync(path.join(__dirname, 'index.html')).toString())
|
||||||
|
console.log("Passed GET of directory index")
|
||||||
|
})
|
||||||
|
|
||||||
|
request.get(url+'/test-index-full', function (e, resp, body) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 200) throw new Error('Status code is not 200 it is '+resp.statusCode)
|
||||||
|
assert.equal(resp.headers['content-type'], 'text/html')
|
||||||
|
assert.equal(body, fs.readFileSync(path.join(__dirname, 'index.html')).toString())
|
||||||
|
console.log("Passed GET of directory index, full pipe")
|
||||||
|
})
|
||||||
|
|
||||||
|
request.get(url+'/test-not-found', function (e, resp, body) {
|
||||||
|
if (e) throw e
|
||||||
|
if (resp.statusCode !== 404) throw new Error('Status code is not 404 it is '+resp.statusCode)
|
||||||
|
console.log("Passed Not Found produces 404")
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
testhttp()
|
||||||
|
|
||||||
|
process.on('exit', function () {console.log('All tests passed.')})
|
3
node_modules/beefy/node_modules/live-reload/.npmignore
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
node_modules
|
||||||
|
*.log
|
||||||
|
*.err
|
19
node_modules/beefy/node_modules/live-reload/LICENCE
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
Copyright (c) 2012 Raynos.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
34
node_modules/beefy/node_modules/live-reload/README.md
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# live-reload
|
||||||
|
|
||||||
|
A live reload server & client
|
||||||
|
|
||||||
|
## Docs
|
||||||
|
|
||||||
|
```
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
live-reload [uri] --port=somePort --delay=someDelay
|
||||||
|
|
||||||
|
Runs a live-reload server on the port. It listens on all files
|
||||||
|
in the uri and sends reload commands to any browsers
|
||||||
|
connected to it if the files change.
|
||||||
|
|
||||||
|
If a delay is set then it will send the command once the
|
||||||
|
file has changed and the delay has elapsed. This is
|
||||||
|
useful if your changing many files at once and only
|
||||||
|
want to reload say 1s after all files have been written
|
||||||
|
to disk.
|
||||||
|
|
||||||
|
To connect a browser to a live-reload server simply add
|
||||||
|
<script src="localhost:somePort"></script> to your page
|
||||||
|
```
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
`npm install live-reload`
|
||||||
|
|
||||||
|
## Contributors
|
||||||
|
|
||||||
|
- Raynos
|
||||||
|
|
||||||
|
## MIT Licenced
|
17
node_modules/beefy/node_modules/live-reload/bin/reload.js
generated
vendored
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
var argv = require("optimist").argv
|
||||||
|
, path = require("path")
|
||||||
|
, filed = require("filed")
|
||||||
|
|
||||||
|
, Reload = require("..")
|
||||||
|
|
||||||
|
, uri = argv.uri = argv._[0]
|
||||||
|
, help = argv.help || argv.h
|
||||||
|
|
||||||
|
if (help) {
|
||||||
|
filed(path.join(__dirname, "usage.txt")).pipe(process.stdout)
|
||||||
|
} else {
|
||||||
|
Reload(argv)
|
||||||
|
}
|
||||||
|
|
16
node_modules/beefy/node_modules/live-reload/bin/usage.txt
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
Usage:
|
||||||
|
|
||||||
|
live-reload [uri] --port=somePort --delay=someDelay
|
||||||
|
|
||||||
|
Runs a live-reload server on the port. It listens on all files
|
||||||
|
in the uri and sends reload commands to any browsers
|
||||||
|
connected to it if the files change.
|
||||||
|
|
||||||
|
If a delay is set then it will send the command once the
|
||||||
|
file has changed and the delay has elapsed. This is
|
||||||
|
useful if your changing many files at once and only
|
||||||
|
want to reload say 1s after all files have been written
|
||||||
|
to disk.
|
||||||
|
|
||||||
|
To connect a browser to a live-reload server simply add
|
||||||
|
<script src="localhost:somePort"></script> to your page
|
19
node_modules/beefy/node_modules/live-reload/browser.js
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
var reconnect = require("reconnect/shoe")
|
||||||
|
|
||||||
|
module.exports = LiveReloadClient
|
||||||
|
|
||||||
|
function LiveReloadClient(uri) {
|
||||||
|
if (typeof uri === "number") {
|
||||||
|
uri = "http://localhost:" + uri
|
||||||
|
}
|
||||||
|
|
||||||
|
reconnect(function (stream) {
|
||||||
|
stream.on("data", ondata)
|
||||||
|
}).connect(uri + "/shoe")
|
||||||
|
}
|
||||||
|
|
||||||
|
function ondata(data) {
|
||||||
|
if (data === "reload") {
|
||||||
|
document.location.reload()
|
||||||
|
}
|
||||||
|
}
|
72
node_modules/beefy/node_modules/live-reload/index.js
generated
vendored
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
var http = require("http")
|
||||||
|
, shoe = require("shoe")
|
||||||
|
, path = require("path")
|
||||||
|
, watchr = require("watchr")
|
||||||
|
, bundle = require("browserify-server")
|
||||||
|
, openStreams = []
|
||||||
|
|
||||||
|
module.exports = LiveReloadServer
|
||||||
|
|
||||||
|
function LiveReloadServer(options) {
|
||||||
|
var server = http.createServer(serveText)
|
||||||
|
, sock = shoe(handleStream)
|
||||||
|
, uri = options.uri || process.cwd()
|
||||||
|
, filterIgnored = options.ignore || noop
|
||||||
|
, delay = options.delay || 1000
|
||||||
|
, port = options.port || 9090
|
||||||
|
, timer
|
||||||
|
, source = bundle(path.join(__dirname, "reload.js"), {
|
||||||
|
body: "require('./browser.js')(" + port + ")"
|
||||||
|
})
|
||||||
|
|
||||||
|
watchr.watch({
|
||||||
|
path: uri
|
||||||
|
, listener: reload
|
||||||
|
, ignoreHiddenFiles: true
|
||||||
|
, ignorePatterns: true
|
||||||
|
})
|
||||||
|
|
||||||
|
sock.install(server, "/shoe")
|
||||||
|
|
||||||
|
server.listen(port)
|
||||||
|
|
||||||
|
console.log("live reload server listening on port", port
|
||||||
|
, "reloading on files", uri)
|
||||||
|
|
||||||
|
|
||||||
|
function serveText(req, res) {
|
||||||
|
res.setHeader("content-type", "application/javascript")
|
||||||
|
res.end(source)
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleStream(stream) {
|
||||||
|
openStreams.push(stream)
|
||||||
|
|
||||||
|
stream.on("end", remove)
|
||||||
|
|
||||||
|
function remove() {
|
||||||
|
var index = openStreams.indexOf(stream)
|
||||||
|
if (index !== -1) {
|
||||||
|
openStreams.splice(index, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function reload(fileName) {
|
||||||
|
if (timer) {
|
||||||
|
clearTimeout(timer)
|
||||||
|
}
|
||||||
|
|
||||||
|
timer = setTimeout(function () {
|
||||||
|
if (!filterIgnored(fileName)) {
|
||||||
|
openStreams.forEach(sendMessage)
|
||||||
|
}
|
||||||
|
}, delay)
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendMessage(stream) {
|
||||||
|
stream && stream.write("reload")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function noop() {}
|
1
node_modules/beefy/node_modules/live-reload/node_modules/.bin/browserify-server
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../browserify-server/bin/browserify-server.js
|
1
node_modules/beefy/node_modules/live-reload/node_modules/.bin/watchr
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../watchr/bin/watchr
|
3
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/.npmignore
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
node_modules
|
||||||
|
*.log
|
||||||
|
*.err
|
19
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/LICENCE
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
Copyright (c) 2012 Raynos.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
2
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/Makefile
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
build:
|
||||||
|
browserify lib/client.js -o lib/bundle.js
|
30
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/README.md
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# browserify-server
|
||||||
|
|
||||||
|
Browserify bundling + static server in one!
|
||||||
|
|
||||||
|
## Docs
|
||||||
|
|
||||||
|
```
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
browserify-server bundle [file] -o [out]
|
||||||
|
|
||||||
|
bundle the file and write the bundle to out
|
||||||
|
|
||||||
|
browserify-server server [folder] --port PORT
|
||||||
|
|
||||||
|
Run a static http server serving the folder
|
||||||
|
```
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
`npm install browserify-server`
|
||||||
|
|
||||||
|
## Contributors
|
||||||
|
|
||||||
|
- Raynos
|
||||||
|
|
||||||
|
## MIT Licenced
|
||||||
|
|
||||||
|
[1]: https://secure.travis-ci.org/Raynos/browserify-server.png
|
||||||
|
[2]: http://travis-ci.org/Raynos/browserify-server
|
29
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/bin/browserify-server.js
generated
vendored
Executable file
@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
var argv = require("optimist").argv
|
||||||
|
, path = require("path")
|
||||||
|
, fs = require("fs")
|
||||||
|
, filed = require("filed")
|
||||||
|
|
||||||
|
, Bundle = require("..")
|
||||||
|
, Server = require("../server")
|
||||||
|
|
||||||
|
, help = argv.help || argv.h
|
||||||
|
, index = argv.index || argv.i
|
||||||
|
, bundle = argv.bundle || argv.b
|
||||||
|
, server = argv.server || argv.s
|
||||||
|
, output = argv.output || argv.o
|
||||||
|
, port = argv.port || argv.p
|
||||||
|
|
||||||
|
if (help) {
|
||||||
|
filed(path.join(__dirname, "usage.txt")).pipe(process.stdout)
|
||||||
|
} else if (index) {
|
||||||
|
filed(path.join(__dirname, "index.html")).pipe(process.stdout)
|
||||||
|
} else if (bundle) {
|
||||||
|
var data = Bundle(bundle, output)
|
||||||
|
fs.writeFileSync(output, data, "utf-8")
|
||||||
|
console.log("bundled", bundle, "to", output
|
||||||
|
, "with env", process.env.NODE_ENV)
|
||||||
|
} else if (server) {
|
||||||
|
Server(server, port)
|
||||||
|
}
|
10
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/bin/index.html
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title> Your title </title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script src="bundle.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
9
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/bin/usage.txt
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
Usage:
|
||||||
|
|
||||||
|
browserify-server bundle [file] -o [out]
|
||||||
|
|
||||||
|
bundle the file and write the bundle to out
|
||||||
|
|
||||||
|
browserify-server server [folder] --port PORT
|
||||||
|
|
||||||
|
Run a static http server serving the folder
|
36
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/index.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
var path = require("path")
|
||||||
|
, fs = require("fs")
|
||||||
|
, browserify = require("browserify")
|
||||||
|
|
||||||
|
module.exports = bundle
|
||||||
|
|
||||||
|
function bundle(input, options) {
|
||||||
|
var bundle = createBundle(input, options)
|
||||||
|
|
||||||
|
try {
|
||||||
|
return bundle.bundle()
|
||||||
|
} catch (err) {
|
||||||
|
console.error("[BROWSERIFY-SERVER]", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createBundle(input, options) {
|
||||||
|
var bundle = browserify({
|
||||||
|
debug: true
|
||||||
|
})
|
||||||
|
|
||||||
|
bundle.register(".html", handleHtml)
|
||||||
|
bundle.register(".svg", handleHtml)
|
||||||
|
|
||||||
|
bundle.addEntry(path.join(__dirname, "other.js"), {
|
||||||
|
body: "process.env.NODE_ENV = '" +
|
||||||
|
process.env.NODE_ENV + "'\n"
|
||||||
|
})
|
||||||
|
bundle.addEntry(input, options)
|
||||||
|
|
||||||
|
return bundle
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleHtml(file, fileName) {
|
||||||
|
return "module.exports = '" + file.replace(/\n/g, "\\n") + "'"
|
||||||
|
}
|
1
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/.bin/browserify
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../browserify/bin/cmd.js
|
4
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
language: node_js
|
||||||
|
node_js:
|
||||||
|
- 0.6
|
||||||
|
- 0.8
|
63
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/LICENSE
generated
vendored
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
Some pieces from builtins/ taken from node core under this license:
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
persons to whom the Software is furnished to do so, subject to the
|
||||||
|
following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included
|
||||||
|
in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
buffer_ieee754.js has this license in it:
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
Copyright (c) 2008, Fair Oaks Labs, Inc.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of Fair Oaks Labs, Inc. nor the names of its contributors
|
||||||
|
may be used to endorse or promote products derived from this software
|
||||||
|
without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
Modifications to writeIEEE754 to support negative zeroes made by Brian White
|
||||||
|
|
||||||
|
----
|
172
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/README.markdown
generated
vendored
Normal file
@ -0,0 +1,172 @@
|
|||||||
|
browserify
|
||||||
|
==========
|
||||||
|
|
||||||
|
Make node-style require() work in the browser with a server-side build step,
|
||||||
|
as if by magic!
|
||||||
|
|
||||||
|
[![build status](https://secure.travis-ci.org/substack/node-browserify.png)](http://travis-ci.org/substack/node-browserify)
|
||||||
|
|
||||||
|
![browserify!](http://substack.net/images/browserify/browserify.png)
|
||||||
|
|
||||||
|
example
|
||||||
|
=======
|
||||||
|
|
||||||
|
Just write an `entry.js` to start with some `require()`s in it:
|
||||||
|
|
||||||
|
````javascript
|
||||||
|
// use relative requires
|
||||||
|
var foo = require('./foo');
|
||||||
|
var bar = require('../lib/bar');
|
||||||
|
|
||||||
|
// or use modules installed by npm into node_modules/
|
||||||
|
var gamma = require('gamma');
|
||||||
|
|
||||||
|
var elem = document.getElementById('result');
|
||||||
|
var x = foo(100) + bar('baz');
|
||||||
|
elem.textContent = gamma(x);
|
||||||
|
````
|
||||||
|
|
||||||
|
Now just use the `browserify` command to build a bundle starting at `entry.js`:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ browserify entry.js -o bundle.js
|
||||||
|
```
|
||||||
|
|
||||||
|
All of the modules that `entry.js` needs are included in the final bundle from a
|
||||||
|
recursive walk using [detective](https://github.com/substack/node-detective).
|
||||||
|
|
||||||
|
To use the bundle, just toss a `<script src="bundle.js"></script>` into your
|
||||||
|
html!
|
||||||
|
|
||||||
|
usage
|
||||||
|
=====
|
||||||
|
|
||||||
|
````
|
||||||
|
Usage: browserify [entry files] {OPTIONS}
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--outfile, -o Write the browserify bundle to this file.
|
||||||
|
If unspecified, browserify prints to stdout.
|
||||||
|
--require, -r A module name or file to bundle.require()
|
||||||
|
Optionally use a colon separator to set the target.
|
||||||
|
--entry, -e An entry point of your app
|
||||||
|
--exports Export these core objects, comma-separated list
|
||||||
|
with any of: require, process. If unspecified, the
|
||||||
|
export behavior will be inferred.
|
||||||
|
|
||||||
|
--ignore, -i Ignore a file
|
||||||
|
--alias, -a Register an alias with a colon separator: "to:from"
|
||||||
|
Example: --alias 'jquery:jquery-browserify'
|
||||||
|
--cache, -c Turn on caching at $HOME/.config/browserling/cache.json or use
|
||||||
|
a file for caching.
|
||||||
|
[default: true]
|
||||||
|
--debug, -d Switch on debugging mode with //@ sourceURL=...s. [boolean]
|
||||||
|
--plugin, -p Use a plugin.
|
||||||
|
Example: --plugin aliasify
|
||||||
|
--prelude Include the code that defines require() in this bundle.
|
||||||
|
[boolean] [default: true]
|
||||||
|
--watch, -w Watch for changes. The script will stay open and write updates
|
||||||
|
to the output every time any of the bundled files change.
|
||||||
|
This option only works in tandem with -o.
|
||||||
|
--verbose, -v Write out how many bytes were written in -o mode. This is
|
||||||
|
especially useful with --watch.
|
||||||
|
--help, -h Show this message
|
||||||
|
|
||||||
|
````
|
||||||
|
|
||||||
|
compatibility
|
||||||
|
=============
|
||||||
|
|
||||||
|
Many [npm](http://npmjs.org) modules that don't do IO will just work after being
|
||||||
|
browserified. Others take more work.
|
||||||
|
|
||||||
|
[coffee script](http://coffeescript.org/) should pretty much just work.
|
||||||
|
Just do `browserify entry.coffee` or `require('./foo.coffee')`.
|
||||||
|
|
||||||
|
Many node built-in modules have been wrapped to work in the browser.
|
||||||
|
All you need to do is `require()` them like in node.
|
||||||
|
|
||||||
|
* events
|
||||||
|
* path
|
||||||
|
* [vm](https://github.com/substack/vm-browserify)
|
||||||
|
* [http](https://github.com/substack/http-browserify)
|
||||||
|
* [crypto](https://github.com/dominictarr/crypto-browserify)
|
||||||
|
* assert
|
||||||
|
* url
|
||||||
|
* buffer
|
||||||
|
* buffer_ieee754
|
||||||
|
* util
|
||||||
|
* querystring
|
||||||
|
* stream
|
||||||
|
|
||||||
|
process
|
||||||
|
-------
|
||||||
|
|
||||||
|
Browserify makes available a faux `process` object to modules with these
|
||||||
|
attributes:
|
||||||
|
|
||||||
|
* nextTick(fn) - uses [the postMessage trick](http://dbaron.org/log/20100309-faster-timeouts)
|
||||||
|
for a faster `setTimeout(fn, 0)` if it can
|
||||||
|
* title - set to 'browser' for browser code, 'node' in regular node code
|
||||||
|
* browser - `true`, good for testing if you're in a browser or in node
|
||||||
|
|
||||||
|
By default the process object is only available inside of files wrapped by
|
||||||
|
browserify. To expose it, use `--exports=process`
|
||||||
|
|
||||||
|
__dirname
|
||||||
|
---------
|
||||||
|
|
||||||
|
The faux directory name, scrubbed of true directory information so as not to
|
||||||
|
expose your filesystem organization.
|
||||||
|
|
||||||
|
__filename
|
||||||
|
----------
|
||||||
|
|
||||||
|
The faux file path, scrubbed of true path information so as not to expose your
|
||||||
|
filesystem organization.
|
||||||
|
|
||||||
|
package.json
|
||||||
|
============
|
||||||
|
|
||||||
|
In order to resolve main files for projects, the package.json "main" field is
|
||||||
|
read.
|
||||||
|
|
||||||
|
If a package.json has a "browserify" field, you can override the standard "main"
|
||||||
|
behavior with something special just for browsers.
|
||||||
|
|
||||||
|
See [dnode's
|
||||||
|
package.json](https://github.com/substack/dnode/blob/9e24b97cf2ce931fbf6d7beb3731086b46bca887/package.json#L40)
|
||||||
|
for an example of using the "browserify" field.
|
||||||
|
|
||||||
|
more
|
||||||
|
====
|
||||||
|
|
||||||
|
* [browserify recipes](https://github.com/substack/node-browserify/blob/master/doc/recipes.markdown#recipes)
|
||||||
|
* [browserify api reference](https://github.com/substack/node-browserify/blob/master/doc/methods.markdown#methods)
|
||||||
|
* [browserify cdn](http://browserify.nodejitsu.com/)
|
||||||
|
|
||||||
|
install
|
||||||
|
=======
|
||||||
|
|
||||||
|
With [npm](http://npmjs.org) do:
|
||||||
|
|
||||||
|
```
|
||||||
|
npm install -g browserify
|
||||||
|
```
|
||||||
|
|
||||||
|
test
|
||||||
|
====
|
||||||
|
|
||||||
|
To run the node tests with tap, do:
|
||||||
|
|
||||||
|
```
|
||||||
|
npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
To run the [testling](http://testling.com) tests,
|
||||||
|
create a [browserling](http://browserling.com) account then:
|
||||||
|
|
||||||
|
```
|
||||||
|
cd testling
|
||||||
|
./test.sh
|
||||||
|
```
|
161
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/bin/cmd.js
generated
vendored
Executable file
@ -0,0 +1,161 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
var browserify = require('../');
|
||||||
|
var fs = require('fs');
|
||||||
|
var resolve = require('resolve');
|
||||||
|
|
||||||
|
var argv = require('optimist')
|
||||||
|
.usage('Usage: browserify [entry files] {OPTIONS}')
|
||||||
|
.wrap(80)
|
||||||
|
.option('outfile', {
|
||||||
|
alias : 'o',
|
||||||
|
desc : 'Write the browserify bundle to this file.\n'
|
||||||
|
+ 'If unspecified, browserify prints to stdout.'
|
||||||
|
,
|
||||||
|
})
|
||||||
|
.option('require', {
|
||||||
|
alias : 'r',
|
||||||
|
desc : 'A module name or file to bundle.require()\n'
|
||||||
|
+ 'Optionally use a colon separator to set the target.'
|
||||||
|
,
|
||||||
|
})
|
||||||
|
.option('entry', {
|
||||||
|
alias : 'e',
|
||||||
|
desc : 'An entry point of your app'
|
||||||
|
})
|
||||||
|
.option('exports', {
|
||||||
|
desc : 'Export these core objects, comma-separated list\n'
|
||||||
|
+ 'with any of: require, process. If unspecified, the\n'
|
||||||
|
+ 'export behavior will be inferred.\n'
|
||||||
|
})
|
||||||
|
.option('ignore', {
|
||||||
|
alias : 'i',
|
||||||
|
desc : 'Ignore a file'
|
||||||
|
})
|
||||||
|
.option('alias', {
|
||||||
|
alias : 'a',
|
||||||
|
desc : 'Register an alias with a colon separator: "to:from"\n'
|
||||||
|
+ "Example: --alias 'jquery:jquery-browserify'"
|
||||||
|
,
|
||||||
|
})
|
||||||
|
.option('cache', {
|
||||||
|
alias : 'c',
|
||||||
|
desc : 'Turn on caching at $HOME/.config/browserling/cache.json '
|
||||||
|
+ 'or use a file for caching.\n',
|
||||||
|
default : true,
|
||||||
|
})
|
||||||
|
.option('debug', {
|
||||||
|
alias : 'd',
|
||||||
|
desc : 'Switch on debugging mode with //@ sourceURL=...s.',
|
||||||
|
type : 'boolean'
|
||||||
|
})
|
||||||
|
.option('plugin', {
|
||||||
|
alias : 'p',
|
||||||
|
desc : 'Use a plugin.\n'
|
||||||
|
+ 'Example: --plugin aliasify'
|
||||||
|
,
|
||||||
|
})
|
||||||
|
.option('prelude', {
|
||||||
|
default : true,
|
||||||
|
type : 'boolean',
|
||||||
|
desc : 'Include the code that defines require() in this bundle.'
|
||||||
|
})
|
||||||
|
.option('watch', {
|
||||||
|
alias : 'w',
|
||||||
|
desc : 'Watch for changes. The script will stay open and write updates '
|
||||||
|
+ 'to the output every time any of the bundled files change.\n'
|
||||||
|
+ 'This option only works in tandem with -o.'
|
||||||
|
,
|
||||||
|
})
|
||||||
|
.option('verbose', {
|
||||||
|
alias : 'v',
|
||||||
|
desc : 'Write out how many bytes were written in -o mode. '
|
||||||
|
+ 'This is especially useful with --watch.'
|
||||||
|
,
|
||||||
|
})
|
||||||
|
.option('help', {
|
||||||
|
alias : 'h',
|
||||||
|
desc : 'Show this message'
|
||||||
|
})
|
||||||
|
.check(function (argv) {
|
||||||
|
if (argv.help) throw ''
|
||||||
|
if (process.argv.length <= 2) throw 'Specify a parameter.'
|
||||||
|
})
|
||||||
|
.argv
|
||||||
|
;
|
||||||
|
|
||||||
|
var bundle = browserify({
|
||||||
|
watch : argv.watch,
|
||||||
|
cache : argv.cache,
|
||||||
|
debug : argv.debug,
|
||||||
|
exports : argv.exports && argv.exports.split(','),
|
||||||
|
});
|
||||||
|
|
||||||
|
bundle.on('syntaxError', function (err) {
|
||||||
|
console.error(err);
|
||||||
|
if (!argv.watch) {
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (argv.noprelude || argv.prelude === false) {
|
||||||
|
bundle.files = [];
|
||||||
|
bundle.prepends = [];
|
||||||
|
}
|
||||||
|
if (argv.ignore) bundle.ignore(argv.ignore);
|
||||||
|
|
||||||
|
([].concat(argv.plugin || [])).forEach(function (plugin) {
|
||||||
|
var resolved = resolve.sync(plugin, { basedir : process.cwd() });
|
||||||
|
bundle.use(require(resolved));
|
||||||
|
});
|
||||||
|
|
||||||
|
([].concat(argv.alias || [])).forEach(function (alias) {
|
||||||
|
if (!alias.match(/:/)) {
|
||||||
|
console.error('aliases require a colon separator');
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
|
bundle.alias.apply(bundle, alias.split(':'));
|
||||||
|
});
|
||||||
|
|
||||||
|
([].concat(argv.require || [])).forEach(function (req) {
|
||||||
|
if (req.match(/:/)) {
|
||||||
|
var s = req.split(':');
|
||||||
|
bundle.require(s[0], { target : s[1] });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!/^[.\/]/.test(req)) {
|
||||||
|
try {
|
||||||
|
var res = resolve.sync(req, { basedir : process.cwd() });
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
return bundle.require(req);
|
||||||
|
}
|
||||||
|
return bundle.require(res, { target : req });
|
||||||
|
}
|
||||||
|
bundle.require(req);
|
||||||
|
});
|
||||||
|
|
||||||
|
(argv._.concat(argv.entry || [])).forEach(function (entry) {
|
||||||
|
bundle.addEntry(entry);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (argv.outfile) {
|
||||||
|
function write () {
|
||||||
|
var src = bundle.bundle();
|
||||||
|
if (!bundle.ok) return;
|
||||||
|
|
||||||
|
fs.writeFile(argv.outfile, src, function () {
|
||||||
|
if (argv.verbose) {
|
||||||
|
console.log(Buffer(src).length + ' bytes written');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
write();
|
||||||
|
if (argv.watch) bundle.on('bundle', write)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var src = bundle.bundle();
|
||||||
|
if (bundle.ok) console.log(src);
|
||||||
|
}
|
55
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/builtins/__browserify_process.js
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
var process = module.exports = {};
|
||||||
|
|
||||||
|
process.nextTick = (function () {
|
||||||
|
var canSetImmediate = typeof window !== 'undefined'
|
||||||
|
&& window.setImmediate;
|
||||||
|
var canPost = typeof window !== 'undefined'
|
||||||
|
&& window.postMessage && window.addEventListener
|
||||||
|
;
|
||||||
|
|
||||||
|
if (canSetImmediate) {
|
||||||
|
return function (f) { return window.setImmediate(f) };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canPost) {
|
||||||
|
var queue = [];
|
||||||
|
window.addEventListener('message', function (ev) {
|
||||||
|
if (ev.source === window && ev.data === 'browserify-tick') {
|
||||||
|
ev.stopPropagation();
|
||||||
|
if (queue.length > 0) {
|
||||||
|
var fn = queue.shift();
|
||||||
|
fn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
return function nextTick(fn) {
|
||||||
|
queue.push(fn);
|
||||||
|
window.postMessage('browserify-tick', '*');
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return function nextTick(fn) {
|
||||||
|
setTimeout(fn, 0);
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
process.title = 'browser';
|
||||||
|
process.browser = true;
|
||||||
|
process.env = {};
|
||||||
|
process.argv = [];
|
||||||
|
|
||||||
|
process.binding = function (name) {
|
||||||
|
if (name === 'evals') return (require)('vm')
|
||||||
|
else throw new Error('No such module. (Possibly not yet loaded)')
|
||||||
|
};
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
var cwd = '/';
|
||||||
|
var path;
|
||||||
|
process.cwd = function () { return cwd };
|
||||||
|
process.chdir = function (dir) {
|
||||||
|
if (!path) path = require('path');
|
||||||
|
cwd = path.resolve(dir, cwd);
|
||||||
|
};
|
||||||
|
})();
|
314
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/builtins/assert.js
generated
vendored
Normal file
@ -0,0 +1,314 @@
|
|||||||
|
// UTILITY
|
||||||
|
var util = require('util');
|
||||||
|
var Buffer = require("buffer").Buffer;
|
||||||
|
var pSlice = Array.prototype.slice;
|
||||||
|
|
||||||
|
function objectKeys(object) {
|
||||||
|
if (Object.keys) return Object.keys(object);
|
||||||
|
var result = [];
|
||||||
|
for (var name in object) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(object, name)) {
|
||||||
|
result.push(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1. The assert module provides functions that throw
|
||||||
|
// AssertionError's when particular conditions are not met. The
|
||||||
|
// assert module must conform to the following interface.
|
||||||
|
|
||||||
|
var assert = module.exports = ok;
|
||||||
|
|
||||||
|
// 2. The AssertionError is defined in assert.
|
||||||
|
// new assert.AssertionError({ message: message,
|
||||||
|
// actual: actual,
|
||||||
|
// expected: expected })
|
||||||
|
|
||||||
|
assert.AssertionError = function AssertionError(options) {
|
||||||
|
this.name = 'AssertionError';
|
||||||
|
this.message = options.message;
|
||||||
|
this.actual = options.actual;
|
||||||
|
this.expected = options.expected;
|
||||||
|
this.operator = options.operator;
|
||||||
|
var stackStartFunction = options.stackStartFunction || fail;
|
||||||
|
|
||||||
|
if (Error.captureStackTrace) {
|
||||||
|
Error.captureStackTrace(this, stackStartFunction);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
util.inherits(assert.AssertionError, Error);
|
||||||
|
|
||||||
|
function replacer(key, value) {
|
||||||
|
if (value === undefined) {
|
||||||
|
return '' + value;
|
||||||
|
}
|
||||||
|
if (typeof value === 'number' && (isNaN(value) || !isFinite(value))) {
|
||||||
|
return value.toString();
|
||||||
|
}
|
||||||
|
if (typeof value === 'function' || value instanceof RegExp) {
|
||||||
|
return value.toString();
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function truncate(s, n) {
|
||||||
|
if (typeof s == 'string') {
|
||||||
|
return s.length < n ? s : s.slice(0, n);
|
||||||
|
} else {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.AssertionError.prototype.toString = function() {
|
||||||
|
if (this.message) {
|
||||||
|
return [this.name + ':', this.message].join(' ');
|
||||||
|
} else {
|
||||||
|
return [
|
||||||
|
this.name + ':',
|
||||||
|
truncate(JSON.stringify(this.actual, replacer), 128),
|
||||||
|
this.operator,
|
||||||
|
truncate(JSON.stringify(this.expected, replacer), 128)
|
||||||
|
].join(' ');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// assert.AssertionError instanceof Error
|
||||||
|
|
||||||
|
assert.AssertionError.__proto__ = Error.prototype;
|
||||||
|
|
||||||
|
// At present only the three keys mentioned above are used and
|
||||||
|
// understood by the spec. Implementations or sub modules can pass
|
||||||
|
// other keys to the AssertionError's constructor - they will be
|
||||||
|
// ignored.
|
||||||
|
|
||||||
|
// 3. All of the following functions must throw an AssertionError
|
||||||
|
// when a corresponding condition is not met, with a message that
|
||||||
|
// may be undefined if not provided. All assertion methods provide
|
||||||
|
// both the actual and expected values to the assertion error for
|
||||||
|
// display purposes.
|
||||||
|
|
||||||
|
function fail(actual, expected, message, operator, stackStartFunction) {
|
||||||
|
throw new assert.AssertionError({
|
||||||
|
message: message,
|
||||||
|
actual: actual,
|
||||||
|
expected: expected,
|
||||||
|
operator: operator,
|
||||||
|
stackStartFunction: stackStartFunction
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXTENSION! allows for well behaved errors defined elsewhere.
|
||||||
|
assert.fail = fail;
|
||||||
|
|
||||||
|
// 4. Pure assertion tests whether a value is truthy, as determined
|
||||||
|
// by !!guard.
|
||||||
|
// assert.ok(guard, message_opt);
|
||||||
|
// This statement is equivalent to assert.equal(true, guard,
|
||||||
|
// message_opt);. To test strictly for the value true, use
|
||||||
|
// assert.strictEqual(true, guard, message_opt);.
|
||||||
|
|
||||||
|
function ok(value, message) {
|
||||||
|
if (!!!value) fail(value, true, message, '==', assert.ok);
|
||||||
|
}
|
||||||
|
assert.ok = ok;
|
||||||
|
|
||||||
|
// 5. The equality assertion tests shallow, coercive equality with
|
||||||
|
// ==.
|
||||||
|
// assert.equal(actual, expected, message_opt);
|
||||||
|
|
||||||
|
assert.equal = function equal(actual, expected, message) {
|
||||||
|
if (actual != expected) fail(actual, expected, message, '==', assert.equal);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 6. The non-equality assertion tests for whether two objects are not equal
|
||||||
|
// with != assert.notEqual(actual, expected, message_opt);
|
||||||
|
|
||||||
|
assert.notEqual = function notEqual(actual, expected, message) {
|
||||||
|
if (actual == expected) {
|
||||||
|
fail(actual, expected, message, '!=', assert.notEqual);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 7. The equivalence assertion tests a deep equality relation.
|
||||||
|
// assert.deepEqual(actual, expected, message_opt);
|
||||||
|
|
||||||
|
assert.deepEqual = function deepEqual(actual, expected, message) {
|
||||||
|
if (!_deepEqual(actual, expected)) {
|
||||||
|
fail(actual, expected, message, 'deepEqual', assert.deepEqual);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function _deepEqual(actual, expected) {
|
||||||
|
// 7.1. All identical values are equivalent, as determined by ===.
|
||||||
|
if (actual === expected) {
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} else if (Buffer.isBuffer(actual) && Buffer.isBuffer(expected)) {
|
||||||
|
if (actual.length != expected.length) return false;
|
||||||
|
|
||||||
|
for (var i = 0; i < actual.length; i++) {
|
||||||
|
if (actual[i] !== expected[i]) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// 7.2. If the expected value is a Date object, the actual value is
|
||||||
|
// equivalent if it is also a Date object that refers to the same time.
|
||||||
|
} else if (actual instanceof Date && expected instanceof Date) {
|
||||||
|
return actual.getTime() === expected.getTime();
|
||||||
|
|
||||||
|
// 7.3. Other pairs that do not both pass typeof value == 'object',
|
||||||
|
// equivalence is determined by ==.
|
||||||
|
} else if (typeof actual != 'object' && typeof expected != 'object') {
|
||||||
|
return actual == expected;
|
||||||
|
|
||||||
|
// 7.4. For all other Object pairs, including Array objects, equivalence is
|
||||||
|
// determined by having the same number of owned properties (as verified
|
||||||
|
// with Object.prototype.hasOwnProperty.call), the same set of keys
|
||||||
|
// (although not necessarily the same order), equivalent values for every
|
||||||
|
// corresponding key, and an identical 'prototype' property. Note: this
|
||||||
|
// accounts for both named and indexed properties on Arrays.
|
||||||
|
} else {
|
||||||
|
return objEquiv(actual, expected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function isUndefinedOrNull(value) {
|
||||||
|
return value === null || value === undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isArguments(object) {
|
||||||
|
return Object.prototype.toString.call(object) == '[object Arguments]';
|
||||||
|
}
|
||||||
|
|
||||||
|
function objEquiv(a, b) {
|
||||||
|
if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
|
||||||
|
return false;
|
||||||
|
// an identical 'prototype' property.
|
||||||
|
if (a.prototype !== b.prototype) return false;
|
||||||
|
//~~~I've managed to break Object.keys through screwy arguments passing.
|
||||||
|
// Converting to array solves the problem.
|
||||||
|
if (isArguments(a)) {
|
||||||
|
if (!isArguments(b)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
a = pSlice.call(a);
|
||||||
|
b = pSlice.call(b);
|
||||||
|
return _deepEqual(a, b);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
var ka = objectKeys(a),
|
||||||
|
kb = objectKeys(b),
|
||||||
|
key, i;
|
||||||
|
} catch (e) {//happens when one is a string literal and the other isn't
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// having the same number of owned properties (keys incorporates
|
||||||
|
// hasOwnProperty)
|
||||||
|
if (ka.length != kb.length)
|
||||||
|
return false;
|
||||||
|
//the same set of keys (although not necessarily the same order),
|
||||||
|
ka.sort();
|
||||||
|
kb.sort();
|
||||||
|
//~~~cheap key test
|
||||||
|
for (i = ka.length - 1; i >= 0; i--) {
|
||||||
|
if (ka[i] != kb[i])
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//equivalent values for every corresponding key, and
|
||||||
|
//~~~possibly expensive deep test
|
||||||
|
for (i = ka.length - 1; i >= 0; i--) {
|
||||||
|
key = ka[i];
|
||||||
|
if (!_deepEqual(a[key], b[key])) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 8. The non-equivalence assertion tests for any deep inequality.
|
||||||
|
// assert.notDeepEqual(actual, expected, message_opt);
|
||||||
|
|
||||||
|
assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
|
||||||
|
if (_deepEqual(actual, expected)) {
|
||||||
|
fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 9. The strict equality assertion tests strict equality, as determined by ===.
|
||||||
|
// assert.strictEqual(actual, expected, message_opt);
|
||||||
|
|
||||||
|
assert.strictEqual = function strictEqual(actual, expected, message) {
|
||||||
|
if (actual !== expected) {
|
||||||
|
fail(actual, expected, message, '===', assert.strictEqual);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 10. The strict non-equality assertion tests for strict inequality, as
|
||||||
|
// determined by !==. assert.notStrictEqual(actual, expected, message_opt);
|
||||||
|
|
||||||
|
assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
|
||||||
|
if (actual === expected) {
|
||||||
|
fail(actual, expected, message, '!==', assert.notStrictEqual);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function expectedException(actual, expected) {
|
||||||
|
if (!actual || !expected) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expected instanceof RegExp) {
|
||||||
|
return expected.test(actual);
|
||||||
|
} else if (actual instanceof expected) {
|
||||||
|
return true;
|
||||||
|
} else if (expected.call({}, actual) === true) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function _throws(shouldThrow, block, expected, message) {
|
||||||
|
var actual;
|
||||||
|
|
||||||
|
if (typeof expected === 'string') {
|
||||||
|
message = expected;
|
||||||
|
expected = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
block();
|
||||||
|
} catch (e) {
|
||||||
|
actual = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
|
||||||
|
(message ? ' ' + message : '.');
|
||||||
|
|
||||||
|
if (shouldThrow && !actual) {
|
||||||
|
fail('Missing expected exception' + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!shouldThrow && expectedException(actual, expected)) {
|
||||||
|
fail('Got unwanted exception' + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((shouldThrow && actual && expected &&
|
||||||
|
!expectedException(actual, expected)) || (!shouldThrow && actual)) {
|
||||||
|
throw actual;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 11. Expected to throw an error:
|
||||||
|
// assert.throws(block, Error_opt, message_opt);
|
||||||
|
|
||||||
|
assert.throws = function(block, /*optional*/error, /*optional*/message) {
|
||||||
|
_throws.apply(this, [true].concat(pSlice.call(arguments)));
|
||||||
|
};
|
||||||
|
|
||||||
|
// EXTENSION! This is annoying to write outside this module.
|
||||||
|
assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
|
||||||
|
_throws.apply(this, [false].concat(pSlice.call(arguments)));
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.ifError = function(err) { if (err) {throw err;}};
|
2
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/builtins/child_process.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
exports.spawn = function () {};
|
||||||
|
exports.exec = function () {};
|
178
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/builtins/events.js
generated
vendored
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
if (!process.EventEmitter) process.EventEmitter = function () {};
|
||||||
|
|
||||||
|
var EventEmitter = exports.EventEmitter = process.EventEmitter;
|
||||||
|
var isArray = typeof Array.isArray === 'function'
|
||||||
|
? Array.isArray
|
||||||
|
: function (xs) {
|
||||||
|
return Object.prototype.toString.call(xs) === '[object Array]'
|
||||||
|
}
|
||||||
|
;
|
||||||
|
function indexOf (xs, x) {
|
||||||
|
if (xs.indexOf) return xs.indexOf(x);
|
||||||
|
for (var i = 0; i < xs.length; i++) {
|
||||||
|
if (x === xs[i]) return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// By default EventEmitters will print a warning if more than
|
||||||
|
// 10 listeners are added to it. This is a useful default which
|
||||||
|
// helps finding memory leaks.
|
||||||
|
//
|
||||||
|
// Obviously not all Emitters should be limited to 10. This function allows
|
||||||
|
// that to be increased. Set to zero for unlimited.
|
||||||
|
var defaultMaxListeners = 10;
|
||||||
|
EventEmitter.prototype.setMaxListeners = function(n) {
|
||||||
|
if (!this._events) this._events = {};
|
||||||
|
this._events.maxListeners = n;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
EventEmitter.prototype.emit = function(type) {
|
||||||
|
// If there is no 'error' event listener then throw.
|
||||||
|
if (type === 'error') {
|
||||||
|
if (!this._events || !this._events.error ||
|
||||||
|
(isArray(this._events.error) && !this._events.error.length))
|
||||||
|
{
|
||||||
|
if (arguments[1] instanceof Error) {
|
||||||
|
throw arguments[1]; // Unhandled 'error' event
|
||||||
|
} else {
|
||||||
|
throw new Error("Uncaught, unspecified 'error' event.");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this._events) return false;
|
||||||
|
var handler = this._events[type];
|
||||||
|
if (!handler) return false;
|
||||||
|
|
||||||
|
if (typeof handler == 'function') {
|
||||||
|
switch (arguments.length) {
|
||||||
|
// fast cases
|
||||||
|
case 1:
|
||||||
|
handler.call(this);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
handler.call(this, arguments[1]);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
handler.call(this, arguments[1], arguments[2]);
|
||||||
|
break;
|
||||||
|
// slower
|
||||||
|
default:
|
||||||
|
var args = Array.prototype.slice.call(arguments, 1);
|
||||||
|
handler.apply(this, args);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} else if (isArray(handler)) {
|
||||||
|
var args = Array.prototype.slice.call(arguments, 1);
|
||||||
|
|
||||||
|
var listeners = handler.slice();
|
||||||
|
for (var i = 0, l = listeners.length; i < l; i++) {
|
||||||
|
listeners[i].apply(this, args);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// EventEmitter is defined in src/node_events.cc
|
||||||
|
// EventEmitter.prototype.emit() is also defined there.
|
||||||
|
EventEmitter.prototype.addListener = function(type, listener) {
|
||||||
|
if ('function' !== typeof listener) {
|
||||||
|
throw new Error('addListener only takes instances of Function');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this._events) this._events = {};
|
||||||
|
|
||||||
|
// To avoid recursion in the case that type == "newListeners"! Before
|
||||||
|
// adding it to the listeners, first emit "newListeners".
|
||||||
|
this.emit('newListener', type, listener);
|
||||||
|
|
||||||
|
if (!this._events[type]) {
|
||||||
|
// Optimize the case of one listener. Don't need the extra array object.
|
||||||
|
this._events[type] = listener;
|
||||||
|
} else if (isArray(this._events[type])) {
|
||||||
|
|
||||||
|
// Check for listener leak
|
||||||
|
if (!this._events[type].warned) {
|
||||||
|
var m;
|
||||||
|
if (this._events.maxListeners !== undefined) {
|
||||||
|
m = this._events.maxListeners;
|
||||||
|
} else {
|
||||||
|
m = defaultMaxListeners;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m && m > 0 && this._events[type].length > m) {
|
||||||
|
this._events[type].warned = true;
|
||||||
|
console.error('(node) warning: possible EventEmitter memory ' +
|
||||||
|
'leak detected. %d listeners added. ' +
|
||||||
|
'Use emitter.setMaxListeners() to increase limit.',
|
||||||
|
this._events[type].length);
|
||||||
|
console.trace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we've already got an array, just append.
|
||||||
|
this._events[type].push(listener);
|
||||||
|
} else {
|
||||||
|
// Adding the second element, need to change to array.
|
||||||
|
this._events[type] = [this._events[type], listener];
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
||||||
|
|
||||||
|
EventEmitter.prototype.once = function(type, listener) {
|
||||||
|
var self = this;
|
||||||
|
self.on(type, function g() {
|
||||||
|
self.removeListener(type, g);
|
||||||
|
listener.apply(this, arguments);
|
||||||
|
});
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
EventEmitter.prototype.removeListener = function(type, listener) {
|
||||||
|
if ('function' !== typeof listener) {
|
||||||
|
throw new Error('removeListener only takes instances of Function');
|
||||||
|
}
|
||||||
|
|
||||||
|
// does not use listeners(), so no side effect of creating _events[type]
|
||||||
|
if (!this._events || !this._events[type]) return this;
|
||||||
|
|
||||||
|
var list = this._events[type];
|
||||||
|
|
||||||
|
if (isArray(list)) {
|
||||||
|
var i = indexOf(list, listener);
|
||||||
|
if (i < 0) return this;
|
||||||
|
list.splice(i, 1);
|
||||||
|
if (list.length == 0)
|
||||||
|
delete this._events[type];
|
||||||
|
} else if (this._events[type] === listener) {
|
||||||
|
delete this._events[type];
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
EventEmitter.prototype.removeAllListeners = function(type) {
|
||||||
|
// does not use listeners(), so no side effect of creating _events[type]
|
||||||
|
if (type && this._events && this._events[type]) this._events[type] = null;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
EventEmitter.prototype.listeners = function(type) {
|
||||||
|
if (!this._events) this._events = {};
|
||||||
|
if (!this._events[type]) this._events[type] = [];
|
||||||
|
if (!isArray(this._events[type])) {
|
||||||
|
this._events[type] = [this._events[type]];
|
||||||
|
}
|
||||||
|
return this._events[type];
|
||||||
|
};
|
1
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/builtins/fs.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
// nothing to see here... no file methods for the browser
|
1
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/builtins/https.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
module.exports = require('http');
|
1
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/builtins/net.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
// todo
|
134
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/builtins/path.js
generated
vendored
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
function filter (xs, fn) {
|
||||||
|
var res = [];
|
||||||
|
for (var i = 0; i < xs.length; i++) {
|
||||||
|
if (fn(xs[i], i, xs)) res.push(xs[i]);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
// resolves . and .. elements in a path array with directory names there
|
||||||
|
// must be no slashes, empty elements, or device names (c:\) in the array
|
||||||
|
// (so also no leading and trailing slashes - it does not distinguish
|
||||||
|
// relative and absolute paths)
|
||||||
|
function normalizeArray(parts, allowAboveRoot) {
|
||||||
|
// if the path tries to go above the root, `up` ends up > 0
|
||||||
|
var up = 0;
|
||||||
|
for (var i = parts.length; i >= 0; i--) {
|
||||||
|
var last = parts[i];
|
||||||
|
if (last == '.') {
|
||||||
|
parts.splice(i, 1);
|
||||||
|
} else if (last === '..') {
|
||||||
|
parts.splice(i, 1);
|
||||||
|
up++;
|
||||||
|
} else if (up) {
|
||||||
|
parts.splice(i, 1);
|
||||||
|
up--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the path is allowed to go above the root, restore leading ..s
|
||||||
|
if (allowAboveRoot) {
|
||||||
|
for (; up--; up) {
|
||||||
|
parts.unshift('..');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return parts;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Regex to split a filename into [*, dir, basename, ext]
|
||||||
|
// posix version
|
||||||
|
var splitPathRe = /^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;
|
||||||
|
|
||||||
|
// path.resolve([from ...], to)
|
||||||
|
// posix version
|
||||||
|
exports.resolve = function() {
|
||||||
|
var resolvedPath = '',
|
||||||
|
resolvedAbsolute = false;
|
||||||
|
|
||||||
|
for (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) {
|
||||||
|
var path = (i >= 0)
|
||||||
|
? arguments[i]
|
||||||
|
: process.cwd();
|
||||||
|
|
||||||
|
// Skip empty and invalid entries
|
||||||
|
if (typeof path !== 'string' || !path) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
resolvedPath = path + '/' + resolvedPath;
|
||||||
|
resolvedAbsolute = path.charAt(0) === '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
// At this point the path should be resolved to a full absolute path, but
|
||||||
|
// handle relative paths to be safe (might happen when process.cwd() fails)
|
||||||
|
|
||||||
|
// Normalize the path
|
||||||
|
resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
|
||||||
|
return !!p;
|
||||||
|
}), !resolvedAbsolute).join('/');
|
||||||
|
|
||||||
|
return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
|
||||||
|
};
|
||||||
|
|
||||||
|
// path.normalize(path)
|
||||||
|
// posix version
|
||||||
|
exports.normalize = function(path) {
|
||||||
|
var isAbsolute = path.charAt(0) === '/',
|
||||||
|
trailingSlash = path.slice(-1) === '/';
|
||||||
|
|
||||||
|
// Normalize the path
|
||||||
|
path = normalizeArray(filter(path.split('/'), function(p) {
|
||||||
|
return !!p;
|
||||||
|
}), !isAbsolute).join('/');
|
||||||
|
|
||||||
|
if (!path && !isAbsolute) {
|
||||||
|
path = '.';
|
||||||
|
}
|
||||||
|
if (path && trailingSlash) {
|
||||||
|
path += '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
return (isAbsolute ? '/' : '') + path;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// posix version
|
||||||
|
exports.join = function() {
|
||||||
|
var paths = Array.prototype.slice.call(arguments, 0);
|
||||||
|
return exports.normalize(filter(paths, function(p, index) {
|
||||||
|
return p && typeof p === 'string';
|
||||||
|
}).join('/'));
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
exports.dirname = function(path) {
|
||||||
|
var dir = splitPathRe.exec(path)[1] || '';
|
||||||
|
var isWindows = false;
|
||||||
|
if (!dir) {
|
||||||
|
// No dirname
|
||||||
|
return '.';
|
||||||
|
} else if (dir.length === 1 ||
|
||||||
|
(isWindows && dir.length <= 3 && dir.charAt(1) === ':')) {
|
||||||
|
// It is just a slash or a drive letter with a slash
|
||||||
|
return dir;
|
||||||
|
} else {
|
||||||
|
// It is a full dirname, strip trailing slash
|
||||||
|
return dir.substring(0, dir.length - 1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
exports.basename = function(path, ext) {
|
||||||
|
var f = splitPathRe.exec(path)[2] || '';
|
||||||
|
// TODO: make this comparison case-insensitive on windows?
|
||||||
|
if (ext && f.substr(-1 * ext.length) === ext) {
|
||||||
|
f = f.substr(0, f.length - ext.length);
|
||||||
|
}
|
||||||
|
return f;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
exports.extname = function(path) {
|
||||||
|
return splitPathRe.exec(path)[3] || '';
|
||||||
|
};
|
250
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/builtins/querystring.js
generated
vendored
Normal file
@ -0,0 +1,250 @@
|
|||||||
|
var isArray = typeof Array.isArray === 'function'
|
||||||
|
? Array.isArray
|
||||||
|
: function (xs) {
|
||||||
|
return Object.prototype.toString.call(xs) === '[object Array]'
|
||||||
|
};
|
||||||
|
|
||||||
|
var objectKeys = Object.keys || function objectKeys(object) {
|
||||||
|
if (object !== Object(object)) throw new TypeError('Invalid object');
|
||||||
|
var keys = [];
|
||||||
|
for (var key in object) if (object.hasOwnProperty(key)) keys[keys.length] = key;
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* querystring
|
||||||
|
* Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Library version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.version = '0.3.1';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Object#toString() ref for stringify().
|
||||||
|
*/
|
||||||
|
|
||||||
|
var toString = Object.prototype.toString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cache non-integer test regexp.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var notint = /[^0-9]/;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse the given query `str`, returning an object.
|
||||||
|
*
|
||||||
|
* @param {String} str
|
||||||
|
* @return {Object}
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.parse = function(str){
|
||||||
|
if (null == str || '' == str) return {};
|
||||||
|
|
||||||
|
function promote(parent, key) {
|
||||||
|
if (parent[key].length == 0) return parent[key] = {};
|
||||||
|
var t = {};
|
||||||
|
for (var i in parent[key]) t[i] = parent[key][i];
|
||||||
|
parent[key] = t;
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
return String(str)
|
||||||
|
.split('&')
|
||||||
|
.reduce(function(ret, pair){
|
||||||
|
try{
|
||||||
|
pair = decodeURIComponent(pair.replace(/\+/g, ' '));
|
||||||
|
} catch(e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
var eql = pair.indexOf('=')
|
||||||
|
, brace = lastBraceInKey(pair)
|
||||||
|
, key = pair.substr(0, brace || eql)
|
||||||
|
, val = pair.substr(brace || eql, pair.length)
|
||||||
|
, val = val.substr(val.indexOf('=') + 1, val.length)
|
||||||
|
, parent = ret;
|
||||||
|
|
||||||
|
// ?foo
|
||||||
|
if ('' == key) key = pair, val = '';
|
||||||
|
|
||||||
|
// nested
|
||||||
|
if (~key.indexOf(']')) {
|
||||||
|
var parts = key.split('[')
|
||||||
|
, len = parts.length
|
||||||
|
, last = len - 1;
|
||||||
|
|
||||||
|
function parse(parts, parent, key) {
|
||||||
|
var part = parts.shift();
|
||||||
|
|
||||||
|
// end
|
||||||
|
if (!part) {
|
||||||
|
if (isArray(parent[key])) {
|
||||||
|
parent[key].push(val);
|
||||||
|
} else if ('object' == typeof parent[key]) {
|
||||||
|
parent[key] = val;
|
||||||
|
} else if ('undefined' == typeof parent[key]) {
|
||||||
|
parent[key] = val;
|
||||||
|
} else {
|
||||||
|
parent[key] = [parent[key], val];
|
||||||
|
}
|
||||||
|
// array
|
||||||
|
} else {
|
||||||
|
obj = parent[key] = parent[key] || [];
|
||||||
|
if (']' == part) {
|
||||||
|
if (isArray(obj)) {
|
||||||
|
if ('' != val) obj.push(val);
|
||||||
|
} else if ('object' == typeof obj) {
|
||||||
|
obj[objectKeys(obj).length] = val;
|
||||||
|
} else {
|
||||||
|
obj = parent[key] = [parent[key], val];
|
||||||
|
}
|
||||||
|
// prop
|
||||||
|
} else if (~part.indexOf(']')) {
|
||||||
|
part = part.substr(0, part.length - 1);
|
||||||
|
if(notint.test(part) && isArray(obj)) obj = promote(parent, key);
|
||||||
|
parse(parts, obj, part);
|
||||||
|
// key
|
||||||
|
} else {
|
||||||
|
if(notint.test(part) && isArray(obj)) obj = promote(parent, key);
|
||||||
|
parse(parts, obj, part);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
parse(parts, parent, 'base');
|
||||||
|
// optimize
|
||||||
|
} else {
|
||||||
|
if (notint.test(key) && isArray(parent.base)) {
|
||||||
|
var t = {};
|
||||||
|
for(var k in parent.base) t[k] = parent.base[k];
|
||||||
|
parent.base = t;
|
||||||
|
}
|
||||||
|
set(parent.base, key, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}, {base: {}}).base;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn the given `obj` into a query string
|
||||||
|
*
|
||||||
|
* @param {Object} obj
|
||||||
|
* @return {String}
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
var stringify = exports.stringify = function(obj, prefix) {
|
||||||
|
if (isArray(obj)) {
|
||||||
|
return stringifyArray(obj, prefix);
|
||||||
|
} else if ('[object Object]' == toString.call(obj)) {
|
||||||
|
return stringifyObject(obj, prefix);
|
||||||
|
} else if ('string' == typeof obj) {
|
||||||
|
return stringifyString(obj, prefix);
|
||||||
|
} else {
|
||||||
|
return prefix;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stringify the given `str`.
|
||||||
|
*
|
||||||
|
* @param {String} str
|
||||||
|
* @param {String} prefix
|
||||||
|
* @return {String}
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function stringifyString(str, prefix) {
|
||||||
|
if (!prefix) throw new TypeError('stringify expects an object');
|
||||||
|
return prefix + '=' + encodeURIComponent(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stringify the given `arr`.
|
||||||
|
*
|
||||||
|
* @param {Array} arr
|
||||||
|
* @param {String} prefix
|
||||||
|
* @return {String}
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function stringifyArray(arr, prefix) {
|
||||||
|
var ret = [];
|
||||||
|
if (!prefix) throw new TypeError('stringify expects an object');
|
||||||
|
for (var i = 0; i < arr.length; i++) {
|
||||||
|
ret.push(stringify(arr[i], prefix + '[]'));
|
||||||
|
}
|
||||||
|
return ret.join('&');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stringify the given `obj`.
|
||||||
|
*
|
||||||
|
* @param {Object} obj
|
||||||
|
* @param {String} prefix
|
||||||
|
* @return {String}
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function stringifyObject(obj, prefix) {
|
||||||
|
var ret = []
|
||||||
|
, keys = objectKeys(obj)
|
||||||
|
, key;
|
||||||
|
for (var i = 0, len = keys.length; i < len; ++i) {
|
||||||
|
key = keys[i];
|
||||||
|
ret.push(stringify(obj[key], prefix
|
||||||
|
? prefix + '[' + encodeURIComponent(key) + ']'
|
||||||
|
: encodeURIComponent(key)));
|
||||||
|
}
|
||||||
|
return ret.join('&');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set `obj`'s `key` to `val` respecting
|
||||||
|
* the weird and wonderful syntax of a qs,
|
||||||
|
* where "foo=bar&foo=baz" becomes an array.
|
||||||
|
*
|
||||||
|
* @param {Object} obj
|
||||||
|
* @param {String} key
|
||||||
|
* @param {String} val
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function set(obj, key, val) {
|
||||||
|
var v = obj[key];
|
||||||
|
if (undefined === v) {
|
||||||
|
obj[key] = val;
|
||||||
|
} else if (isArray(v)) {
|
||||||
|
v.push(val);
|
||||||
|
} else {
|
||||||
|
obj[key] = [v, val];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Locate last brace in `str` within the key.
|
||||||
|
*
|
||||||
|
* @param {String} str
|
||||||
|
* @return {Number}
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function lastBraceInKey(str) {
|
||||||
|
var len = str.length
|
||||||
|
, brace
|
||||||
|
, c;
|
||||||
|
for (var i = 0; i < len; ++i) {
|
||||||
|
c = str[i];
|
||||||
|
if (']' == c) brace = false;
|
||||||
|
if ('[' == c) brace = true;
|
||||||
|
if ('=' == c && !brace) return i;
|
||||||
|
}
|
||||||
|
}
|
119
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/builtins/stream.js
generated
vendored
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
var events = require('events');
|
||||||
|
var util = require('util');
|
||||||
|
|
||||||
|
function Stream() {
|
||||||
|
events.EventEmitter.call(this);
|
||||||
|
}
|
||||||
|
util.inherits(Stream, events.EventEmitter);
|
||||||
|
module.exports = Stream;
|
||||||
|
// Backwards-compat with node 0.4.x
|
||||||
|
Stream.Stream = Stream;
|
||||||
|
|
||||||
|
Stream.prototype.pipe = function(dest, options) {
|
||||||
|
var source = this;
|
||||||
|
|
||||||
|
function ondata(chunk) {
|
||||||
|
if (dest.writable) {
|
||||||
|
if (false === dest.write(chunk) && source.pause) {
|
||||||
|
source.pause();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
source.on('data', ondata);
|
||||||
|
|
||||||
|
function ondrain() {
|
||||||
|
if (source.readable && source.resume) {
|
||||||
|
source.resume();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dest.on('drain', ondrain);
|
||||||
|
|
||||||
|
// If the 'end' option is not supplied, dest.end() will be called when
|
||||||
|
// source gets the 'end' or 'close' events. Only dest.end() once, and
|
||||||
|
// only when all sources have ended.
|
||||||
|
if (!dest._isStdio && (!options || options.end !== false)) {
|
||||||
|
dest._pipeCount = dest._pipeCount || 0;
|
||||||
|
dest._pipeCount++;
|
||||||
|
|
||||||
|
source.on('end', onend);
|
||||||
|
source.on('close', onclose);
|
||||||
|
}
|
||||||
|
|
||||||
|
var didOnEnd = false;
|
||||||
|
function onend() {
|
||||||
|
if (didOnEnd) return;
|
||||||
|
didOnEnd = true;
|
||||||
|
|
||||||
|
dest._pipeCount--;
|
||||||
|
|
||||||
|
// remove the listeners
|
||||||
|
cleanup();
|
||||||
|
|
||||||
|
if (dest._pipeCount > 0) {
|
||||||
|
// waiting for other incoming streams to end.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dest.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function onclose() {
|
||||||
|
if (didOnEnd) return;
|
||||||
|
didOnEnd = true;
|
||||||
|
|
||||||
|
dest._pipeCount--;
|
||||||
|
|
||||||
|
// remove the listeners
|
||||||
|
cleanup();
|
||||||
|
|
||||||
|
if (dest._pipeCount > 0) {
|
||||||
|
// waiting for other incoming streams to end.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dest.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
// don't leave dangling pipes when there are errors.
|
||||||
|
function onerror(er) {
|
||||||
|
cleanup();
|
||||||
|
if (this.listeners('error').length === 0) {
|
||||||
|
throw er; // Unhandled stream error in pipe.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
source.on('error', onerror);
|
||||||
|
dest.on('error', onerror);
|
||||||
|
|
||||||
|
// remove all the event listeners that were added.
|
||||||
|
function cleanup() {
|
||||||
|
source.removeListener('data', ondata);
|
||||||
|
dest.removeListener('drain', ondrain);
|
||||||
|
|
||||||
|
source.removeListener('end', onend);
|
||||||
|
source.removeListener('close', onclose);
|
||||||
|
|
||||||
|
source.removeListener('error', onerror);
|
||||||
|
dest.removeListener('error', onerror);
|
||||||
|
|
||||||
|
source.removeListener('end', cleanup);
|
||||||
|
source.removeListener('close', cleanup);
|
||||||
|
|
||||||
|
dest.removeListener('end', cleanup);
|
||||||
|
dest.removeListener('close', cleanup);
|
||||||
|
}
|
||||||
|
|
||||||
|
source.on('end', cleanup);
|
||||||
|
source.on('close', cleanup);
|
||||||
|
|
||||||
|
dest.on('end', cleanup);
|
||||||
|
dest.on('close', cleanup);
|
||||||
|
|
||||||
|
dest.emit('pipe', source);
|
||||||
|
|
||||||
|
// Allow for unix-like usage: A.pipe(B).pipe(C)
|
||||||
|
return dest;
|
||||||
|
};
|
161
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/builtins/string_decoder.js
generated
vendored
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
var StringDecoder = exports.StringDecoder = function(encoding) {
|
||||||
|
this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
|
||||||
|
switch (this.encoding) {
|
||||||
|
case 'utf8':
|
||||||
|
// CESU-8 represents each of Surrogate Pair by 3-bytes
|
||||||
|
this.surrogateSize = 3;
|
||||||
|
break;
|
||||||
|
case 'ucs2':
|
||||||
|
case 'utf16le':
|
||||||
|
// UTF-16 represents each of Surrogate Pair by 2-bytes
|
||||||
|
this.surrogateSize = 2;
|
||||||
|
this.detectIncompleteChar = utf16DetectIncompleteChar;
|
||||||
|
break;
|
||||||
|
case 'base64':
|
||||||
|
// Base-64 stores 3 bytes in 4 chars, and pads the remainder.
|
||||||
|
this.surrogateSize = 3;
|
||||||
|
this.detectIncompleteChar = base64DetectIncompleteChar;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
this.write = passThroughWrite;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.charBuffer = new Buffer(6);
|
||||||
|
this.charReceived = 0;
|
||||||
|
this.charLength = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
StringDecoder.prototype.write = function(buffer) {
|
||||||
|
var charStr = '';
|
||||||
|
var offset = 0;
|
||||||
|
|
||||||
|
// if our last write ended with an incomplete multibyte character
|
||||||
|
while (this.charLength) {
|
||||||
|
// determine how many remaining bytes this buffer has to offer for this char
|
||||||
|
var i = (buffer.length >= this.charLength - this.charReceived) ?
|
||||||
|
this.charLength - this.charReceived :
|
||||||
|
buffer.length;
|
||||||
|
|
||||||
|
// add the new bytes to the char buffer
|
||||||
|
buffer.copy(this.charBuffer, this.charReceived, offset, i);
|
||||||
|
this.charReceived += (i - offset);
|
||||||
|
offset = i;
|
||||||
|
|
||||||
|
if (this.charReceived < this.charLength) {
|
||||||
|
// still not enough chars in this buffer? wait for more ...
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the character that was split
|
||||||
|
charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
|
||||||
|
|
||||||
|
// lead surrogate (D800-DBFF) is also the incomplete character
|
||||||
|
var charCode = charStr.charCodeAt(charStr.length - 1);
|
||||||
|
if (charCode >= 0xD800 && charCode <= 0xDBFF) {
|
||||||
|
this.charLength += this.surrogateSize;
|
||||||
|
charStr = '';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
this.charReceived = this.charLength = 0;
|
||||||
|
|
||||||
|
// if there are no more bytes in this buffer, just emit our char
|
||||||
|
if (i == buffer.length) return charStr;
|
||||||
|
|
||||||
|
// otherwise cut off the characters end from the beginning of this buffer
|
||||||
|
buffer = buffer.slice(i, buffer.length);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
var lenIncomplete = this.detectIncompleteChar(buffer);
|
||||||
|
|
||||||
|
var end = buffer.length;
|
||||||
|
if (this.charLength) {
|
||||||
|
// buffer the incomplete character bytes we got
|
||||||
|
buffer.copy(this.charBuffer, 0, buffer.length - lenIncomplete, end);
|
||||||
|
this.charReceived = lenIncomplete;
|
||||||
|
end -= lenIncomplete;
|
||||||
|
}
|
||||||
|
|
||||||
|
charStr += buffer.toString(this.encoding, 0, end);
|
||||||
|
|
||||||
|
var end = charStr.length - 1;
|
||||||
|
var charCode = charStr.charCodeAt(end);
|
||||||
|
// lead surrogate (D800-DBFF) is also the incomplete character
|
||||||
|
if (charCode >= 0xD800 && charCode <= 0xDBFF) {
|
||||||
|
var size = this.surrogateSize;
|
||||||
|
this.charLength += size;
|
||||||
|
this.charReceived += size;
|
||||||
|
this.charBuffer.copy(this.charBuffer, size, 0, size);
|
||||||
|
this.charBuffer.write(charStr.charAt(charStr.length - 1), this.encoding);
|
||||||
|
return charStr.substring(0, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
// or just emit the charStr
|
||||||
|
return charStr;
|
||||||
|
};
|
||||||
|
|
||||||
|
StringDecoder.prototype.detectIncompleteChar = function(buffer) {
|
||||||
|
// determine how many bytes we have to check at the end of this buffer
|
||||||
|
var i = (buffer.length >= 3) ? 3 : buffer.length;
|
||||||
|
|
||||||
|
// Figure out if one of the last i bytes of our buffer announces an
|
||||||
|
// incomplete char.
|
||||||
|
for (; i > 0; i--) {
|
||||||
|
var c = buffer[buffer.length - i];
|
||||||
|
|
||||||
|
// See http://en.wikipedia.org/wiki/UTF-8#Description
|
||||||
|
|
||||||
|
// 110XXXXX
|
||||||
|
if (i == 1 && c >> 5 == 0x06) {
|
||||||
|
this.charLength = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1110XXXX
|
||||||
|
if (i <= 2 && c >> 4 == 0x0E) {
|
||||||
|
this.charLength = 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 11110XXX
|
||||||
|
if (i <= 3 && c >> 3 == 0x1E) {
|
||||||
|
this.charLength = 4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
};
|
||||||
|
|
||||||
|
StringDecoder.prototype.end = function(buffer) {
|
||||||
|
var res = '';
|
||||||
|
if (buffer && buffer.length)
|
||||||
|
res = this.write(buffer);
|
||||||
|
|
||||||
|
if (this.charReceived) {
|
||||||
|
var cr = this.charReceived;
|
||||||
|
var buf = this.charBuffer;
|
||||||
|
var enc = this.encoding;
|
||||||
|
res += buf.slice(0, cr).toString(enc);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
|
function passThroughWrite(buffer) {
|
||||||
|
return buffer.toString(this.encoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
function utf16DetectIncompleteChar(buffer) {
|
||||||
|
var incomplete = this.charReceived = buffer.length % 2;
|
||||||
|
this.charLength = incomplete ? 2 : 0;
|
||||||
|
return incomplete;
|
||||||
|
}
|
||||||
|
|
||||||
|
function base64DetectIncompleteChar(buffer) {
|
||||||
|
var incomplete = this.charReceived = buffer.length % 3;
|
||||||
|
this.charLength = incomplete ? 3 : 0;
|
||||||
|
return incomplete;
|
||||||
|
}
|
1
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/builtins/sys.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
module.exports = require('util');
|
1
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/builtins/tls.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
// todo
|
2
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/builtins/tty.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
exports.isatty = function () {};
|
||||||
|
exports.setRawMode = function () {};
|
604
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/builtins/url.js
generated
vendored
Normal file
@ -0,0 +1,604 @@
|
|||||||
|
var punycode = { encode : function (s) { return s } };
|
||||||
|
|
||||||
|
exports.parse = urlParse;
|
||||||
|
exports.resolve = urlResolve;
|
||||||
|
exports.resolveObject = urlResolveObject;
|
||||||
|
exports.format = urlFormat;
|
||||||
|
|
||||||
|
function arrayIndexOf(array, subject) {
|
||||||
|
for (var i = 0, j = array.length; i < j; i++) {
|
||||||
|
if(array[i] == subject) return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
var objectKeys = Object.keys || function objectKeys(object) {
|
||||||
|
if (object !== Object(object)) throw new TypeError('Invalid object');
|
||||||
|
var keys = [];
|
||||||
|
for (var key in object) if (object.hasOwnProperty(key)) keys[keys.length] = key;
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reference: RFC 3986, RFC 1808, RFC 2396
|
||||||
|
|
||||||
|
// define these here so at least they only have to be
|
||||||
|
// compiled once on the first module load.
|
||||||
|
var protocolPattern = /^([a-z0-9.+-]+:)/i,
|
||||||
|
portPattern = /:[0-9]+$/,
|
||||||
|
// RFC 2396: characters reserved for delimiting URLs.
|
||||||
|
delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
|
||||||
|
// RFC 2396: characters not allowed for various reasons.
|
||||||
|
unwise = ['{', '}', '|', '\\', '^', '~', '[', ']', '`'].concat(delims),
|
||||||
|
// Allowed by RFCs, but cause of XSS attacks. Always escape these.
|
||||||
|
autoEscape = ['\''],
|
||||||
|
// Characters that are never ever allowed in a hostname.
|
||||||
|
// Note that any invalid chars are also handled, but these
|
||||||
|
// are the ones that are *expected* to be seen, so we fast-path
|
||||||
|
// them.
|
||||||
|
nonHostChars = ['%', '/', '?', ';', '#']
|
||||||
|
.concat(unwise).concat(autoEscape),
|
||||||
|
nonAuthChars = ['/', '@', '?', '#'].concat(delims),
|
||||||
|
hostnameMaxLen = 255,
|
||||||
|
hostnamePartPattern = /^[a-zA-Z0-9][a-z0-9A-Z_-]{0,62}$/,
|
||||||
|
hostnamePartStart = /^([a-zA-Z0-9][a-z0-9A-Z_-]{0,62})(.*)$/,
|
||||||
|
// protocols that can allow "unsafe" and "unwise" chars.
|
||||||
|
unsafeProtocol = {
|
||||||
|
'javascript': true,
|
||||||
|
'javascript:': true
|
||||||
|
},
|
||||||
|
// protocols that never have a hostname.
|
||||||
|
hostlessProtocol = {
|
||||||
|
'javascript': true,
|
||||||
|
'javascript:': true
|
||||||
|
},
|
||||||
|
// protocols that always have a path component.
|
||||||
|
pathedProtocol = {
|
||||||
|
'http': true,
|
||||||
|
'https': true,
|
||||||
|
'ftp': true,
|
||||||
|
'gopher': true,
|
||||||
|
'file': true,
|
||||||
|
'http:': true,
|
||||||
|
'ftp:': true,
|
||||||
|
'gopher:': true,
|
||||||
|
'file:': true
|
||||||
|
},
|
||||||
|
// protocols that always contain a // bit.
|
||||||
|
slashedProtocol = {
|
||||||
|
'http': true,
|
||||||
|
'https': true,
|
||||||
|
'ftp': true,
|
||||||
|
'gopher': true,
|
||||||
|
'file': true,
|
||||||
|
'http:': true,
|
||||||
|
'https:': true,
|
||||||
|
'ftp:': true,
|
||||||
|
'gopher:': true,
|
||||||
|
'file:': true
|
||||||
|
},
|
||||||
|
querystring = require('querystring');
|
||||||
|
|
||||||
|
function urlParse(url, parseQueryString, slashesDenoteHost) {
|
||||||
|
if (url && typeof(url) === 'object' && url.href) return url;
|
||||||
|
|
||||||
|
if (typeof url !== 'string') {
|
||||||
|
throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
|
||||||
|
}
|
||||||
|
|
||||||
|
var out = {},
|
||||||
|
rest = url;
|
||||||
|
|
||||||
|
// cut off any delimiters.
|
||||||
|
// This is to support parse stuff like "<http://foo.com>"
|
||||||
|
for (var i = 0, l = rest.length; i < l; i++) {
|
||||||
|
if (arrayIndexOf(delims, rest.charAt(i)) === -1) break;
|
||||||
|
}
|
||||||
|
if (i !== 0) rest = rest.substr(i);
|
||||||
|
|
||||||
|
|
||||||
|
var proto = protocolPattern.exec(rest);
|
||||||
|
if (proto) {
|
||||||
|
proto = proto[0];
|
||||||
|
var lowerProto = proto.toLowerCase();
|
||||||
|
out.protocol = lowerProto;
|
||||||
|
rest = rest.substr(proto.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
// figure out if it's got a host
|
||||||
|
// user@server is *always* interpreted as a hostname, and url
|
||||||
|
// resolution will treat //foo/bar as host=foo,path=bar because that's
|
||||||
|
// how the browser resolves relative URLs.
|
||||||
|
if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
|
||||||
|
var slashes = rest.substr(0, 2) === '//';
|
||||||
|
if (slashes && !(proto && hostlessProtocol[proto])) {
|
||||||
|
rest = rest.substr(2);
|
||||||
|
out.slashes = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hostlessProtocol[proto] &&
|
||||||
|
(slashes || (proto && !slashedProtocol[proto]))) {
|
||||||
|
// there's a hostname.
|
||||||
|
// the first instance of /, ?, ;, or # ends the host.
|
||||||
|
// don't enforce full RFC correctness, just be unstupid about it.
|
||||||
|
|
||||||
|
// If there is an @ in the hostname, then non-host chars *are* allowed
|
||||||
|
// to the left of the first @ sign, unless some non-auth character
|
||||||
|
// comes *before* the @-sign.
|
||||||
|
// URLs are obnoxious.
|
||||||
|
var atSign = arrayIndexOf(rest, '@');
|
||||||
|
if (atSign !== -1) {
|
||||||
|
// there *may be* an auth
|
||||||
|
var hasAuth = true;
|
||||||
|
for (var i = 0, l = nonAuthChars.length; i < l; i++) {
|
||||||
|
var index = arrayIndexOf(rest, nonAuthChars[i]);
|
||||||
|
if (index !== -1 && index < atSign) {
|
||||||
|
// not a valid auth. Something like http://foo.com/bar@baz/
|
||||||
|
hasAuth = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hasAuth) {
|
||||||
|
// pluck off the auth portion.
|
||||||
|
out.auth = rest.substr(0, atSign);
|
||||||
|
rest = rest.substr(atSign + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var firstNonHost = -1;
|
||||||
|
for (var i = 0, l = nonHostChars.length; i < l; i++) {
|
||||||
|
var index = arrayIndexOf(rest, nonHostChars[i]);
|
||||||
|
if (index !== -1 &&
|
||||||
|
(firstNonHost < 0 || index < firstNonHost)) firstNonHost = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (firstNonHost !== -1) {
|
||||||
|
out.host = rest.substr(0, firstNonHost);
|
||||||
|
rest = rest.substr(firstNonHost);
|
||||||
|
} else {
|
||||||
|
out.host = rest;
|
||||||
|
rest = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// pull out port.
|
||||||
|
var p = parseHost(out.host);
|
||||||
|
var keys = objectKeys(p);
|
||||||
|
for (var i = 0, l = keys.length; i < l; i++) {
|
||||||
|
var key = keys[i];
|
||||||
|
out[key] = p[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
// we've indicated that there is a hostname,
|
||||||
|
// so even if it's empty, it has to be present.
|
||||||
|
out.hostname = out.hostname || '';
|
||||||
|
|
||||||
|
// validate a little.
|
||||||
|
if (out.hostname.length > hostnameMaxLen) {
|
||||||
|
out.hostname = '';
|
||||||
|
} else {
|
||||||
|
var hostparts = out.hostname.split(/\./);
|
||||||
|
for (var i = 0, l = hostparts.length; i < l; i++) {
|
||||||
|
var part = hostparts[i];
|
||||||
|
if (!part) continue;
|
||||||
|
if (!part.match(hostnamePartPattern)) {
|
||||||
|
var newpart = '';
|
||||||
|
for (var j = 0, k = part.length; j < k; j++) {
|
||||||
|
if (part.charCodeAt(j) > 127) {
|
||||||
|
// we replace non-ASCII char with a temporary placeholder
|
||||||
|
// we need this to make sure size of hostname is not
|
||||||
|
// broken by replacing non-ASCII by nothing
|
||||||
|
newpart += 'x';
|
||||||
|
} else {
|
||||||
|
newpart += part[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// we test again with ASCII char only
|
||||||
|
if (!newpart.match(hostnamePartPattern)) {
|
||||||
|
var validParts = hostparts.slice(0, i);
|
||||||
|
var notHost = hostparts.slice(i + 1);
|
||||||
|
var bit = part.match(hostnamePartStart);
|
||||||
|
if (bit) {
|
||||||
|
validParts.push(bit[1]);
|
||||||
|
notHost.unshift(bit[2]);
|
||||||
|
}
|
||||||
|
if (notHost.length) {
|
||||||
|
rest = '/' + notHost.join('.') + rest;
|
||||||
|
}
|
||||||
|
out.hostname = validParts.join('.');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// hostnames are always lower case.
|
||||||
|
out.hostname = out.hostname.toLowerCase();
|
||||||
|
|
||||||
|
// IDNA Support: Returns a puny coded representation of "domain".
|
||||||
|
// It only converts the part of the domain name that
|
||||||
|
// has non ASCII characters. I.e. it dosent matter if
|
||||||
|
// you call it with a domain that already is in ASCII.
|
||||||
|
var domainArray = out.hostname.split('.');
|
||||||
|
var newOut = [];
|
||||||
|
for (var i = 0; i < domainArray.length; ++i) {
|
||||||
|
var s = domainArray[i];
|
||||||
|
newOut.push(s.match(/[^A-Za-z0-9_-]/) ?
|
||||||
|
'xn--' + punycode.encode(s) : s);
|
||||||
|
}
|
||||||
|
out.hostname = newOut.join('.');
|
||||||
|
|
||||||
|
out.host = (out.hostname || '') +
|
||||||
|
((out.port) ? ':' + out.port : '');
|
||||||
|
out.href += out.host;
|
||||||
|
}
|
||||||
|
|
||||||
|
// now rest is set to the post-host stuff.
|
||||||
|
// chop off any delim chars.
|
||||||
|
if (!unsafeProtocol[lowerProto]) {
|
||||||
|
|
||||||
|
// First, make 100% sure that any "autoEscape" chars get
|
||||||
|
// escaped, even if encodeURIComponent doesn't think they
|
||||||
|
// need to be.
|
||||||
|
for (var i = 0, l = autoEscape.length; i < l; i++) {
|
||||||
|
var ae = autoEscape[i];
|
||||||
|
var esc = encodeURIComponent(ae);
|
||||||
|
if (esc === ae) {
|
||||||
|
esc = escape(ae);
|
||||||
|
}
|
||||||
|
rest = rest.split(ae).join(esc);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now make sure that delims never appear in a url.
|
||||||
|
var chop = rest.length;
|
||||||
|
for (var i = 0, l = delims.length; i < l; i++) {
|
||||||
|
var c = arrayIndexOf(rest, delims[i]);
|
||||||
|
if (c !== -1) {
|
||||||
|
chop = Math.min(c, chop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rest = rest.substr(0, chop);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// chop off from the tail first.
|
||||||
|
var hash = arrayIndexOf(rest, '#');
|
||||||
|
if (hash !== -1) {
|
||||||
|
// got a fragment string.
|
||||||
|
out.hash = rest.substr(hash);
|
||||||
|
rest = rest.slice(0, hash);
|
||||||
|
}
|
||||||
|
var qm = arrayIndexOf(rest, '?');
|
||||||
|
if (qm !== -1) {
|
||||||
|
out.search = rest.substr(qm);
|
||||||
|
out.query = rest.substr(qm + 1);
|
||||||
|
if (parseQueryString) {
|
||||||
|
out.query = querystring.parse(out.query);
|
||||||
|
}
|
||||||
|
rest = rest.slice(0, qm);
|
||||||
|
} else if (parseQueryString) {
|
||||||
|
// no query string, but parseQueryString still requested
|
||||||
|
out.search = '';
|
||||||
|
out.query = {};
|
||||||
|
}
|
||||||
|
if (rest) out.pathname = rest;
|
||||||
|
if (slashedProtocol[proto] &&
|
||||||
|
out.hostname && !out.pathname) {
|
||||||
|
out.pathname = '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
//to support http.request
|
||||||
|
if (out.pathname || out.search) {
|
||||||
|
out.path = (out.pathname ? out.pathname : '') +
|
||||||
|
(out.search ? out.search : '');
|
||||||
|
}
|
||||||
|
|
||||||
|
// finally, reconstruct the href based on what has been validated.
|
||||||
|
out.href = urlFormat(out);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// format a parsed object into a url string
|
||||||
|
function urlFormat(obj) {
|
||||||
|
// ensure it's an object, and not a string url.
|
||||||
|
// If it's an obj, this is a no-op.
|
||||||
|
// this way, you can call url_format() on strings
|
||||||
|
// to clean up potentially wonky urls.
|
||||||
|
if (typeof(obj) === 'string') obj = urlParse(obj);
|
||||||
|
|
||||||
|
var auth = obj.auth || '';
|
||||||
|
if (auth) {
|
||||||
|
auth = auth.split('@').join('%40');
|
||||||
|
for (var i = 0, l = nonAuthChars.length; i < l; i++) {
|
||||||
|
var nAC = nonAuthChars[i];
|
||||||
|
auth = auth.split(nAC).join(encodeURIComponent(nAC));
|
||||||
|
}
|
||||||
|
auth += '@';
|
||||||
|
}
|
||||||
|
|
||||||
|
var protocol = obj.protocol || '',
|
||||||
|
host = (obj.host !== undefined) ? auth + obj.host :
|
||||||
|
obj.hostname !== undefined ? (
|
||||||
|
auth + obj.hostname +
|
||||||
|
(obj.port ? ':' + obj.port : '')
|
||||||
|
) :
|
||||||
|
false,
|
||||||
|
pathname = obj.pathname || '',
|
||||||
|
query = obj.query &&
|
||||||
|
((typeof obj.query === 'object' &&
|
||||||
|
objectKeys(obj.query).length) ?
|
||||||
|
querystring.stringify(obj.query) :
|
||||||
|
'') || '',
|
||||||
|
search = obj.search || (query && ('?' + query)) || '',
|
||||||
|
hash = obj.hash || '';
|
||||||
|
|
||||||
|
if (protocol && protocol.substr(-1) !== ':') protocol += ':';
|
||||||
|
|
||||||
|
// only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
|
||||||
|
// unless they had them to begin with.
|
||||||
|
if (obj.slashes ||
|
||||||
|
(!protocol || slashedProtocol[protocol]) && host !== false) {
|
||||||
|
host = '//' + (host || '');
|
||||||
|
if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
|
||||||
|
} else if (!host) {
|
||||||
|
host = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
|
||||||
|
if (search && search.charAt(0) !== '?') search = '?' + search;
|
||||||
|
|
||||||
|
return protocol + host + pathname + search + hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
function urlResolve(source, relative) {
|
||||||
|
return urlFormat(urlResolveObject(source, relative));
|
||||||
|
}
|
||||||
|
|
||||||
|
function urlResolveObject(source, relative) {
|
||||||
|
if (!source) return relative;
|
||||||
|
|
||||||
|
source = urlParse(urlFormat(source), false, true);
|
||||||
|
relative = urlParse(urlFormat(relative), false, true);
|
||||||
|
|
||||||
|
// hash is always overridden, no matter what.
|
||||||
|
source.hash = relative.hash;
|
||||||
|
|
||||||
|
if (relative.href === '') {
|
||||||
|
source.href = urlFormat(source);
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
// hrefs like //foo/bar always cut to the protocol.
|
||||||
|
if (relative.slashes && !relative.protocol) {
|
||||||
|
relative.protocol = source.protocol;
|
||||||
|
//urlParse appends trailing / to urls like http://www.example.com
|
||||||
|
if (slashedProtocol[relative.protocol] &&
|
||||||
|
relative.hostname && !relative.pathname) {
|
||||||
|
relative.path = relative.pathname = '/';
|
||||||
|
}
|
||||||
|
relative.href = urlFormat(relative);
|
||||||
|
return relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (relative.protocol && relative.protocol !== source.protocol) {
|
||||||
|
// if it's a known url protocol, then changing
|
||||||
|
// the protocol does weird things
|
||||||
|
// first, if it's not file:, then we MUST have a host,
|
||||||
|
// and if there was a path
|
||||||
|
// to begin with, then we MUST have a path.
|
||||||
|
// if it is file:, then the host is dropped,
|
||||||
|
// because that's known to be hostless.
|
||||||
|
// anything else is assumed to be absolute.
|
||||||
|
if (!slashedProtocol[relative.protocol]) {
|
||||||
|
relative.href = urlFormat(relative);
|
||||||
|
return relative;
|
||||||
|
}
|
||||||
|
source.protocol = relative.protocol;
|
||||||
|
if (!relative.host && !hostlessProtocol[relative.protocol]) {
|
||||||
|
var relPath = (relative.pathname || '').split('/');
|
||||||
|
while (relPath.length && !(relative.host = relPath.shift()));
|
||||||
|
if (!relative.host) relative.host = '';
|
||||||
|
if (!relative.hostname) relative.hostname = '';
|
||||||
|
if (relPath[0] !== '') relPath.unshift('');
|
||||||
|
if (relPath.length < 2) relPath.unshift('');
|
||||||
|
relative.pathname = relPath.join('/');
|
||||||
|
}
|
||||||
|
source.pathname = relative.pathname;
|
||||||
|
source.search = relative.search;
|
||||||
|
source.query = relative.query;
|
||||||
|
source.host = relative.host || '';
|
||||||
|
source.auth = relative.auth;
|
||||||
|
source.hostname = relative.hostname || relative.host;
|
||||||
|
source.port = relative.port;
|
||||||
|
//to support http.request
|
||||||
|
if (source.pathname !== undefined || source.search !== undefined) {
|
||||||
|
source.path = (source.pathname ? source.pathname : '') +
|
||||||
|
(source.search ? source.search : '');
|
||||||
|
}
|
||||||
|
source.slashes = source.slashes || relative.slashes;
|
||||||
|
source.href = urlFormat(source);
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
var isSourceAbs = (source.pathname && source.pathname.charAt(0) === '/'),
|
||||||
|
isRelAbs = (
|
||||||
|
relative.host !== undefined ||
|
||||||
|
relative.pathname && relative.pathname.charAt(0) === '/'
|
||||||
|
),
|
||||||
|
mustEndAbs = (isRelAbs || isSourceAbs ||
|
||||||
|
(source.host && relative.pathname)),
|
||||||
|
removeAllDots = mustEndAbs,
|
||||||
|
srcPath = source.pathname && source.pathname.split('/') || [],
|
||||||
|
relPath = relative.pathname && relative.pathname.split('/') || [],
|
||||||
|
psychotic = source.protocol &&
|
||||||
|
!slashedProtocol[source.protocol];
|
||||||
|
|
||||||
|
// if the url is a non-slashed url, then relative
|
||||||
|
// links like ../.. should be able
|
||||||
|
// to crawl up to the hostname, as well. This is strange.
|
||||||
|
// source.protocol has already been set by now.
|
||||||
|
// Later on, put the first path part into the host field.
|
||||||
|
if (psychotic) {
|
||||||
|
|
||||||
|
delete source.hostname;
|
||||||
|
delete source.port;
|
||||||
|
if (source.host) {
|
||||||
|
if (srcPath[0] === '') srcPath[0] = source.host;
|
||||||
|
else srcPath.unshift(source.host);
|
||||||
|
}
|
||||||
|
delete source.host;
|
||||||
|
if (relative.protocol) {
|
||||||
|
delete relative.hostname;
|
||||||
|
delete relative.port;
|
||||||
|
if (relative.host) {
|
||||||
|
if (relPath[0] === '') relPath[0] = relative.host;
|
||||||
|
else relPath.unshift(relative.host);
|
||||||
|
}
|
||||||
|
delete relative.host;
|
||||||
|
}
|
||||||
|
mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isRelAbs) {
|
||||||
|
// it's absolute.
|
||||||
|
source.host = (relative.host || relative.host === '') ?
|
||||||
|
relative.host : source.host;
|
||||||
|
source.hostname = (relative.hostname || relative.hostname === '') ?
|
||||||
|
relative.hostname : source.hostname;
|
||||||
|
source.search = relative.search;
|
||||||
|
source.query = relative.query;
|
||||||
|
srcPath = relPath;
|
||||||
|
// fall through to the dot-handling below.
|
||||||
|
} else if (relPath.length) {
|
||||||
|
// it's relative
|
||||||
|
// throw away the existing file, and take the new path instead.
|
||||||
|
if (!srcPath) srcPath = [];
|
||||||
|
srcPath.pop();
|
||||||
|
srcPath = srcPath.concat(relPath);
|
||||||
|
source.search = relative.search;
|
||||||
|
source.query = relative.query;
|
||||||
|
} else if ('search' in relative) {
|
||||||
|
// just pull out the search.
|
||||||
|
// like href='?foo'.
|
||||||
|
// Put this after the other two cases because it simplifies the booleans
|
||||||
|
if (psychotic) {
|
||||||
|
source.hostname = source.host = srcPath.shift();
|
||||||
|
//occationaly the auth can get stuck only in host
|
||||||
|
//this especialy happens in cases like
|
||||||
|
//url.resolveObject('mailto:local1@domain1', 'local2@domain2')
|
||||||
|
var authInHost = source.host && arrayIndexOf(source.host, '@') > 0 ?
|
||||||
|
source.host.split('@') : false;
|
||||||
|
if (authInHost) {
|
||||||
|
source.auth = authInHost.shift();
|
||||||
|
source.host = source.hostname = authInHost.shift();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
source.search = relative.search;
|
||||||
|
source.query = relative.query;
|
||||||
|
//to support http.request
|
||||||
|
if (source.pathname !== undefined || source.search !== undefined) {
|
||||||
|
source.path = (source.pathname ? source.pathname : '') +
|
||||||
|
(source.search ? source.search : '');
|
||||||
|
}
|
||||||
|
source.href = urlFormat(source);
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
if (!srcPath.length) {
|
||||||
|
// no path at all. easy.
|
||||||
|
// we've already handled the other stuff above.
|
||||||
|
delete source.pathname;
|
||||||
|
//to support http.request
|
||||||
|
if (!source.search) {
|
||||||
|
source.path = '/' + source.search;
|
||||||
|
} else {
|
||||||
|
delete source.path;
|
||||||
|
}
|
||||||
|
source.href = urlFormat(source);
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
// if a url ENDs in . or .., then it must get a trailing slash.
|
||||||
|
// however, if it ends in anything else non-slashy,
|
||||||
|
// then it must NOT get a trailing slash.
|
||||||
|
var last = srcPath.slice(-1)[0];
|
||||||
|
var hasTrailingSlash = (
|
||||||
|
(source.host || relative.host) && (last === '.' || last === '..') ||
|
||||||
|
last === '');
|
||||||
|
|
||||||
|
// strip single dots, resolve double dots to parent dir
|
||||||
|
// if the path tries to go above the root, `up` ends up > 0
|
||||||
|
var up = 0;
|
||||||
|
for (var i = srcPath.length; i >= 0; i--) {
|
||||||
|
last = srcPath[i];
|
||||||
|
if (last == '.') {
|
||||||
|
srcPath.splice(i, 1);
|
||||||
|
} else if (last === '..') {
|
||||||
|
srcPath.splice(i, 1);
|
||||||
|
up++;
|
||||||
|
} else if (up) {
|
||||||
|
srcPath.splice(i, 1);
|
||||||
|
up--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the path is allowed to go above the root, restore leading ..s
|
||||||
|
if (!mustEndAbs && !removeAllDots) {
|
||||||
|
for (; up--; up) {
|
||||||
|
srcPath.unshift('..');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mustEndAbs && srcPath[0] !== '' &&
|
||||||
|
(!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
|
||||||
|
srcPath.unshift('');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
|
||||||
|
srcPath.push('');
|
||||||
|
}
|
||||||
|
|
||||||
|
var isAbsolute = srcPath[0] === '' ||
|
||||||
|
(srcPath[0] && srcPath[0].charAt(0) === '/');
|
||||||
|
|
||||||
|
// put the host back
|
||||||
|
if (psychotic) {
|
||||||
|
source.hostname = source.host = isAbsolute ? '' :
|
||||||
|
srcPath.length ? srcPath.shift() : '';
|
||||||
|
//occationaly the auth can get stuck only in host
|
||||||
|
//this especialy happens in cases like
|
||||||
|
//url.resolveObject('mailto:local1@domain1', 'local2@domain2')
|
||||||
|
var authInHost = source.host && arrayIndexOf(source.host, '@') > 0 ?
|
||||||
|
source.host.split('@') : false;
|
||||||
|
if (authInHost) {
|
||||||
|
source.auth = authInHost.shift();
|
||||||
|
source.host = source.hostname = authInHost.shift();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mustEndAbs = mustEndAbs || (source.host && srcPath.length);
|
||||||
|
|
||||||
|
if (mustEndAbs && !isAbsolute) {
|
||||||
|
srcPath.unshift('');
|
||||||
|
}
|
||||||
|
|
||||||
|
source.pathname = srcPath.join('/');
|
||||||
|
//to support request.http
|
||||||
|
if (source.pathname !== undefined || source.search !== undefined) {
|
||||||
|
source.path = (source.pathname ? source.pathname : '') +
|
||||||
|
(source.search ? source.search : '');
|
||||||
|
}
|
||||||
|
source.auth = relative.auth || source.auth;
|
||||||
|
source.slashes = source.slashes || relative.slashes;
|
||||||
|
source.href = urlFormat(source);
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseHost(host) {
|
||||||
|
var out = {};
|
||||||
|
var port = portPattern.exec(host);
|
||||||
|
if (port) {
|
||||||
|
port = port[0];
|
||||||
|
out.port = port.substr(1);
|
||||||
|
host = host.substr(0, host.length - port.length);
|
||||||
|
}
|
||||||
|
if (host) out.hostname = host;
|
||||||
|
return out;
|
||||||
|
}
|
351
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/builtins/util.js
generated
vendored
Normal file
@ -0,0 +1,351 @@
|
|||||||
|
var events = require('events');
|
||||||
|
|
||||||
|
exports.isArray = isArray;
|
||||||
|
exports.isDate = function(obj){return Object.prototype.toString.call(obj) === '[object Date]'};
|
||||||
|
exports.isRegExp = function(obj){return Object.prototype.toString.call(obj) === '[object RegExp]'};
|
||||||
|
|
||||||
|
|
||||||
|
exports.print = function () {};
|
||||||
|
exports.puts = function () {};
|
||||||
|
exports.debug = function() {};
|
||||||
|
|
||||||
|
exports.inspect = function(obj, showHidden, depth, colors) {
|
||||||
|
var seen = [];
|
||||||
|
|
||||||
|
var stylize = function(str, styleType) {
|
||||||
|
// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
|
||||||
|
var styles =
|
||||||
|
{ 'bold' : [1, 22],
|
||||||
|
'italic' : [3, 23],
|
||||||
|
'underline' : [4, 24],
|
||||||
|
'inverse' : [7, 27],
|
||||||
|
'white' : [37, 39],
|
||||||
|
'grey' : [90, 39],
|
||||||
|
'black' : [30, 39],
|
||||||
|
'blue' : [34, 39],
|
||||||
|
'cyan' : [36, 39],
|
||||||
|
'green' : [32, 39],
|
||||||
|
'magenta' : [35, 39],
|
||||||
|
'red' : [31, 39],
|
||||||
|
'yellow' : [33, 39] };
|
||||||
|
|
||||||
|
var style =
|
||||||
|
{ 'special': 'cyan',
|
||||||
|
'number': 'blue',
|
||||||
|
'boolean': 'yellow',
|
||||||
|
'undefined': 'grey',
|
||||||
|
'null': 'bold',
|
||||||
|
'string': 'green',
|
||||||
|
'date': 'magenta',
|
||||||
|
// "name": intentionally not styling
|
||||||
|
'regexp': 'red' }[styleType];
|
||||||
|
|
||||||
|
if (style) {
|
||||||
|
return '\033[' + styles[style][0] + 'm' + str +
|
||||||
|
'\033[' + styles[style][1] + 'm';
|
||||||
|
} else {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (! colors) {
|
||||||
|
stylize = function(str, styleType) { return str; };
|
||||||
|
}
|
||||||
|
|
||||||
|
function format(value, recurseTimes) {
|
||||||
|
// Provide a hook for user-specified inspect functions.
|
||||||
|
// Check that value is an object with an inspect function on it
|
||||||
|
if (value && typeof value.inspect === 'function' &&
|
||||||
|
// Filter out the util module, it's inspect function is special
|
||||||
|
value !== exports &&
|
||||||
|
// Also filter out any prototype objects using the circular check.
|
||||||
|
!(value.constructor && value.constructor.prototype === value)) {
|
||||||
|
return value.inspect(recurseTimes);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Primitive types cannot have properties
|
||||||
|
switch (typeof value) {
|
||||||
|
case 'undefined':
|
||||||
|
return stylize('undefined', 'undefined');
|
||||||
|
|
||||||
|
case 'string':
|
||||||
|
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
|
||||||
|
.replace(/'/g, "\\'")
|
||||||
|
.replace(/\\"/g, '"') + '\'';
|
||||||
|
return stylize(simple, 'string');
|
||||||
|
|
||||||
|
case 'number':
|
||||||
|
return stylize('' + value, 'number');
|
||||||
|
|
||||||
|
case 'boolean':
|
||||||
|
return stylize('' + value, 'boolean');
|
||||||
|
}
|
||||||
|
// For some reason typeof null is "object", so special case here.
|
||||||
|
if (value === null) {
|
||||||
|
return stylize('null', 'null');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look up the keys of the object.
|
||||||
|
var visible_keys = Object_keys(value);
|
||||||
|
var keys = showHidden ? Object_getOwnPropertyNames(value) : visible_keys;
|
||||||
|
|
||||||
|
// Functions without properties can be shortcutted.
|
||||||
|
if (typeof value === 'function' && keys.length === 0) {
|
||||||
|
if (isRegExp(value)) {
|
||||||
|
return stylize('' + value, 'regexp');
|
||||||
|
} else {
|
||||||
|
var name = value.name ? ': ' + value.name : '';
|
||||||
|
return stylize('[Function' + name + ']', 'special');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dates without properties can be shortcutted
|
||||||
|
if (isDate(value) && keys.length === 0) {
|
||||||
|
return stylize(value.toUTCString(), 'date');
|
||||||
|
}
|
||||||
|
|
||||||
|
var base, type, braces;
|
||||||
|
// Determine the object type
|
||||||
|
if (isArray(value)) {
|
||||||
|
type = 'Array';
|
||||||
|
braces = ['[', ']'];
|
||||||
|
} else {
|
||||||
|
type = 'Object';
|
||||||
|
braces = ['{', '}'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make functions say that they are functions
|
||||||
|
if (typeof value === 'function') {
|
||||||
|
var n = value.name ? ': ' + value.name : '';
|
||||||
|
base = (isRegExp(value)) ? ' ' + value : ' [Function' + n + ']';
|
||||||
|
} else {
|
||||||
|
base = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make dates with properties first say the date
|
||||||
|
if (isDate(value)) {
|
||||||
|
base = ' ' + value.toUTCString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keys.length === 0) {
|
||||||
|
return braces[0] + base + braces[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (recurseTimes < 0) {
|
||||||
|
if (isRegExp(value)) {
|
||||||
|
return stylize('' + value, 'regexp');
|
||||||
|
} else {
|
||||||
|
return stylize('[Object]', 'special');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
seen.push(value);
|
||||||
|
|
||||||
|
var output = keys.map(function(key) {
|
||||||
|
var name, str;
|
||||||
|
if (value.__lookupGetter__) {
|
||||||
|
if (value.__lookupGetter__(key)) {
|
||||||
|
if (value.__lookupSetter__(key)) {
|
||||||
|
str = stylize('[Getter/Setter]', 'special');
|
||||||
|
} else {
|
||||||
|
str = stylize('[Getter]', 'special');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (value.__lookupSetter__(key)) {
|
||||||
|
str = stylize('[Setter]', 'special');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (visible_keys.indexOf(key) < 0) {
|
||||||
|
name = '[' + key + ']';
|
||||||
|
}
|
||||||
|
if (!str) {
|
||||||
|
if (seen.indexOf(value[key]) < 0) {
|
||||||
|
if (recurseTimes === null) {
|
||||||
|
str = format(value[key]);
|
||||||
|
} else {
|
||||||
|
str = format(value[key], recurseTimes - 1);
|
||||||
|
}
|
||||||
|
if (str.indexOf('\n') > -1) {
|
||||||
|
if (isArray(value)) {
|
||||||
|
str = str.split('\n').map(function(line) {
|
||||||
|
return ' ' + line;
|
||||||
|
}).join('\n').substr(2);
|
||||||
|
} else {
|
||||||
|
str = '\n' + str.split('\n').map(function(line) {
|
||||||
|
return ' ' + line;
|
||||||
|
}).join('\n');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
str = stylize('[Circular]', 'special');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (typeof name === 'undefined') {
|
||||||
|
if (type === 'Array' && key.match(/^\d+$/)) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
name = JSON.stringify('' + key);
|
||||||
|
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
|
||||||
|
name = name.substr(1, name.length - 2);
|
||||||
|
name = stylize(name, 'name');
|
||||||
|
} else {
|
||||||
|
name = name.replace(/'/g, "\\'")
|
||||||
|
.replace(/\\"/g, '"')
|
||||||
|
.replace(/(^"|"$)/g, "'");
|
||||||
|
name = stylize(name, 'string');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return name + ': ' + str;
|
||||||
|
});
|
||||||
|
|
||||||
|
seen.pop();
|
||||||
|
|
||||||
|
var numLinesEst = 0;
|
||||||
|
var length = output.reduce(function(prev, cur) {
|
||||||
|
numLinesEst++;
|
||||||
|
if (cur.indexOf('\n') >= 0) numLinesEst++;
|
||||||
|
return prev + cur.length + 1;
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
if (length > 50) {
|
||||||
|
output = braces[0] +
|
||||||
|
(base === '' ? '' : base + '\n ') +
|
||||||
|
' ' +
|
||||||
|
output.join(',\n ') +
|
||||||
|
' ' +
|
||||||
|
braces[1];
|
||||||
|
|
||||||
|
} else {
|
||||||
|
output = braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
return format(obj, (typeof depth === 'undefined' ? 2 : depth));
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function isArray(ar) {
|
||||||
|
return ar instanceof Array ||
|
||||||
|
Array.isArray(ar) ||
|
||||||
|
(ar && ar !== Object.prototype && isArray(ar.__proto__));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function isRegExp(re) {
|
||||||
|
return re instanceof RegExp ||
|
||||||
|
(typeof re === 'object' && Object.prototype.toString.call(re) === '[object RegExp]');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function isDate(d) {
|
||||||
|
if (d instanceof Date) return true;
|
||||||
|
if (typeof d !== 'object') return false;
|
||||||
|
var properties = Date.prototype && Object_getOwnPropertyNames(Date.prototype);
|
||||||
|
var proto = d.__proto__ && Object_getOwnPropertyNames(d.__proto__);
|
||||||
|
return JSON.stringify(proto) === JSON.stringify(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
function pad(n) {
|
||||||
|
return n < 10 ? '0' + n.toString(10) : n.toString(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
|
||||||
|
'Oct', 'Nov', 'Dec'];
|
||||||
|
|
||||||
|
// 26 Feb 16:19:34
|
||||||
|
function timestamp() {
|
||||||
|
var d = new Date();
|
||||||
|
var time = [pad(d.getHours()),
|
||||||
|
pad(d.getMinutes()),
|
||||||
|
pad(d.getSeconds())].join(':');
|
||||||
|
return [d.getDate(), months[d.getMonth()], time].join(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.log = function (msg) {};
|
||||||
|
|
||||||
|
exports.pump = null;
|
||||||
|
|
||||||
|
var Object_keys = Object.keys || function (obj) {
|
||||||
|
var res = [];
|
||||||
|
for (var key in obj) res.push(key);
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
|
var Object_getOwnPropertyNames = Object.getOwnPropertyNames || function (obj) {
|
||||||
|
var res = [];
|
||||||
|
for (var key in obj) {
|
||||||
|
if (Object.hasOwnProperty.call(obj, key)) res.push(key);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
|
var Object_create = Object.create || function (prototype, properties) {
|
||||||
|
// from es5-shim
|
||||||
|
var object;
|
||||||
|
if (prototype === null) {
|
||||||
|
object = { '__proto__' : null };
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (typeof prototype !== 'object') {
|
||||||
|
throw new TypeError(
|
||||||
|
'typeof prototype[' + (typeof prototype) + '] != \'object\''
|
||||||
|
);
|
||||||
|
}
|
||||||
|
var Type = function () {};
|
||||||
|
Type.prototype = prototype;
|
||||||
|
object = new Type();
|
||||||
|
object.__proto__ = prototype;
|
||||||
|
}
|
||||||
|
if (typeof properties !== 'undefined' && Object.defineProperties) {
|
||||||
|
Object.defineProperties(object, properties);
|
||||||
|
}
|
||||||
|
return object;
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.inherits = function(ctor, superCtor) {
|
||||||
|
ctor.super_ = superCtor;
|
||||||
|
ctor.prototype = Object_create(superCtor.prototype, {
|
||||||
|
constructor: {
|
||||||
|
value: ctor,
|
||||||
|
enumerable: false,
|
||||||
|
writable: true,
|
||||||
|
configurable: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var formatRegExp = /%[sdj%]/g;
|
||||||
|
exports.format = function(f) {
|
||||||
|
if (typeof f !== 'string') {
|
||||||
|
var objects = [];
|
||||||
|
for (var i = 0; i < arguments.length; i++) {
|
||||||
|
objects.push(exports.inspect(arguments[i]));
|
||||||
|
}
|
||||||
|
return objects.join(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
var i = 1;
|
||||||
|
var args = arguments;
|
||||||
|
var len = args.length;
|
||||||
|
var str = String(f).replace(formatRegExp, function(x) {
|
||||||
|
if (x === '%%') return '%';
|
||||||
|
if (i >= len) return x;
|
||||||
|
switch (x) {
|
||||||
|
case '%s': return String(args[i++]);
|
||||||
|
case '%d': return Number(args[i++]);
|
||||||
|
case '%j': return JSON.stringify(args[i++]);
|
||||||
|
default:
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
for(var x = args[i]; i < len; x = args[++i]){
|
||||||
|
if (x === null || typeof x !== 'object') {
|
||||||
|
str += ' ' + x;
|
||||||
|
} else {
|
||||||
|
str += ' ' + exports.inspect(x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
};
|
182
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/doc/methods.markdown
generated
vendored
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
methods
|
||||||
|
=======
|
||||||
|
|
||||||
|
This section documents the browserify api.
|
||||||
|
|
||||||
|
````javascript
|
||||||
|
var browserify = require('browserify');
|
||||||
|
````
|
||||||
|
|
||||||
|
var b = browserify(opts={})
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
Return a new bundle object.
|
||||||
|
|
||||||
|
`opts` may also contain these fields:
|
||||||
|
|
||||||
|
* watch - set watches on files, see below
|
||||||
|
* cache - turn on caching for AST traversals, see below
|
||||||
|
* debug - turn on source mapping for debugging with `//@ sourceURL=...`
|
||||||
|
in browsers that support it
|
||||||
|
* exports - an array of the core items to export to the namespace. Available
|
||||||
|
items: 'require', 'process'
|
||||||
|
|
||||||
|
If `opts` is a string, it is interpreted as a file to call `.addEntry()` with.
|
||||||
|
|
||||||
|
### watch :: Boolean or Object
|
||||||
|
|
||||||
|
Set watches on files and automatically rebundle when a file changes.
|
||||||
|
|
||||||
|
This option defaults to false. If `opts.watch` is set to true, default watch
|
||||||
|
arguments are assumed or you can pass in an object to pass along as the second
|
||||||
|
parameter to `fs.watchFile()`.
|
||||||
|
|
||||||
|
### cache :: Boolean or String
|
||||||
|
|
||||||
|
If `cache` is a boolean, turn on caching at
|
||||||
|
`$HOME/.config/browserify/cache.json`.
|
||||||
|
|
||||||
|
If `cache` is a string, turn on caching at the filename specified by `cache`.
|
||||||
|
|
||||||
|
### bundle events
|
||||||
|
|
||||||
|
`b` bundles will also emit events.
|
||||||
|
|
||||||
|
#### 'syntaxError', err
|
||||||
|
|
||||||
|
This event gets emitted when there is a syntax error somewhere in the build
|
||||||
|
process. If you don't listen for this event, the error will be printed to
|
||||||
|
stderr.
|
||||||
|
|
||||||
|
#### 'bundle'
|
||||||
|
|
||||||
|
In watch mode, this event is emitted when a new bundle has been generated.
|
||||||
|
|
||||||
|
b.bundle()
|
||||||
|
----------
|
||||||
|
|
||||||
|
Return the bundled source as a string.
|
||||||
|
|
||||||
|
By default, `require` is not exported to the environment if there are entry
|
||||||
|
files in the bundle but you can override that with `opts.exports`.
|
||||||
|
|
||||||
|
`process` is only exported to the environment when `opts.exports` contains the
|
||||||
|
string `'process'`.
|
||||||
|
|
||||||
|
b.require(file)
|
||||||
|
---------------
|
||||||
|
|
||||||
|
Require a file or files for inclusion in the bundle.
|
||||||
|
|
||||||
|
If `file` is an array, require each element in it.
|
||||||
|
|
||||||
|
If `file` is a non-array object, map an alias to a package name.
|
||||||
|
For instance to be able to map `require('jquery')` to the jquery-browserify
|
||||||
|
package, you can do:
|
||||||
|
|
||||||
|
````javascript
|
||||||
|
b.require({ jquery : 'jquery-browserify' })
|
||||||
|
````
|
||||||
|
|
||||||
|
and the same thing in middleware-form:
|
||||||
|
|
||||||
|
````javascript
|
||||||
|
browserify({ require : { jquery : 'jquery-browserify' } })
|
||||||
|
````
|
||||||
|
|
||||||
|
To mix alias objects with regular requires you could do:
|
||||||
|
|
||||||
|
````javascript
|
||||||
|
browserify({ require : [ 'seq', { jquery : 'jquery-browserify' }, 'traverse' ])
|
||||||
|
````
|
||||||
|
|
||||||
|
In practice you won't need to `b.require()` very many files since all the
|
||||||
|
`require()`s are read from each file that you require and automatically
|
||||||
|
included.
|
||||||
|
|
||||||
|
b.ignore(file)
|
||||||
|
--------------
|
||||||
|
|
||||||
|
Omit a file or files from being included by the AST walk to hunt down
|
||||||
|
`require()` statements.
|
||||||
|
|
||||||
|
b.addEntry(file)
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Append a file to the end of the bundle and execute it without having to
|
||||||
|
`require()` it.
|
||||||
|
|
||||||
|
Specifying an entry point will let you `require()` other modules without having
|
||||||
|
to load the entry point in a `<script>` tag yourself.
|
||||||
|
|
||||||
|
If entry is an Array, concatenate these files together and append to the end of
|
||||||
|
the bundle.
|
||||||
|
|
||||||
|
b.filter(fn)
|
||||||
|
------------
|
||||||
|
|
||||||
|
Transform the source using the filter function `fn(src)`. The return value of
|
||||||
|
`fn` should be the new source.
|
||||||
|
|
||||||
|
b.register(ext, fn)
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
Register a handler to wrap extensions.
|
||||||
|
|
||||||
|
Wrap every file matching the extension `ext` with the function `fn`.
|
||||||
|
|
||||||
|
For every `file` included into the bundle `fn` gets called for matching file
|
||||||
|
types as `fn.call(b, body, file)` for the bundle instance `b` and the file
|
||||||
|
content string `body`. `fn` should return the new wrapped contents.
|
||||||
|
|
||||||
|
If `ext` is unspecified, execute the wrapper for every file.
|
||||||
|
|
||||||
|
If `ext` is 'post', execute the wrapper on the entire bundle.
|
||||||
|
|
||||||
|
If `ext` is 'pre', call the wrapper function with the bundle object before the
|
||||||
|
source is generated.
|
||||||
|
|
||||||
|
If `ext` is 'path', execute the wrapper for every `file` before it is open,
|
||||||
|
allowing the extension to change it. `fn` gets called as `fn.call(b, file)`
|
||||||
|
for the bundle instance `b` and the file path `file`. `fn` should return the
|
||||||
|
new path to the file.
|
||||||
|
|
||||||
|
If `ext` is an object, pull the extension from `ext.extension` and the wrapper
|
||||||
|
function `fn` from `ext.wrapper`. This makes it easy to write plugins like
|
||||||
|
[fileify](https://github.com/substack/node-fileify).
|
||||||
|
|
||||||
|
Coffee script support is just implemented internally as a `.register()`
|
||||||
|
extension:
|
||||||
|
|
||||||
|
````javascript
|
||||||
|
b.register('.coffee', function (body) {
|
||||||
|
return coffee.compile(body);
|
||||||
|
});
|
||||||
|
````
|
||||||
|
|
||||||
|
b.use(fn)
|
||||||
|
---------
|
||||||
|
|
||||||
|
Use a middleware plugin, `fn`. `fn` is called with the instance object `b`.
|
||||||
|
|
||||||
|
b.prepend(content)
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Prepend unwrapped content to the beginning of the bundle.
|
||||||
|
|
||||||
|
b.append(content)
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
Append unwrapped content to the end of the bundle.
|
||||||
|
|
||||||
|
b.alias(to, from)
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
Alias a package name from another package name.
|
||||||
|
|
||||||
|
b.modified
|
||||||
|
----------
|
||||||
|
|
||||||
|
Contains a Date object with the time the bundle was last modified. This field is
|
||||||
|
useful in conjunction with the `watch` field described in the `browserify()` to
|
||||||
|
generate unique `<script>` `src` values to force script reloading.
|
62
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/doc/recipes.markdown
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
recipes
|
||||||
|
=======
|
||||||
|
|
||||||
|
Here are some recipe-style examples for getting started.
|
||||||
|
|
||||||
|
use an npm module in the browser
|
||||||
|
================================
|
||||||
|
|
||||||
|
First install a module:
|
||||||
|
|
||||||
|
```
|
||||||
|
npm install traverse
|
||||||
|
```
|
||||||
|
|
||||||
|
Then write an `entry.js`:
|
||||||
|
|
||||||
|
````javascript
|
||||||
|
var traverse = require('traverse');
|
||||||
|
var obj = traverse({ a : 3, b : [ 4, 5 ] }).map(function (x) {
|
||||||
|
if (typeof x === 'number') this.update(x * 100)
|
||||||
|
});
|
||||||
|
console.dir(obj);
|
||||||
|
````
|
||||||
|
|
||||||
|
now bundle it!
|
||||||
|
|
||||||
|
```
|
||||||
|
$ browserify entry.js -o bundle.js
|
||||||
|
```
|
||||||
|
|
||||||
|
then put it in your html
|
||||||
|
|
||||||
|
``` html
|
||||||
|
<script src="bundle.js"></script>
|
||||||
|
```
|
||||||
|
|
||||||
|
and the entry.js will just run and `require('traverse')` will just work™.
|
||||||
|
|
||||||
|
convert a node module into a browser require-able standalone file
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
Install the `traverse` package into `./node_modules`:
|
||||||
|
|
||||||
|
```
|
||||||
|
npm install traverse
|
||||||
|
```
|
||||||
|
|
||||||
|
Bundle everything up with browserify:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ npm install -g browserify
|
||||||
|
$ browserify -r traverse -o bundle.js
|
||||||
|
```
|
||||||
|
|
||||||
|
Look at the files! There is a new one: `bundle.js`. Now go into HTML land:
|
||||||
|
|
||||||
|
``` html
|
||||||
|
<script src="bundle.js"></script>
|
||||||
|
<script>
|
||||||
|
var traverse = require('traverse');
|
||||||
|
</script>
|
||||||
|
```
|
219
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/example/debug/browserify.js
generated
vendored
Normal file
@ -0,0 +1,219 @@
|
|||||||
|
var require = function (file, cwd) {
|
||||||
|
var resolved = require.resolve(file, cwd || '/');
|
||||||
|
var mod = require.modules[resolved];
|
||||||
|
if (!mod) throw new Error(
|
||||||
|
'Failed to resolve module ' + file + ', tried ' + resolved
|
||||||
|
);
|
||||||
|
var res = mod._cached ? mod._cached : mod();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
require.paths = [];
|
||||||
|
require.modules = {};
|
||||||
|
require.extensions = [".js",".coffee"];
|
||||||
|
|
||||||
|
require._core = {
|
||||||
|
'assert': true,
|
||||||
|
'events': true,
|
||||||
|
'fs': true,
|
||||||
|
'path': true,
|
||||||
|
'vm': true
|
||||||
|
};
|
||||||
|
|
||||||
|
require.resolve = (function () {
|
||||||
|
return function (x, cwd) {
|
||||||
|
if (!cwd) cwd = '/';
|
||||||
|
|
||||||
|
if (require._core[x]) return x;
|
||||||
|
var path = require.modules.path();
|
||||||
|
var y = cwd || '.';
|
||||||
|
|
||||||
|
if (x.match(/^(?:\.\.?\/|\/)/)) {
|
||||||
|
var m = loadAsFileSync(path.resolve(y, x))
|
||||||
|
|| loadAsDirectorySync(path.resolve(y, x));
|
||||||
|
if (m) return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
var n = loadNodeModulesSync(x, y);
|
||||||
|
if (n) return n;
|
||||||
|
|
||||||
|
throw new Error("Cannot find module '" + x + "'");
|
||||||
|
|
||||||
|
function loadAsFileSync (x) {
|
||||||
|
if (require.modules[x]) {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < require.extensions.length; i++) {
|
||||||
|
var ext = require.extensions[i];
|
||||||
|
if (require.modules[x + ext]) return x + ext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadAsDirectorySync (x) {
|
||||||
|
x = x.replace(/\/+$/, '');
|
||||||
|
var pkgfile = x + '/package.json';
|
||||||
|
if (require.modules[pkgfile]) {
|
||||||
|
var pkg = require.modules[pkgfile]();
|
||||||
|
var b = pkg.browserify;
|
||||||
|
if (typeof b === 'object' && b.main) {
|
||||||
|
var m = loadAsFileSync(path.resolve(x, b.main));
|
||||||
|
if (m) return m;
|
||||||
|
}
|
||||||
|
else if (typeof b === 'string') {
|
||||||
|
var m = loadAsFileSync(path.resolve(x, b));
|
||||||
|
if (m) return m;
|
||||||
|
}
|
||||||
|
else if (pkg.main) {
|
||||||
|
var m = loadAsFileSync(path.resolve(x, pkg.main));
|
||||||
|
if (m) return m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return loadAsFileSync(x + '/index');
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadNodeModulesSync (x, start) {
|
||||||
|
var dirs = nodeModulesPathsSync(start);
|
||||||
|
for (var i = 0; i < dirs.length; i++) {
|
||||||
|
var dir = dirs[i];
|
||||||
|
var m = loadAsFileSync(dir + '/' + x);
|
||||||
|
if (m) return m;
|
||||||
|
var n = loadAsDirectorySync(dir + '/' + x);
|
||||||
|
if (n) return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
var m = loadAsFileSync(x);
|
||||||
|
if (m) return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
function nodeModulesPathsSync (start) {
|
||||||
|
var parts;
|
||||||
|
if (start === '/') parts = [ '' ];
|
||||||
|
else parts = path.normalize(start).split('/');
|
||||||
|
|
||||||
|
var dirs = [];
|
||||||
|
for (var i = parts.length - 1; i >= 0; i--) {
|
||||||
|
if (parts[i] === 'node_modules') continue;
|
||||||
|
var dir = parts.slice(0, i + 1).join('/') + '/node_modules';
|
||||||
|
dirs.push(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dirs;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
require.alias = function (from, to) {
|
||||||
|
var path = require.modules.path();
|
||||||
|
var res = null;
|
||||||
|
try {
|
||||||
|
res = require.resolve(from + '/package.json', '/');
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
res = require.resolve(from, '/');
|
||||||
|
}
|
||||||
|
var basedir = path.dirname(res);
|
||||||
|
|
||||||
|
var keys = (Object.keys || function (obj) {
|
||||||
|
var res = [];
|
||||||
|
for (var key in obj) res.push(key)
|
||||||
|
return res;
|
||||||
|
})(require.modules);
|
||||||
|
|
||||||
|
for (var i = 0; i < keys.length; i++) {
|
||||||
|
var key = keys[i];
|
||||||
|
if (key.slice(0, basedir.length + 1) === basedir + '/') {
|
||||||
|
var f = key.slice(basedir.length);
|
||||||
|
require.modules[to + f] = require.modules[basedir + f];
|
||||||
|
}
|
||||||
|
else if (key === basedir) {
|
||||||
|
require.modules[to] = require.modules[basedir];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
require.define = function (filename, fn) {
|
||||||
|
var dirname = require._core[filename]
|
||||||
|
? ''
|
||||||
|
: require.modules.path().dirname(filename)
|
||||||
|
;
|
||||||
|
|
||||||
|
var require_ = function (file) {
|
||||||
|
return require(file, dirname)
|
||||||
|
};
|
||||||
|
require_.resolve = function (name) {
|
||||||
|
return require.resolve(name, dirname);
|
||||||
|
};
|
||||||
|
require_.modules = require.modules;
|
||||||
|
require_.define = require.define;
|
||||||
|
var module_ = { exports : {} };
|
||||||
|
|
||||||
|
require.modules[filename] = function () {
|
||||||
|
require.modules[filename]._cached = module_.exports;
|
||||||
|
fn.call(
|
||||||
|
module_.exports,
|
||||||
|
require_,
|
||||||
|
module_,
|
||||||
|
module_.exports,
|
||||||
|
dirname,
|
||||||
|
filename
|
||||||
|
);
|
||||||
|
require.modules[filename]._cached = module_.exports;
|
||||||
|
return module_.exports;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
if (typeof process === 'undefined') process = {};
|
||||||
|
|
||||||
|
if (!process.nextTick) process.nextTick = (function () {
|
||||||
|
var queue = [];
|
||||||
|
var canPost = typeof window !== 'undefined'
|
||||||
|
&& window.postMessage && window.addEventListener
|
||||||
|
;
|
||||||
|
|
||||||
|
if (canPost) {
|
||||||
|
window.addEventListener('message', function (ev) {
|
||||||
|
if (ev.source === window && ev.data === 'browserify-tick') {
|
||||||
|
ev.stopPropagation();
|
||||||
|
if (queue.length > 0) {
|
||||||
|
var fn = queue.shift();
|
||||||
|
fn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return function (fn) {
|
||||||
|
if (canPost) {
|
||||||
|
queue.push(fn);
|
||||||
|
window.postMessage('browserify-tick', '*');
|
||||||
|
}
|
||||||
|
else setTimeout(fn, 0);
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
if (!process.title) process.title = 'browser';
|
||||||
|
|
||||||
|
if (!process.binding) process.binding = function (name) {
|
||||||
|
if (name === 'evals') return require('vm')
|
||||||
|
else throw new Error('No such module')
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!process.cwd) process.cwd = function () { return '.' };
|
||||||
|
|
||||||
|
require.define("path", Function(
|
||||||
|
[ 'require', 'module', 'exports', '__dirname', '__filename' ],
|
||||||
|
"function filter (xs, fn) {\n var res = [];\n for (var i = 0; i < xs.length; i++) {\n if (fn(xs[i], i, xs)) res.push(xs[i]);\n }\n return res;\n}\n\n// resolves . and .. elements in a path array with directory names there\n// must be no slashes, empty elements, or device names (c:\\) in the array\n// (so also no leading and trailing slashes - it does not distinguish\n// relative and absolute paths)\nfunction normalizeArray(parts, allowAboveRoot) {\n // if the path tries to go above the root, `up` ends up > 0\n var up = 0;\n for (var i = parts.length; i >= 0; i--) {\n var last = parts[i];\n if (last == '.') {\n parts.splice(i, 1);\n } else if (last === '..') {\n parts.splice(i, 1);\n up++;\n } else if (up) {\n parts.splice(i, 1);\n up--;\n }\n }\n\n // if the path is allowed to go above the root, restore leading ..s\n if (allowAboveRoot) {\n for (; up--; up) {\n parts.unshift('..');\n }\n }\n\n return parts;\n}\n\n// Regex to split a filename into [*, dir, basename, ext]\n// posix version\nvar splitPathRe = /^(.+\\/(?!$)|\\/)?((?:.+?)?(\\.[^.]*)?)$/;\n\n// path.resolve([from ...], to)\n// posix version\nexports.resolve = function() {\nvar resolvedPath = '',\n resolvedAbsolute = false;\n\nfor (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) {\n var path = (i >= 0)\n ? arguments[i]\n : process.cwd();\n\n // Skip empty and invalid entries\n if (typeof path !== 'string' || !path) {\n continue;\n }\n\n resolvedPath = path + '/' + resolvedPath;\n resolvedAbsolute = path.charAt(0) === '/';\n}\n\n// At this point the path should be resolved to a full absolute path, but\n// handle relative paths to be safe (might happen when process.cwd() fails)\n\n// Normalize the path\nresolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {\n return !!p;\n }), !resolvedAbsolute).join('/');\n\n return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';\n};\n\n// path.normalize(path)\n// posix version\nexports.normalize = function(path) {\nvar isAbsolute = path.charAt(0) === '/',\n trailingSlash = path.slice(-1) === '/';\n\n// Normalize the path\npath = normalizeArray(filter(path.split('/'), function(p) {\n return !!p;\n }), !isAbsolute).join('/');\n\n if (!path && !isAbsolute) {\n path = '.';\n }\n if (path && trailingSlash) {\n path += '/';\n }\n \n return (isAbsolute ? '/' : '') + path;\n};\n\n\n// posix version\nexports.join = function() {\n var paths = Array.prototype.slice.call(arguments, 0);\n return exports.normalize(filter(paths, function(p, index) {\n return p && typeof p === 'string';\n }).join('/'));\n};\n\n\nexports.dirname = function(path) {\n var dir = splitPathRe.exec(path)[1] || '';\n var isWindows = false;\n if (!dir) {\n // No dirname\n return '.';\n } else if (dir.length === 1 ||\n (isWindows && dir.length <= 3 && dir.charAt(1) === ':')) {\n // It is just a slash or a drive letter with a slash\n return dir;\n } else {\n // It is a full dirname, strip trailing slash\n return dir.substring(0, dir.length - 1);\n }\n};\n\n\nexports.basename = function(path, ext) {\n var f = splitPathRe.exec(path)[2] || '';\n // TODO: make this comparison case-insensitive on windows?\n if (ext && f.substr(-1 * ext.length) === ext) {\n f = f.substr(0, f.length - ext.length);\n }\n return f;\n};\n\n\nexports.extname = function(path) {\n return splitPathRe.exec(path)[3] || '';\n};\n\n//@ sourceURL=path"
|
||||||
|
));
|
||||||
|
|
||||||
|
require.define("/thrower.js", Function(
|
||||||
|
[ 'require', 'module', 'exports', '__dirname', '__filename' ],
|
||||||
|
"module.exports = function () {\n throw 'beep';\n};\n\n//@ sourceURL=/thrower.js"
|
||||||
|
));
|
||||||
|
|
||||||
|
require.define("/entry.js", Function(
|
||||||
|
[ 'require', 'module', 'exports', '__dirname', '__filename' ],
|
||||||
|
"var thrower = require('./thrower');\nthrower();\n\n//@ sourceURL=/entry.js"
|
||||||
|
));
|
||||||
|
require("/entry.js");
|
3
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/example/debug/build.sh
generated
vendored
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
browserify js/entry.js -v -o browserify.js --debug
|
7
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/example/debug/index.html
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<script type="text/javascript" src="/browserify.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
</body>
|
||||||
|
</html>
|
2
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/example/debug/js/entry.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
var thrower = require('./thrower');
|
||||||
|
thrower();
|
3
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/example/debug/js/thrower.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
module.exports = function () {
|
||||||
|
throw 'beep';
|
||||||
|
};
|
9
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/example/debug/server.js
generated
vendored
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
var connect = require('connect');
|
||||||
|
var server = connect.createServer();
|
||||||
|
|
||||||
|
server.use(connect.static(__dirname));
|
||||||
|
server.listen(8080);
|
||||||
|
console.log('Listening on :8080');
|
||||||
|
console.log('Make sure to run ./build.sh to generate browserify.js');
|
368
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/example/simple-build/browserify.js
generated
vendored
Normal file
@ -0,0 +1,368 @@
|
|||||||
|
var require = function (file, cwd) {
|
||||||
|
var resolved = require.resolve(file, cwd || '/');
|
||||||
|
var mod = require.modules[resolved];
|
||||||
|
if (!mod) throw new Error(
|
||||||
|
'Failed to resolve module ' + file + ', tried ' + resolved
|
||||||
|
);
|
||||||
|
var res = mod._cached ? mod._cached : mod();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
require.paths = [];
|
||||||
|
require.modules = {};
|
||||||
|
require.extensions = [".js",".coffee"];
|
||||||
|
|
||||||
|
require._core = {
|
||||||
|
'assert': true,
|
||||||
|
'events': true,
|
||||||
|
'fs': true,
|
||||||
|
'path': true,
|
||||||
|
'vm': true
|
||||||
|
};
|
||||||
|
|
||||||
|
require.resolve = (function () {
|
||||||
|
return function (x, cwd) {
|
||||||
|
if (!cwd) cwd = '/';
|
||||||
|
|
||||||
|
if (require._core[x]) return x;
|
||||||
|
var path = require.modules.path();
|
||||||
|
cwd = path.resolve('/', cwd);
|
||||||
|
var y = cwd || '/';
|
||||||
|
|
||||||
|
if (x.match(/^(?:\.\.?\/|\/)/)) {
|
||||||
|
var m = loadAsFileSync(path.resolve(y, x))
|
||||||
|
|| loadAsDirectorySync(path.resolve(y, x));
|
||||||
|
if (m) return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
var n = loadNodeModulesSync(x, y);
|
||||||
|
if (n) return n;
|
||||||
|
|
||||||
|
throw new Error("Cannot find module '" + x + "'");
|
||||||
|
|
||||||
|
function loadAsFileSync (x) {
|
||||||
|
if (require.modules[x]) {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < require.extensions.length; i++) {
|
||||||
|
var ext = require.extensions[i];
|
||||||
|
if (require.modules[x + ext]) return x + ext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadAsDirectorySync (x) {
|
||||||
|
x = x.replace(/\/+$/, '');
|
||||||
|
var pkgfile = x + '/package.json';
|
||||||
|
if (require.modules[pkgfile]) {
|
||||||
|
var pkg = require.modules[pkgfile]();
|
||||||
|
var b = pkg.browserify;
|
||||||
|
if (typeof b === 'object' && b.main) {
|
||||||
|
var m = loadAsFileSync(path.resolve(x, b.main));
|
||||||
|
if (m) return m;
|
||||||
|
}
|
||||||
|
else if (typeof b === 'string') {
|
||||||
|
var m = loadAsFileSync(path.resolve(x, b));
|
||||||
|
if (m) return m;
|
||||||
|
}
|
||||||
|
else if (pkg.main) {
|
||||||
|
var m = loadAsFileSync(path.resolve(x, pkg.main));
|
||||||
|
if (m) return m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return loadAsFileSync(x + '/index');
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadNodeModulesSync (x, start) {
|
||||||
|
var dirs = nodeModulesPathsSync(start);
|
||||||
|
for (var i = 0; i < dirs.length; i++) {
|
||||||
|
var dir = dirs[i];
|
||||||
|
var m = loadAsFileSync(dir + '/' + x);
|
||||||
|
if (m) return m;
|
||||||
|
var n = loadAsDirectorySync(dir + '/' + x);
|
||||||
|
if (n) return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
var m = loadAsFileSync(x);
|
||||||
|
if (m) return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
function nodeModulesPathsSync (start) {
|
||||||
|
var parts;
|
||||||
|
if (start === '/') parts = [ '' ];
|
||||||
|
else parts = path.normalize(start).split('/');
|
||||||
|
|
||||||
|
var dirs = [];
|
||||||
|
for (var i = parts.length - 1; i >= 0; i--) {
|
||||||
|
if (parts[i] === 'node_modules') continue;
|
||||||
|
var dir = parts.slice(0, i + 1).join('/') + '/node_modules';
|
||||||
|
dirs.push(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dirs;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
require.alias = function (from, to) {
|
||||||
|
var path = require.modules.path();
|
||||||
|
var res = null;
|
||||||
|
try {
|
||||||
|
res = require.resolve(from + '/package.json', '/');
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
res = require.resolve(from, '/');
|
||||||
|
}
|
||||||
|
var basedir = path.dirname(res);
|
||||||
|
|
||||||
|
var keys = (Object.keys || function (obj) {
|
||||||
|
var res = [];
|
||||||
|
for (var key in obj) res.push(key)
|
||||||
|
return res;
|
||||||
|
})(require.modules);
|
||||||
|
|
||||||
|
for (var i = 0; i < keys.length; i++) {
|
||||||
|
var key = keys[i];
|
||||||
|
if (key.slice(0, basedir.length + 1) === basedir + '/') {
|
||||||
|
var f = key.slice(basedir.length);
|
||||||
|
require.modules[to + f] = require.modules[basedir + f];
|
||||||
|
}
|
||||||
|
else if (key === basedir) {
|
||||||
|
require.modules[to] = require.modules[basedir];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
require.define = function (filename, fn) {
|
||||||
|
var dirname = require._core[filename]
|
||||||
|
? ''
|
||||||
|
: require.modules.path().dirname(filename)
|
||||||
|
;
|
||||||
|
|
||||||
|
var require_ = function (file) {
|
||||||
|
return require(file, dirname)
|
||||||
|
};
|
||||||
|
require_.resolve = function (name) {
|
||||||
|
return require.resolve(name, dirname);
|
||||||
|
};
|
||||||
|
require_.modules = require.modules;
|
||||||
|
require_.define = require.define;
|
||||||
|
var module_ = { exports : {} };
|
||||||
|
|
||||||
|
require.modules[filename] = function () {
|
||||||
|
require.modules[filename]._cached = module_.exports;
|
||||||
|
fn.call(
|
||||||
|
module_.exports,
|
||||||
|
require_,
|
||||||
|
module_,
|
||||||
|
module_.exports,
|
||||||
|
dirname,
|
||||||
|
filename
|
||||||
|
);
|
||||||
|
require.modules[filename]._cached = module_.exports;
|
||||||
|
return module_.exports;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
if (typeof process === 'undefined') process = {};
|
||||||
|
|
||||||
|
if (!process.nextTick) process.nextTick = (function () {
|
||||||
|
var queue = [];
|
||||||
|
var canPost = typeof window !== 'undefined'
|
||||||
|
&& window.postMessage && window.addEventListener
|
||||||
|
;
|
||||||
|
|
||||||
|
if (canPost) {
|
||||||
|
window.addEventListener('message', function (ev) {
|
||||||
|
if (ev.source === window && ev.data === 'browserify-tick') {
|
||||||
|
ev.stopPropagation();
|
||||||
|
if (queue.length > 0) {
|
||||||
|
var fn = queue.shift();
|
||||||
|
fn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return function (fn) {
|
||||||
|
if (canPost) {
|
||||||
|
queue.push(fn);
|
||||||
|
window.postMessage('browserify-tick', '*');
|
||||||
|
}
|
||||||
|
else setTimeout(fn, 0);
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
if (!process.title) process.title = 'browser';
|
||||||
|
|
||||||
|
if (!process.binding) process.binding = function (name) {
|
||||||
|
if (name === 'evals') return require('vm')
|
||||||
|
else throw new Error('No such module')
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!process.cwd) process.cwd = function () { return '.' };
|
||||||
|
|
||||||
|
require.define("path", function (require, module, exports, __dirname, __filename) {
|
||||||
|
function filter (xs, fn) {
|
||||||
|
var res = [];
|
||||||
|
for (var i = 0; i < xs.length; i++) {
|
||||||
|
if (fn(xs[i], i, xs)) res.push(xs[i]);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
// resolves . and .. elements in a path array with directory names there
|
||||||
|
// must be no slashes, empty elements, or device names (c:\) in the array
|
||||||
|
// (so also no leading and trailing slashes - it does not distinguish
|
||||||
|
// relative and absolute paths)
|
||||||
|
function normalizeArray(parts, allowAboveRoot) {
|
||||||
|
// if the path tries to go above the root, `up` ends up > 0
|
||||||
|
var up = 0;
|
||||||
|
for (var i = parts.length; i >= 0; i--) {
|
||||||
|
var last = parts[i];
|
||||||
|
if (last == '.') {
|
||||||
|
parts.splice(i, 1);
|
||||||
|
} else if (last === '..') {
|
||||||
|
parts.splice(i, 1);
|
||||||
|
up++;
|
||||||
|
} else if (up) {
|
||||||
|
parts.splice(i, 1);
|
||||||
|
up--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the path is allowed to go above the root, restore leading ..s
|
||||||
|
if (allowAboveRoot) {
|
||||||
|
for (; up--; up) {
|
||||||
|
parts.unshift('..');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return parts;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Regex to split a filename into [*, dir, basename, ext]
|
||||||
|
// posix version
|
||||||
|
var splitPathRe = /^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;
|
||||||
|
|
||||||
|
// path.resolve([from ...], to)
|
||||||
|
// posix version
|
||||||
|
exports.resolve = function() {
|
||||||
|
var resolvedPath = '',
|
||||||
|
resolvedAbsolute = false;
|
||||||
|
|
||||||
|
for (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) {
|
||||||
|
var path = (i >= 0)
|
||||||
|
? arguments[i]
|
||||||
|
: process.cwd();
|
||||||
|
|
||||||
|
// Skip empty and invalid entries
|
||||||
|
if (typeof path !== 'string' || !path) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
resolvedPath = path + '/' + resolvedPath;
|
||||||
|
resolvedAbsolute = path.charAt(0) === '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
// At this point the path should be resolved to a full absolute path, but
|
||||||
|
// handle relative paths to be safe (might happen when process.cwd() fails)
|
||||||
|
|
||||||
|
// Normalize the path
|
||||||
|
resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
|
||||||
|
return !!p;
|
||||||
|
}), !resolvedAbsolute).join('/');
|
||||||
|
|
||||||
|
return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
|
||||||
|
};
|
||||||
|
|
||||||
|
// path.normalize(path)
|
||||||
|
// posix version
|
||||||
|
exports.normalize = function(path) {
|
||||||
|
var isAbsolute = path.charAt(0) === '/',
|
||||||
|
trailingSlash = path.slice(-1) === '/';
|
||||||
|
|
||||||
|
// Normalize the path
|
||||||
|
path = normalizeArray(filter(path.split('/'), function(p) {
|
||||||
|
return !!p;
|
||||||
|
}), !isAbsolute).join('/');
|
||||||
|
|
||||||
|
if (!path && !isAbsolute) {
|
||||||
|
path = '.';
|
||||||
|
}
|
||||||
|
if (path && trailingSlash) {
|
||||||
|
path += '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
return (isAbsolute ? '/' : '') + path;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// posix version
|
||||||
|
exports.join = function() {
|
||||||
|
var paths = Array.prototype.slice.call(arguments, 0);
|
||||||
|
return exports.normalize(filter(paths, function(p, index) {
|
||||||
|
return p && typeof p === 'string';
|
||||||
|
}).join('/'));
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
exports.dirname = function(path) {
|
||||||
|
var dir = splitPathRe.exec(path)[1] || '';
|
||||||
|
var isWindows = false;
|
||||||
|
if (!dir) {
|
||||||
|
// No dirname
|
||||||
|
return '.';
|
||||||
|
} else if (dir.length === 1 ||
|
||||||
|
(isWindows && dir.length <= 3 && dir.charAt(1) === ':')) {
|
||||||
|
// It is just a slash or a drive letter with a slash
|
||||||
|
return dir;
|
||||||
|
} else {
|
||||||
|
// It is a full dirname, strip trailing slash
|
||||||
|
return dir.substring(0, dir.length - 1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
exports.basename = function(path, ext) {
|
||||||
|
var f = splitPathRe.exec(path)[2] || '';
|
||||||
|
// TODO: make this comparison case-insensitive on windows?
|
||||||
|
if (ext && f.substr(-1 * ext.length) === ext) {
|
||||||
|
f = f.substr(0, f.length - ext.length);
|
||||||
|
}
|
||||||
|
return f;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
exports.extname = function(path) {
|
||||||
|
return splitPathRe.exec(path)[3] || '';
|
||||||
|
};
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
require.define("/foo.js", function (require, module, exports, __dirname, __filename) {
|
||||||
|
var bar = require('./bar');
|
||||||
|
|
||||||
|
module.exports = function (x) {
|
||||||
|
return x * bar.coeff(x) + (x * 3 - 2)
|
||||||
|
};
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
require.define("/bar.js", function (require, module, exports, __dirname, __filename) {
|
||||||
|
exports.coeff = function (x) {
|
||||||
|
return Math.log(x) / Math.log(2) + 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
require.define("/entry.js", function (require, module, exports, __dirname, __filename) {
|
||||||
|
var foo = require('./foo');
|
||||||
|
|
||||||
|
window.onload = function () {
|
||||||
|
document.getElementById('result').innerHTML = foo(100);
|
||||||
|
};
|
||||||
|
|
||||||
|
});
|
||||||
|
require("/entry.js");
|
3
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/example/simple-build/build.sh
generated
vendored
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
browserify js/entry.js -v -o browserify.js
|
9
node_modules/beefy/node_modules/live-reload/node_modules/browserify-server/node_modules/browserify/example/simple-build/index.html
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<script type="text/javascript" src="/browserify.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
foo =
|
||||||
|
<span style='font-family: monospace' id="result"></span>
|
||||||
|
</body>
|
||||||
|
</html>
|