Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
github.com/louislef299/scroll
ANSI Scroll Buffer Stages is a simple package meant to emulate the stages in a cli tool where overall output isn't important unless there is a failure. It consists of a simple buffer abstraction that utilizes ANSI escape codes in the background. This can help when there is a large amount of output to the terminal in stages, but the overall result may be important to communicate to the user.
go get github.com/louislef299/scroll
Simple write to the Buffer:
scroll.Printf("hello world")
Erase the existing Buffer:
// Prints hello world 5x
for i := 0; i < 5; i++ {
scroll.Printf("hello world")
}
scroll.EraseBuffer()
Run print statements in stages:
// Stage 1
for i := 0; i < 5; i++ {
scroll.Printf("%d: hello from stage 1", i + 1)
}
// end stage
scroll.NewStage("stage 1 complete!")
// Stage 2
for i := 0; i < 5; i++ {
scroll.Printf("%d: hello from stage 2", i + 1)
}
// end stage
scroll.NewStage("stage 2 complete!")
Create a custom Buffer:
// Creates a new buffer with a size of 5
buff := scroll.New(context.TODO(), os.Stdout, 5)
// Prints hello world 5x
for i := 0; i < 5; i++ {
buff.Printf("hello world")
}
time.Sleep(time.Second)
buff.NewStage("finish buffer example!")
The ANSI Buffer also implements io.Writer:
log.SetOutput(scroll.New(context.TODO(), 5))
log.Println("written from test")
The writer is unreliable under stress however, as the channels that are created for synchronization are not reliably transferred to packages like log and fmt.
The tests are currently visual tests and require a human to watch the output and verify functionality. Not ideal, but that's how it is for now. Feel free to fix it!
The scroll package takes some inspiration for the log standard package and Fatih Arslan's color package.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.