This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * three urls are given, data must be supplied back in the order of the urls via SDOUT | |
| */ | |
| var http = require('http'); | |
| var data1 = ''; | |
| var data2 = ''; | |
| var data3 = ''; | |
| var collect = function(url,callback){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Example given (changed it toUppperCase rather than reverse) | |
| var map = require('through2-map') | |
| inStream.pipe(map(function (chunk) { | |
| return chunk.toString().split('').toUpperCase().join('') | |
| })).pipe(outStream) | |
| //attempt | |
| var stream = require('stream') | |
| var upper = new stream.Transform(); | |
| upper._transform = function (chunk, encoding, done){ | |
| var data = chunk.toString().split().toUpperCase().join(''); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //issue, socket hangs | |
| var stream = require('stream') | |
| var http = require('http'); | |
| var upper = new stream.Transform(); | |
| upper._transform = function (chunk, encoding, done){ | |
| var data = chunk.toString().split().toUpperCase().join(''); | |
| data.forEach(this.push.bind(this)); | |
| done(); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var http = require('http'); | |
| var map = require('through2-map'); | |
| var server = http.createServer(function(req,res){ | |
| if (req.method == 'POST') { | |
| req.pipe(map(function (chunk) { | |
| return chunk.toString().toUpperCase() | |
| })).pipe(res); | |
| req.on('end', function() { | |
| res.end(); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| textBuf = new Buffer('bytewiser'); | |
| textBuf.pipe(process.stdout); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var buffer = new Buffer([]) | |
| for (var i = 2;i <= process.argv.length - 1; i++) { | |
| buffer[i] = process.argv[i]; | |
| console.error(buffer[i]); | |
| }; | |
| for (var i = 2;i <= buffer.length - 1; i++) { | |
| process.stdout.write(buffer[i].toString('hex')); | |
| }; | |
| process.stdout.write('\n'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var http = require('http'); | |
| var map = require('through2-map'); | |
| var server = http.createServer(function(req,res){ | |
| if (req.method == 'POST') { | |
| req.pipe(map(function (chunk) { | |
| return chunk.toString().toUpperCase() | |
| })).pipe(res); | |
| req.on('end', function() { | |
| res.end(); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var http = require('http'); | |
| var url = require('url'); | |
| var server = http.createServer(function (request,response){ | |
| if (request.method == 'GET'){ | |
| reqObj = url.parse(request.url,true); | |
| var dateString = reqObj.query.iso; | |
| console.error(reqObj.query); | |
| var date = new Date(dateString) | |
| console.error(date); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*Given an unknown number of bytes passed via process.argv, | |
| //create a buffer from them and output a hexadecimal encoded representation of the buffer. | |
| // | |
| //Your answer should be a string of two-character pairs (also known as hexadecimal octets), | |
| //where each pair represents a single number in the array of bytes converted to hexadecimal | |
| */ | |
| var leftpad = function(str){ | |
| if (str.length == 1){ | |
| str = '0'+str; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Write a program that takes the first buffer written to process.stdin, | |
| updates all instances of . with ! and then logs out the updated buffer object. | |
| Bonus points if you never call .toString() on your buffer! | |
| */ | |
| //var buffer = Buffer.from(process.stdin); | |
| var input = '' | |
| process.stdin.on('data', function(d) { | |
| /* |