How to use the window-size.get function in window-size

To help you get started, we’ve selected a few window-size examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sparkswap / broker / broker-cli / commands / orderbook.js View on Github external
function createUI (market, asks, bids) {
  console.clear()
  const baseCurrencySymbol = market.split('/')[0].toUpperCase()
  const windowWidth = size.get().width
  const { mainTableWidth, innerTableWidth } = calculateTableWidths(windowWidth)
  const table = new Table({
    head: ['ASKS', 'BIDS'],
    style: { head: ['gray'] },
    colWidths: [mainTableWidth, mainTableWidth]
  })

  // The extensive options are required because the default for cli-table is to have
  // borders between every row and column.
  const innerTableOptions = {
    head: ['Price', `Depth (${baseCurrencySymbol})`],
    style: { head: ['gray'] },
    colWidths: [innerTableWidth, innerTableWidth],
    chars: {
      'top': '',
      'top-mid': '',
github sparkswap / broker-cli / commands / orderbook.js View on Github external
function createUI (market, asks, bids) {
  console.clear()
  const windowHeight = size.get().height

  // Fill as many orders as the screen allows less other info displayed
  const maxLengthPerSide = Math.floor((windowHeight - NON_MARKET_INFO) / 2)
  const baseCurrencySymbol = market.split('/')[0].toUpperCase()

  const parentTable = new Table({
    head: [],
    chars: {
      'top-mid': '',
      'bottom-mid': '',
      'left-mid': '',
      'mid': '',
      'mid-mid': '',
      'right-mid': '',
      'middle': ''
    },
github sparkswap / broker / broker-cli / commands / orderbook.js View on Github external
function createUI (market, asks, bids) {
  const baseCurrencySymbol = market.split('/')[0].toUpperCase()
  const windowWidth = size.get().width
  const { mainTableWidth, innerTableWidth } = calculateTableWidths(windowWidth)
  const table = new Table({
    head: ['ASKS', 'BIDS'],
    style: { head: ['gray'] },
    colWidths: [mainTableWidth, mainTableWidth]
  })

  // The extensive options are required because the default for cli-table is to have
  // borders between every row and column.
  const innerTableOptions = {
    head: ['Price', `Depth (${baseCurrencySymbol})`],
    style: { head: ['gray'] },
    colWidths: [innerTableWidth, innerTableWidth],
    chars: {
      'top': '',
      'top-mid': '',
github release-it / release-it / lib / metrics.js View on Github external
const got = require('got');
const supportsColor = require('supports-color');
const windowSize = require('window-size');
const uuid = require('uuid');
const osName = require('os-name');
const isCi = require('is-ci');
const _ = require('lodash');
const debug = require('debug')('release-it:metrics');
const pkg = require('../package.json');

const noop = Promise.resolve();

const cast = value => (value ? 1 : 0);

const cid = uuid.v4();
const dimensions = windowSize ? windowSize.get() : { width: 0, height: 0 };
const vp = `${dimensions.width}x${dimensions.height}`;
const depths = ['1-bit', '4-bit', '8-bit', '24-bits'];
const sd = depths[supportsColor.level || 0];

const payload = config => ({
  v: 1,
  tid: 'UA-108828841-1',
  cid,
  vp,
  sd,
  cd1: pkg.version,
  cd2: process.version,
  cd3: osName(),
  cd4: cast(!config.isCI),
  cd5: cast(config.isDryRun),
  cd6: cast(config.isVerbose),
github sparkswap / broker-cli / commands / order / summary.js View on Github external
function createUI (market, orders) {
  const windowWidth = size.get().width
  const unitWidth = Math.floor(windowWidth / 16)

  const orderTable = new Table({
    head: ['Order ID', 'Status', 'Side', 'Amount', 'Limit Price', 'Time', 'Created At'],
    colWidths: [2 * unitWidth, unitWidth, unitWidth, 3 * unitWidth, 3 * unitWidth, unitWidth, 3 * unitWidth],
    style: { head: ['gray'] }
  })

  const ui = []

  ui.push('')
  ui.push(String(`Orders: ${market.toUpperCase()}`).bold.white)
  ui.push('')

  orders.forEach((order) => {
    const price = order.isMarketOrder ? 'MARKET' : order.limitPrice
github embark-framework / embark / cmd / dashboard / dashboard.js View on Github external
checkWindowSize() {
    let size = windowSize.get();
    if (size.height < 40 || size.width < 118) {
      this.logger.warn(__("tip: you can resize the terminal or disable the dashboard with") + " embark run --nodashboard".bold.underline);
    }
  }
github embark-framework / embark / packages / embark / src / lib / utils / utils.js View on Github external
function getWindowSize() {
  const windowSize = require('window-size');
  if (windowSize) {
    return windowSize.get();
  }

  return {width: 240, height: 75};
}
github fabiospampinato / bump / src / utils / script.ts View on Github external
async run ( name: string ) {

    if ( !Config.scripts.enabled ) return;

    const script = Config.scripts[name];

    if ( !script ) return;

    const size = _.get ( windowSize.get (), 'width', 40 );

    try {

      Utils.log ( chalk.yellow ( `┌─ script:${name} ${'─'.repeat ( size - 12 - name.length )}┐` ) );

      await execa.shell ( `${script} && exit 0`, { stdout: 'inherit', stderr: 'inherit' } );

      Utils.log ( chalk.yellow ( `└${'─'.repeat ( size - 2 )}┘` ) );

    } catch ( e ) {

      Utils.log ( e );

      Utils.exit ( `[script] An error occurred while executing the "${chalk.bold ( name )}" script` );

    }
github sparkswap / broker / broker-cli / commands / order / summary.js View on Github external
function createUI (market, orders) {
  const windowWidth = size.get().width
  const unitWidth = Math.floor(windowWidth / 16)

  const orderTable = new Table({
    head: ['Order ID', 'Side', 'Amount', 'Limit Price', 'Time', 'Status'],
    colWidths: [5 * unitWidth, unitWidth, 3 * unitWidth, 3 * unitWidth, unitWidth, 2 * unitWidth],
    style: { head: ['gray'] }
  })

  const ui = []

  ui.push('')
  ui.push(String(`Orders: ${market.toUpperCase()}`).bold.white)
  ui.push('')

  orders.forEach((order) => {
    const price = order.isMarketOrder ? 'MARKET' : order.limitPrice

window-size

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.

MIT
Latest version published 6 years ago

Package Health Score

71 / 100
Full package analysis