Pure Programmer
Blue Matrix


Cluster Map

Stream I/O

L1

This page is under construction. Please come back later.

StreamIO1.js
#!/usr/bin/env node;
/******************************************************************************
 * This program simply copies an input stream to the console character by
 * character like the Unix 'cat' program.
 * 
 * Copyright © 2020 Richard Lesh.  All rights reserved.
 *****************************************************************************/

const Utils = require('./Utils');

const main = async () => {
	let c;
	while ((c = await Utils.getchar(process.stdin)) !== undefined) {
		process.stdout.write(String.fromCodePoint(c));
	}
}
main().catch( e => { console.error(e) } );
Output
$ node StreamIO1.js < ../../data/text/GettysburgAddress.txt Lincoln's Gettysburg Address, given November 19, 1863 on the battlefield near Gettysburg, Pennsylvania, USA Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this. But, in a larger sense, we can not dedicate-we can not consecrate-we can not hallow-this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us-that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion-that we here highly resolve that these dead shall not have died in vain-that this nation, under God, shall have a new birth of freedom-and that government of the people, by the people, for the people, shall not perish from the earth. $ node StreamIO1.js < ../../data/text/UnicodeTest.utf8 Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. Vor vier Punkten und sieben Jahren haben unsere Väter auf diesem Kontinent eine neue Nation hervorgebracht, die in Freiheit empfangen wurde und sich dem Vorschlag verschrieben hat, dass alle Menschen gleich geschaffen sind. Τέσσερα σκορ και πριν από επτά χρόνια οι πατέρες μας έφεραν σε αυτή την ήπειρο, ένα νέο έθνος, που σχεδιάστηκε στην Ελευθερία και αφιερώθηκε στην πρόταση ότι όλοι οι άνθρωποι δημιουργούνται ίσοι. أربع نقاط وقبل سبع سنوات قدم آباؤنا في هذه القارة ، أمة جديدة ، تم تصورها في الحرية ، ومكرسة لفرضية أن جميع الرجال خلقوا متساوين. ארבע ציונים ולפני שבע שנים אבותינו הציגו ביבשת זו, אומה חדשה, שהגתה בחירות, והוקדשה לטענה שכל הגברים נוצרים שווים. 4スコアと7年前、私たちの父親は、この大陸で生まれた新しい国であり、リバティで考案され、すべての人が平等に創造されるという命題に献身しました。 4 점 7 년 전, 우리 조상들은 리버티에서 잉태 된 새로운 국가 인이 대륙에서 모든 사람들이 평등하게 창조되었다고 제안했습니다. 四年前七年前,我们的祖先在这个大陆上建立了一个新国家,这个国家是在自由中孕育的,致力于实现人人平等的主张。 Unicode 11 Emoji 🥰 Smiling Face with Hearts 🥵 Hot Face 🥶 Cold Face 🥴 Woozy Face 🥳 Partying Face Unicode 10 Emoji 🤪 Zany Face 🤯 Exploding Head 🧐 Face with Monocle 🤬 Face with Symbols on Mouth 🦖 T-Rex Unicode 9 Emoji 🤣 Rolling on the Floor Laughing 🤢 Nauseated Face 🤡 Clown Face 🦊 Fox 🦈 Shark Unicode 8 Emoji 🤑 Money-Mouth Face 🤓 Nerd Face 🦁 Lion 🦄 Unicorn 🦀 Crab Unicode 7 Emoji 🖖 Vulcan Salute 🐿 Chipmunk 🕷 Spider 🌶 Hot Pepper 🌪 Tornado Precomposed vs. Decomposed Å = Å à = à é = é î = î ñ = ñ ü = ü 한 = 한 Graphemes that take two codepoints Canada 🇨🇦 China 🇨🇳 France 🇫🇷 Greece 🇬🇷 Israel 🇮🇱 Japan 🇯🇵 Mexico 🇲🇽 UK 🇬🇧 US 🇺🇸
StreamIO2.js
#!/usr/bin/env node;
/******************************************************************************
 * This program simply copies an input stream to the console line by line.
 * 
 * Copyright © 2020 Richard Lesh.  All rights reserved.
 *****************************************************************************/

const Utils = require('./Utils');

const main = async () => {
	let line;
	while ((line = await Utils.getline(process.stdin)) !== undefined) {
		console.log(line);
	}
}
main().catch( e => { console.error(e) } );
Output
$ node StreamIO2.js < ../../data/text/GettysburgAddress.txt Lincoln's Gettysburg Address, given November 19, 1863 on the battlefield near Gettysburg, Pennsylvania, USA Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this. But, in a larger sense, we can not dedicate-we can not consecrate-we can not hallow-this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us-that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion-that we here highly resolve that these dead shall not have died in vain-that this nation, under God, shall have a new birth of freedom-and that government of the people, by the people, for the people, shall not perish from the earth. $ node StreamIO2.js < ../../data/text/UnicodeTest.utf8 Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. Vor vier Punkten und sieben Jahren haben unsere Väter auf diesem Kontinent eine neue Nation hervorgebracht, die in Freiheit empfangen wurde und sich dem Vorschlag verschrieben hat, dass alle Menschen gleich geschaffen sind. Τέσσερα σκορ και πριν από επτά χρόνια οι πατέρες μας έφεραν σε αυτή την ήπειρο, ένα νέο έθνος, που σχεδιάστηκε στην Ελευθερία και αφιερώθηκε στην πρόταση ότι όλοι οι άνθρωποι δημιουργούνται ίσοι. أربع نقاط وقبل سبع سنوات قدم آباؤنا في هذه القارة ، أمة جديدة ، تم تصورها في الحرية ، ومكرسة لفرضية أن جميع الرجال خلقوا متساوين. ארבע ציונים ולפני שבע שנים אבותינו הציגו ביבשת זו, אומה חדשה, שהגתה בחירות, והוקדשה לטענה שכל הגברים נוצרים שווים. 4スコアと7年前、私たちの父親は、この大陸で生まれた新しい国であり、リバティで考案され、すべての人が平等に創造されるという命題に献身しました。 4 점 7 년 전, 우리 조상들은 리버티에서 잉태 된 새로운 국가 인이 대륙에서 모든 사람들이 평등하게 창조되었다고 제안했습니다. 四年前七年前,我们的祖先在这个大陆上建立了一个新国家,这个国家是在自由中孕育的,致力于实现人人平等的主张。 Unicode 11 Emoji 🥰 Smiling Face with Hearts 🥵 Hot Face 🥶 Cold Face 🥴 Woozy Face 🥳 Partying Face Unicode 10 Emoji 🤪 Zany Face 🤯 Exploding Head 🧐 Face with Monocle 🤬 Face with Symbols on Mouth 🦖 T-Rex Unicode 9 Emoji 🤣 Rolling on the Floor Laughing 🤢 Nauseated Face 🤡 Clown Face 🦊 Fox 🦈 Shark Unicode 8 Emoji 🤑 Money-Mouth Face 🤓 Nerd Face 🦁 Lion 🦄 Unicorn 🦀 Crab Unicode 7 Emoji 🖖 Vulcan Salute 🐿 Chipmunk 🕷 Spider 🌶 Hot Pepper 🌪 Tornado Precomposed vs. Decomposed Å = Å à = à é = é î = î ñ = ñ ü = ü 한 = 한 Graphemes that take two codepoints Canada 🇨🇦 China 🇨🇳 France 🇫🇷 Greece 🇬🇷 Israel 🇮🇱 Japan 🇯🇵 Mexico 🇲🇽 UK 🇬🇧 US 🇺🇸
StreamIO3.js
#!/usr/bin/env node;
/******************************************************************************
 * This program reads bytes from STDIN and prints them in decimal format.
 * 
 * Copyright © 2020 Richard Lesh.  All rights reserved.
 *****************************************************************************/

const Utils = require('./Utils');

const main = async () => {
	let c;
	let count = 0;
	while ((c = await Utils.getbyte(process.stdin)) != -1) {
		process.stdout.write(c + " ");
		++count;
		if (count % 20 === 0) {
			console.log();
		}
	}
	if (count % 20 !== 0) {
		console.log();
	}
}
main().catch( e => { console.error(e) } );
Output
$ node StreamIO3.js < ../../data/text/GettysburgAddress.txt 76 105 110 99 111 108 110 39 115 32 71 101 116 116 121 115 98 117 114 103 32 65 100 100 114 101 115 115 44 32 103 105 118 101 110 32 78 111 118 101 109 98 101 114 32 49 57 44 32 49 56 54 51 10 111 110 32 116 104 101 32 98 97 116 116 108 101 102 105 101 108 100 32 110 101 97 114 32 71 101 116 116 121 115 98 117 114 103 44 32 80 101 110 110 115 121 108 118 97 110 105 97 44 32 85 83 65 10 10 70 111 117 114 32 115 99 111 114 101 32 97 110 100 32 115 101 118 101 110 32 121 101 97 114 115 32 97 103 111 32 111 117 114 32 102 97 116 104 101 114 115 32 98 114 111 117 103 104 116 32 102 111 114 116 104 32 111 110 32 116 104 105 115 32 99 111 110 116 105 110 101 110 116 44 32 97 32 110 101 119 32 110 97 116 105 111 110 44 32 99 ... 110 111 116 32 104 97 118 101 32 100 105 101 100 32 105 110 32 118 97 105 110 45 116 104 97 116 32 116 104 105 115 32 110 97 116 105 111 110 44 32 117 110 100 101 114 32 71 111 100 44 32 115 104 97 108 108 32 104 97 118 101 32 97 32 110 101 119 32 98 105 114 116 104 32 111 102 32 102 114 101 101 100 111 109 45 97 110 100 32 116 104 97 116 32 103 111 118 101 114 110 109 101 110 116 32 111 102 32 116 104 101 32 112 101 111 112 108 101 44 32 98 121 32 116 104 101 32 112 101 111 112 108 101 44 32 102 111 114 32 116 104 101 32 112 101 111 112 108 101 44 32 115 104 97 108 108 32 110 111 116 32 112 101 114 105 115 104 32 102 114 111 109 32 116 104 101 32 101 97 114 116 104 46 10 $ node StreamIO3.js < ../../data/text/UnicodeTest.utf8 70 111 117 114 32 115 99 111 114 101 32 97 110 100 32 115 101 118 101 110 32 121 101 97 114 115 32 97 103 111 32 111 117 114 32 102 97 116 104 101 114 115 32 98 114 111 117 103 104 116 32 102 111 114 116 104 32 111 110 32 116 104 105 115 32 99 111 110 116 105 110 101 110 116 44 32 97 32 110 101 119 32 110 97 116 105 111 110 44 32 99 111 110 99 101 105 118 101 100 32 105 110 32 76 105 98 101 114 116 121 44 32 97 110 100 32 100 101 100 105 99 97 116 101 100 32 116 111 32 116 104 101 32 112 114 111 112 111 115 105 116 105 111 110 32 116 104 97 116 32 97 108 108 32 109 101 110 32 97 114 101 32 99 114 101 97 116 101 100 32 101 113 117 97 108 46 10 10 86 111 114 32 118 105 101 114 32 80 117 110 107 116 101 110 32 117 110 100 32 115 ... 188 32 61 32 117 204 136 10 237 149 156 32 61 32 225 132 146 225 133 161 225 134 171 10 10 71 114 97 112 104 101 109 101 115 32 116 104 97 116 32 116 97 107 101 32 116 119 111 32 99 111 100 101 112 111 105 110 116 115 10 67 97 110 97 100 97 32 240 159 135 168 240 159 135 166 10 67 104 105 110 97 32 240 159 135 168 240 159 135 179 10 70 114 97 110 99 101 32 240 159 135 171 240 159 135 183 10 71 114 101 101 99 101 32 240 159 135 172 240 159 135 183 10 73 115 114 97 101 108 32 240 159 135 174 240 159 135 177 10 74 97 112 97 110 32 240 159 135 175 240 159 135 181 10 77 101 120 105 99 111 32 240 159 135 178 240 159 135 189 10 85 75 32 240 159 135 172 240 159 135 167 10 85 83 32 240 159 135 186 240 159 135 184 32 10
javascript

Questions

Projects

More ★'s indicate higher difficulty level.

References