Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
window-size
Advanced tools
Reliable way to get the height and width of terminal/console, since it's not calculated or updated the same way on all platforms, environments and node.js versions.
Reliable way to get the height and width of terminal/console, since it's not calculated or updated the same way on all platforms, environments and node.js versions.
Install with npm:
$ npm install --save window-size
var size = require('window-size');
$ window-size
# height: 40
# width : 145
The main export is either an object with width
and height
properties, or undefined
if unable to get width and height.
var size = require('window-size');
console.log(size);
//=> {width: 80, height: 25}
Calls the main function to get the up-to-date window size.
console.log(size.get());
//=> {width: 80, height: 25}
Example
See example.js for the code used in the below gif.
process.stdout.on('resize', function() {
console.log(size.get());
});
HEADS UP!
Note that some platforms only provide the initial terminal size, not the actual size after it has been resized by the user.
Get process.env.COLUMNS
and process.env.ROWS
, if defined. Called by the main function if for some reason size was not available from process.stdout
and process.stderr
.
console.log(size.env());
Attempts to get the size from tty
. Called by the main function if for some reason size was not available from process.stdout
, process.stderr
or process.env
.
console.log(size.tty());
Get the terminal size in Windows 10+.
console.log(size.win());
Note that this method calls execSync to get the size, and must be called directly, as it is not called by the main function.
Get the terminal size by calling the unix $ tput
command.
console.log(size.tput());
Note that this method calls execSync to get the size, and must be called directly, as it is not called by the main function.
In some environments the main export may not be able to find a window size using the default methods. In this case, size
will be undefined
and the functions will not be exported.
Because of this, the functions have been exported in a separate file and can be required directly.
var utils = require('window-size/utils');
console.log(utils.win());
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Commits | Contributor |
---|---|
23 | jonschlinkert |
11 | doowb |
4 | bcoe |
3 | icyflame |
2 | derhuerst |
1 | karliky |
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
Jon Schlinkert
Copyright © 2018, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.7.0, on July 27, 2018.
FAQs
Reliable way to get the height and width of terminal/console, since it's not calculated or updated the same way on all platforms, environments and node.js versions.
The npm package window-size receives a total of 3,482,660 weekly downloads. As such, window-size popularity was classified as popular.
We found that window-size demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.