Skip to content

Instantly share code, notes, and snippets.

@st98
Last active August 29, 2015 14:14
Show Gist options
  • Save st98/bea51e125dc381e574b7 to your computer and use it in GitHub Desktop.
Save st98/bea51e125dc381e574b7 to your computer and use it in GitHub Desktop.
process.stdin, test
function f(s) {
return s.split('').map(function (a) {
return ('00' + a.charCodeAt(0).toString(16)).slice(-2);
}).join(' ');
}
process.stdin.setEncoding('utf8');
process.stdin.on('readable', function () {
var a = process.stdin.read();
if (a !== null) {
console.log('> ', a.replace(/\n/, ''));
console.log('| ', f(a));
}
});
function f(s) {
return s.split('').map(function (a) {
return ('00' + a.charCodeAt(0).toString(16)).slice(-2);
}).join(' ');
}
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (a) {
if (a !== null) {
console.log('> ', a.replace(/\n/, ''));
console.log('| ', f(a));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment