Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ console.log('It doesn`t matter')
console.log('How \n many \n lines \n it uses')
```

Or maybe, to show an flow process?
Or maybe, to show a flow process?
```javascript
function someAsyncFunction(){
var TAG = '[someAsyncFunction]'
Expand All @@ -106,9 +106,9 @@ You can create your own progress bar, just like "that":
```javascript
require('draftlog').into(console)

// Input progess goes from 0 to 100
// Input progress goes from 0 to 100
function ProgressBar(progress) {
// Make it 50 characters length
// Make it 50 characters long
var units = Math.round(progress / 2)
return '[' + '='.repeat(units) + ' '.repeat(50 - units) + '] ' + progress + '%'
}
Expand Down Expand Up @@ -145,7 +145,7 @@ automatically, because the stream is being "read". To stop your own code, you ca

## Discouragements

This library is awesome for development, `cli` tools and what ever you want to created, that is NOT an
This library is awesome for development, `cli` tools and whatever you want to create, that is NOT an
optimized "slave" server. Please, disable it passing `true` as a second parameter to the DraftLog initialization:

```javascript
Expand Down
24 changes: 12 additions & 12 deletions examples/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const DraftLog = require('../').into(console)
// Mock download
var downloadMock = setInterval

// Shows an instalation log for a `library` on the `step`
function InstalationProgress(library, step, finished) {
// Shows an installation log for a `library` on the `step`
function InstallationProgress(library, step, finished) {
var fillSpaces = ' '.repeat(15 - library.length)
if (finished) {
return chalk.cyan.dim(' > ') + chalk.yellow.dim(library) + fillSpaces + chalk.green('Installed')
Expand All @@ -14,14 +14,14 @@ function InstalationProgress(library, step, finished) {
}
}

// Pretent do install stuff in series
// Pretend do install stuff in series
var libs = ['async', 'lodash', 'mongodb', 'chalk', 'express', 'forever', 'socket.io', 'pm2', 'mocha']
var finished = false
var installed = 0

function startNextDownload() {
if (installed >= libs.length) {
// Finished! (logs once only)
// Finished! (logs only once)
if (!finished) {
console.log()
console.log(chalk.green('Finished Installation.'))
Expand All @@ -42,31 +42,31 @@ function startNextDownload() {
function install(lib, callback) {
var status = console.draft()

gatterDependencies()
gatherDependencies()

function gatterDependencies() {
status(InstalationProgress(lib, 'gatterDependencies'))
function gatherDependencies() {
status(InstallationProgress(lib, 'gatherDependencies'))

// Wait 300ms before next step
setTimeout(function () {downloadDepeendencies()}, 100 + Math.random() * 200)
setTimeout(function () {downloadDependencies()}, 100 + Math.random() * 200)
}

function downloadDepeendencies() {
status(InstalationProgress(lib, 'downloading dependencies'))
function downloadDependencies() {
status(InstallationProgress(lib, 'downloading dependencies'))

// Wait 300ms before next step
setTimeout(function () {compileCode()}, 150 + Math.random() * 200)
}

function compileCode() {
status(InstalationProgress(lib, 'compiling code'))
status(InstallationProgress(lib, 'compiling code'))

// Wait 300ms before next step
setTimeout(function () {finishUp()}, 50 + Math.random() * 200)
}

function finishUp() {
status(InstalationProgress(lib, 'finished', true))
status(InstallationProgress(lib, 'finished', true))
callback()
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ console.log()
var updateLoading = console.draft()

function loadingTest(){
updateLoading(Loading('Inderteminate Loading...'))
updateLoading(Loading('Indeterminate Loading...'))
}

// Keeps updating underteminate loading
// Keeps updating indeterminate loading
var interval = setInterval(loadingTest, 100)

var steps = ['Doing that', 'Then that', 'And after that', 'We will finish', 'In', '3', '2', '1']
Expand Down
2 changes: 1 addition & 1 deletion examples/progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const DraftLog = require('../').into(console)
// Mock download
var downloadMock = setInterval

// Input progess goes from 0 to 100
// Input progress goes from 0 to 100
function ProgressBar(progress) {
// Make it 50 characters length
progress = Math.min(100, progress)
Expand Down
4 changes: 2 additions & 2 deletions lib/LogDraft.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ LogDraft.prototype.update = function update(/* log arguments */) {
// It can be rewritten, move line to current cursor line, and keep updating
this.saveLine(-1)
} else {
// Invalidate and prevent writting
// Invalidate and prevent writing
this.valid = false
return;
}
Expand Down Expand Up @@ -65,7 +65,7 @@ LogDraft.prototype.update = function update(/* log arguments */) {
/*
* Returns true if line is out of screen
*/
LogDraft.prototype.isOffScreen = function isOffScren() {
LogDraft.prototype.isOffScreen = function isOffScreen() {
var rows = this._stream.rows() || defaults.maximumLinesUp
return this._stream.rows() <= this.linesUp()
}
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Lib main object is 'into' method
var Lib = require('./into')

// Expose injecter 'into' method
// Expose injector 'into' method
Lib.into = Lib

// Expose Defaults
Expand Down
6 changes: 3 additions & 3 deletions lib/into.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const LogDraft = require('./LogDraft')
const LineCountStream = require('./LineCountStream')

/*
* Injects DrafLog into a console object
* call with a seccond parameter as 'true' to
* Mock instalation, and add only the `draft` method
* Injects DraftLog into a console object
* call with a second parameter as 'true' to
* Mock installation, and add only the `draft` method
* as a alias to `console.log`
*/
module.exports = function into(console, extra) {
Expand Down