Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Leftovers

  • Loading branch information...
commit 0786cacd234debcd5b1b66aa50c83d5d09c8f087 1 parent 6ee14bc
@unconed authored
View
BIN  Illustrator/ansi-colors.psd
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
65 Node/shell/builtin/hex.js
@@ -0,0 +1,65 @@
+var view = require('view/view'),
+ reader = require('shell/reader'),
+ parseArgs = require('misc').parseArgs;
+
+exports.main = function (tokens, pipes, exit, environment) {
+ var out = new view.bridge(pipes.viewOut);
+
+ var args = parseArgs(tokens),
+ options = args.options;
+
+ // Buffered mime reader handler.
+ var handler = {
+
+ /**
+ * Pipe open, headers found.
+ */
+ begin: function (headers) {
+ // Override content-type, output rest.
+ headers.set('Content-Type', [ 'application/octet-stream', { schema: 'termkit.hex' } ]);
+ pipes.dataOut.write(headers.generate());
+ },
+
+ /**
+ * Pipe data.
+ */
+ data: function (data) {
+ // Pipe out.
+ pipes.dataOut.write(data);
+ },
+
+ /**
+ * Pipe closed.
+ */
+ end: function (exit) {
+ // Quit immediately.
+ exit();
+ },
+ };
+
+ // Reader callbacks
+ var errors = 0;
+ // Open
+ function readerOpen() {
+ return handler;
+ };
+ // Close
+ function readerClose() {
+ exit(errors == 0);
+ };
+ // Error
+ function readerError(error) {
+ errors++;
+ out.print(error);
+ };
+
+ // Spawn appropriate reader.
+ if (files.length) {
+ // Spawn files reader.
+ var pipe = new reader.filesReader(files, readerOpen, readerClose, readerError);
+ }
+ else {
+ // Spawn data reader.
+ var pipe = new reader.dataReader(pipes.dataIn, readerOpen, readerClose, readerError);
+ }
+};
Please sign in to comment.
Something went wrong with that request. Please try again.