This file contains 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
const stdin = process.stdin; | |
const stdout = process.stdout; | |
stdout.write('Enter you name -> '); | |
stdin.on('data', function (data) { | |
stdout.write('Your name is -> '); | |
var name = data.toString().trim(); | |
stdout.write(name + '\n'); | |
stdout.write('Your name to reverse -> ' + name.toString().split('').reverse().join('') + '\n'); |
This file contains 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
const stdin = process.stdin; | |
const stdout = process.stdout; | |
const waitTime = 6000; | |
var currentTime = 0; | |
var loadsec = (waitTime - 1000) / 1000; | |
stdout.write(`loading ${loadsec} seconds...\n`); | |
var tm = setInterval(function () { | |
stdout.write((currentTime += 1).toString() + '\n'); |
This file contains 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
const stdin = process.stdin; | |
const stdout = process.stdout; | |
const waitTimeout = 6000; | |
const waitInterval = 1000; | |
var currentTime = 0; | |
var percent = 0; | |
function print (percent) { | |
stdout.clearLine(); | |
stdout.cursorTo(0); |
This file contains 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
// ДЗ Ядро | |
/* | |
+++Задание 1 | |
Реализовать программу, которая принимает на вход один или более аргументов и выводит их | |
сумму в консоль(stdout) | |
*/ | |
/* | |
const stdout = process.stdout; | |
const argv = process.argv; |
This file contains 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
const fs = require('fs'); | |
function getValue(flag) { | |
const index = process.argv.indexOf(flag); | |
if (index > -1) { | |
return process.argv[index + 1]; | |
} else { | |
return null; | |
} | |
} |
This file contains 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
const fs = require('fs'); | |
function getValue(flag) { | |
const index = process.argv.indexOf(flag); | |
if (index > -1) { | |
return process.argv[index + 1]; | |
} else { | |
return null; | |
} | |
} |
This file contains 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
const fs = require('fs'); | |
const watcher = fs.watch(__dirname, function (event, filename) { | |
console.log('Event: ', event, ' ', 'filename: ', filename); | |
}); | |
watcher.on('error', function (err) { | |
console.log(err); | |
}); |
This file contains 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
//Файловая система | |
/* | |
+++Задание 1 | |
Реализовать программу, которая синхронно читает файл и выводит количество строк(\n) содержащихся в файле в консоль | |
*/ | |
/* | |
const fs = require('fs'); | |
var file = fs.readFileSync('test.txt', 'utf-8'); | |
file = file.split('\n'); |
This file contains 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
const fs = require('fs'); | |
const streamInput = fs.createReadStream('ent.mp4'); // входящий поток | |
const streamOutput = fs.createWriteStream('new.mp4'); // исходящий поток | |
streamInput.on('data', function (part) { // событие на входящем потоке | |
streamOutput.write(part); // записывает части данных в файл new.mp4 | |
}); |
This file contains 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
const EventEmiter = require('events'); // подключаем модуль | |
const myEE = new EventEmiter(); | |
myEE.on('ready', function () { // создаём событие ready | |
console.log('is ready ...'); | |
}); | |
myEE.on('start', function () { // создаём событие start | |
console.log('is start ...'); | |
}); |
OlderNewer