Permalink
Browse files

done

  • Loading branch information...
1 parent 081c458 commit 807351b9c8c0c03910b774e911f3afc83d9f06ff @mvrilo committed Nov 4, 2010
Showing with 5,368 additions and 0 deletions.
  1. +22 −0 deps/mime/README.md
  2. +1 −0 deps/mime/index.js
  3. +64 −0 deps/mime/mime.js
  4. +1,351 −0 deps/mime/mime.types
  5. +11 −0 deps/mime/package.json
  6. +68 −0 deps/mime/test.js
  7. +614 −0 deps/uglifyjs/README.html
  8. +299 −0 deps/uglifyjs/README.org
  9. +178 −0 deps/uglifyjs/bin/uglifyjs
  10. +75 −0 deps/uglifyjs/docstyle.css
  11. +1,220 −0 deps/uglifyjs/lib/parse-js.js
  12. +1,299 −0 deps/uglifyjs/lib/process.js
  13. +6 −0 deps/uglifyjs/package.json
  14. +28 −0 deps/uglifyjs/test/beautify.js
  15. +1 −0 deps/uglifyjs/test/unit/compress/expected/const.js
  16. +1 −0 deps/uglifyjs/test/unit/compress/expected/if.js
  17. +1 −0 deps/uglifyjs/test/unit/compress/expected/ifreturn.js
  18. +1 −0 deps/uglifyjs/test/unit/compress/expected/issue10.js
  19. +1 −0 deps/uglifyjs/test/unit/compress/expected/issue11.js
  20. +1 −0 deps/uglifyjs/test/unit/compress/expected/issue13.js
  21. +1 −0 deps/uglifyjs/test/unit/compress/expected/issue14.js
  22. +1 −0 deps/uglifyjs/test/unit/compress/expected/issue16.js
  23. +1 −0 deps/uglifyjs/test/unit/compress/expected/issue17.js
  24. +1 −0 deps/uglifyjs/test/unit/compress/expected/issue20.js
  25. +1 −0 deps/uglifyjs/test/unit/compress/expected/issue21.js
  26. +1 −0 deps/uglifyjs/test/unit/compress/expected/issue25.js
  27. +1 −0 deps/uglifyjs/test/unit/compress/expected/issue27.js
  28. +1 −0 deps/uglifyjs/test/unit/compress/expected/issue28.js
  29. +1 −0 deps/uglifyjs/test/unit/compress/expected/issue29.js
  30. +1 −0 deps/uglifyjs/test/unit/compress/expected/issue30.js
  31. +1 −0 deps/uglifyjs/test/unit/compress/expected/issue34.js
  32. +1 −0 deps/uglifyjs/test/unit/compress/expected/issue4.js
  33. +1 −0 deps/uglifyjs/test/unit/compress/expected/issue9.js
  34. +1 −0 deps/uglifyjs/test/unit/compress/expected/var.js
  35. +5 −0 deps/uglifyjs/test/unit/compress/test/const.js
  36. +6 −0 deps/uglifyjs/test/unit/compress/test/if.js
  37. +9 −0 deps/uglifyjs/test/unit/compress/test/ifreturn.js
  38. +1 −0 deps/uglifyjs/test/unit/compress/test/issue10.js
  39. +3 −0 deps/uglifyjs/test/unit/compress/test/issue11.js
  40. +1 −0 deps/uglifyjs/test/unit/compress/test/issue13.js
  41. +1 −0 deps/uglifyjs/test/unit/compress/test/issue14.js
  42. +1 −0 deps/uglifyjs/test/unit/compress/test/issue16.js
  43. +4 −0 deps/uglifyjs/test/unit/compress/test/issue17.js
  44. +1 −0 deps/uglifyjs/test/unit/compress/test/issue20.js
  45. +6 −0 deps/uglifyjs/test/unit/compress/test/issue21.js
  46. +7 −0 deps/uglifyjs/test/unit/compress/test/issue25.js
  47. +1 −0 deps/uglifyjs/test/unit/compress/test/issue27.js
  48. +3 −0 deps/uglifyjs/test/unit/compress/test/issue28.js
  49. +1 −0 deps/uglifyjs/test/unit/compress/test/issue29.js
  50. +3 −0 deps/uglifyjs/test/unit/compress/test/issue30.js
  51. +3 −0 deps/uglifyjs/test/unit/compress/test/issue34.js
  52. +3 −0 deps/uglifyjs/test/unit/compress/test/issue4.js
  53. +4 −0 deps/uglifyjs/test/unit/compress/test/issue9.js
  54. +3 −0 deps/uglifyjs/test/unit/compress/test/var.js
  55. +44 −0 deps/uglifyjs/test/unit/scripts.js
  56. +2 −0 deps/uglifyjs/uglify-js.js
View
@@ -0,0 +1,22 @@
+A library for doing simple mime-type lookups.
+
+ var mime = require('mime');
+
+ mime.lookup('/path/to/file.txt'); // => 'text/plain'
+ mime.lookup('file.txt'); // => 'text/plain'
+ mime.lookup('.txt'); // => 'text/plain'
+ mime.lookup('htm'); // => 'text/html'
+
+... and extension lookups by mime-type
+
+ mime.extension('text/html'); // => 'html'
+ mime.extension('application/octet-stream'); // => 'bin'
+
+It also includes rudimentary logic for determining charsets. (Useful in a web
+framework):
+
+ mime.charset.lookup('text/plain'); // => 'UTF-8'
+
+Install with [npm](http://github.com/isaacs/npm):
+
+ npm install mime
View
@@ -0,0 +1 @@
+module.exports = require('./mime');
View
@@ -0,0 +1,64 @@
+var sys = require('sys');
+var path = require('path');
+var fs = require('fs');
+
+/**
+ * Load mimetype map from an Apache2 mime.types file. For the
+ * canonical Apache file:
+ * http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
+ */
+function _init(mimeFile) {
+ var types = exports.types = {};
+ var extensions = exports.extensions = {};
+
+ if (!mimeFile) mimeFile = path.join(__dirname, 'mime.types');
+
+ var content = fs.readFileSync(mimeFile, 'binary');
+ var lines = content.split(/[\r\n]+/), line;
+ // Each line
+ while (line = lines.shift()) {
+ line = line.replace(/#.*/); // Remove comments
+ if (line) {
+ line = line.split(/\s+/); // Split into fields
+ var mimeType = line.shift(), ext; // field 0 = type
+ // All remaining fields are extensions
+ while (mimeType && (ext = line.shift())) {
+ if (types[ext]) {
+ throw Error('Extension "' + ext + '" maps to multiple types');
+ }
+ types[ext] = mimeType;
+ // For extension map, we use the first extension listed
+ if (!extensions[mimeType]) {
+ extensions[mimeType] = ext;
+ }
+ }
+ }
+ }
+}
+_init();
+
+/**
+ * Lookup a mime type based on extension
+ */
+exports.lookup = function(path, fallback) {
+ var ext = path.replace(/.*[\.\/]/, '').toLowerCase();
+ return exports.types[ext] || fallback || exports.default_type;
+};
+
+/**
+ * Return file extension associated with a mime type
+ */
+exports.extension = function(mimeType) {
+ return exports.extensions[mimeType];
+};
+
+exports.default_type = exports.types.bin; // bin = application/octet-stream
+
+var charsets = exports.charsets = {
+ lookup: function(mimeType, fallback) {
+ // RWK: With mime.types being a) large and b) dynamic, is it reasonable to
+ // assume that all "text/*" types should be UTF-8 rather than trying to map
+ // them individually?
+ return /^text\//.test(mimeType) ? 'UTF-8' : fallback;
+ }
+};
Oops, something went wrong.

0 comments on commit 807351b

Please sign in to comment.