Initial commit
[yaffs-website] / node_modules / window-size / index.js
1 'use strict';
2
3 /*!
4  * window-size <https://github.com/jonschlinkert/window-size>
5  *
6  * Copyright (c) 2014-2015 Jon Schlinkert
7  * Licensed under the MIT license.
8  */
9
10 var tty = require('tty');
11
12 module.exports = (function () {
13   var width;
14   var height;
15
16   if (tty.isatty(1) && tty.isatty(2)) {
17     if (process.stdout.getWindowSize) {
18       width = process.stdout.getWindowSize(1)[0];
19       height = process.stdout.getWindowSize(1)[1];
20     } else if (tty.getWindowSize) {
21       width = tty.getWindowSize()[1];
22       height = tty.getWindowSize()[0];
23     } else if (process.stdout.columns && process.stdout.rows) {
24       height = process.stdout.rows;
25       width = process.stdout.columns;
26     }
27   } else {
28     Error('window-size could not get size with tty or process.stdout.');
29   }
30
31   return {height: height, width: width};
32 })();