Gathering detailed insights and metrics for draftlog
Gathering detailed insights and metrics for draftlog
Gathering detailed insights and metrics for draftlog
Gathering detailed insights and metrics for draftlog
npm install draftlog
Typescript
Module System
Node Version
NPM Version
89.3
Supply Chain
100
Quality
75.8
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
5,178,489
Last Day
2,059
Last Week
9,749
Last Month
49,962
Last Year
689,953
1,250 Stars
43 Commits
33 Forks
24 Watching
1 Branches
4 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.13
Package Id
draftlog@1.0.13
Size
6.48 kB
NPM Version
6.14.4
Node Version
14.2.0
Publised On
26 Mar 2021
Cumulative downloads
Total Downloads
Last day
-18.7%
2,059
Compared to previous day
Last week
-28.5%
9,749
Compared to previous week
Last month
-0.9%
49,962
Compared to previous month
Last year
-0.6%
689,953
Compared to previous year
1
Because Logging can be pretty and fun
$ npm install draftlog
It allows you to re-write a line of your log after being written. Just like post 'updating'.
This is the building block for any dynamic element such as progress bars
, loading status
,
animations
, checkboxes
and so on.
It does that by keeping track of the current lines of code written through the stream
, and
moving the cursor up to the line of the LogDraft
you created previously, and updating its content.
Look in the examples folders to see how easy it is, to create anything. No strict and fixed widgets are given to you. Instead, use your creativity with this tool to create anything you want! Share the results later with an example ;)
Looking for CUTE Unicode chars? Check out Unicute.
How the HECK is that even possible?
1// Setup 2const DraftLog = require('draftlog') 3DraftLog(console) 4 5// Or, in a single line: 6require('draftlog').into(console) 7 8// Account for manual line breaks with: 9require('draftlog').into(console).addLineListener(process.stdin)
To create a updatable log, use the draft
method injected into the provided console
:
1// Create a Draft log 2var update = console.draft('Hi, my name is') 3 4// You can call logs after it 5console.log('Something else') 6 7// Use the received callback to update it as many times as you want 8update('Hi, my name is Ivan!')
Here are some interesting examples:
1// Prints a clock incrementing one every second in the same line 2var draft = console.draft() 3var elapsed = 1 4setInterval( () => { 5 draft('Elapsed', elapsed++, 'seconds') 6}, 1000) 7 8console.log('It doesn`t matter') 9console.log('How \n many \n lines \n it uses')
Or maybe, to show an flow process?
1function someAsyncFunction(){ 2 var TAG = '[someAsyncFunction]' 3 var log = console.draft(TAG, 'init') 4 5 function a() { 6 setTimeout(() => { 7 log(TAG, 'calling b') 8 b() 9 }, 500) 10 } 11 12 function b() { 13 setTimeout(() => { 14 log(TAG, 'finished') 15 }) 16 } 17}
You can create your own progress bar, just like "that":
1require('draftlog').into(console) 2 3// Input progess goes from 0 to 100 4function ProgressBar(progress) { 5 // Make it 50 characters length 6 var units = Math.round(progress / 2) 7 return '[' + '='.repeat(units) + ' '.repeat(50 - units) + '] ' + progress + '%' 8} 9 10var barLine = console.draft('Starting download...') 11downloadFile(function (progress) { 12 barLine(ProgressBar(progress)) 13}) 14 15// Will show something like: (being updated in realtime) 16// [============================ ] 56%
We have a few of them ready for you to use! Take a look at the examples folder.
Remember to replace require('../')
with require('draftlog')
.
Also, install chalk
to get colors on your terminal ;)
Because of the way Terminals are built, it is not possible to update a text outside the viewing area of the terminal.
That said, DraftLogs are setup to automagically be rewritten on a new line if they reach the end of the viewport.
Note that, you can disable that behavior, by setting DraftLog.defaults.canReWrite = false
Also, if the NodeJS environment cannot detect the number of rows of your terminal automatically, it will use
the default height on DraftLog.defaults.maximumLinesUp
. Modify that if needed.
When using into(console).addLineListener(process.stdin)
, your code will no longer exit
automatically, because the stream is being "read". To stop your own code, you can call
process.exit(0)
or pause the stream when you want with: process.stdin.pause()
.
This library is awesome for development, cli
tools and what ever you want to created, that is NOT an
optimized "slave" server. Please, disable it passing true
as a second parameter to the DraftLog initialization:
1// Disable Initialization (true = production; false = development) 2DraftLog(console, true) 3// Or, with one line require-init: 4require('draftlog').into(console, true)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 3/27 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More@niceties/draftlog-appender
Appender for '@niceites/logger' implemented using draftlog package.
draftlog-session
Session aware logs like Yarn with timings and steps
@elfo/draftlog
Create updatable log lines into the terminal, and give life to your logs! [with typescript issue fix]
reins_progress_bar
This is a module for easily managing progress bars only. It is recommended to use this in combination with [node-draftlog](https://github.com/ivanseidel/node-draftlog).