Skip to content

Commit

Permalink
Breaking changes: engine node >= 4.5, because of node v6 'new Buffer'…
Browse files Browse the repository at this point in the history
… deprecation migration
  • Loading branch information
cronvel committed Nov 1, 2016
1 parent 22c7e26 commit 7e98ab2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

v0.25.0
-------

Breaking changes: engine node >= 4.5, because of node v6 'new Buffer' deprecation migration


v0.24.30
--------

Expand Down
14 changes: 7 additions & 7 deletions lib/ScreenBuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ ScreenBuffer.create = function create( options )

Object.defineProperties( screenBuffer , {
buffer: { enumerable: true , configurable: true ,
value: new Buffer( screenBuffer.width * screenBuffer.height * ScreenBuffer.ITEM_SIZE )
value: Buffer.allocUnsafe( screenBuffer.width * screenBuffer.height * ScreenBuffer.ITEM_SIZE )
}
} ) ;

Expand Down Expand Up @@ -180,7 +180,7 @@ ScreenBuffer.prototype.fill = function fill( options )

if ( options && typeof options === 'object' )
{
clearBuffer = new Buffer( ScreenBuffer.ITEM_SIZE ) ;
clearBuffer = Buffer.allocUnsafe( ScreenBuffer.ITEM_SIZE ) ;

// Write the attributes
attr = options.attr !== undefined ? options.attr : ScreenBuffer.DEFAULT_ATTR ;
Expand Down Expand Up @@ -379,7 +379,7 @@ ScreenBuffer.prototype.resize = function resize( fromRect )
if ( toRect.isNull ) { return false ; }

// Generate a new buffer
var resizedBuffer = new Buffer( toRect.width * toRect.height * ScreenBuffer.ITEM_SIZE ) ;
var resizedBuffer = Buffer.allocUnsafe( toRect.width * toRect.height * ScreenBuffer.ITEM_SIZE ) ;
this.fill( { buffer: resizedBuffer } ) ;

// We use the blit to reconstruct the buffer geometry
Expand Down Expand Up @@ -622,7 +622,7 @@ ScreenBuffer.prototype.terminalBlitter = function terminalBlitter( p )
{
if ( ! this.lastBuffer || this.lastBuffer.length !== this.buffer.length )
{
this.lastBuffer = new Buffer( this.buffer ) ;
this.lastBuffer = Buffer.from( this.buffer ) ;
}
else if ( this.lastBufferUpToDate )
{
Expand Down Expand Up @@ -792,7 +792,7 @@ ScreenBuffer.prototype.saveSyncV1 = function saveSync( filepath )
{
var content ;

content = new Buffer( ScreenBuffer.HEADER_SIZE + this.buffer.length ) ;
content = Buffer.allocUnsafe( ScreenBuffer.HEADER_SIZE + this.buffer.length ) ;

// Clear the header area
content.fill( 0 , 0 , ScreenBuffer.HEADER_SIZE ) ;
Expand Down Expand Up @@ -886,7 +886,7 @@ ScreenBuffer.prototype.saveSyncV2 = function saveSync( filepath )

header = 'SB\n' + JSON.stringify( header ) + '\n' ;

content = new Buffer( header.length + this.buffer.length ) ;
content = Buffer.allocUnsafe( header.length + this.buffer.length ) ;
content.write( header ) ;

this.buffer.copy( content , header.length ) ;
Expand Down Expand Up @@ -1164,7 +1164,7 @@ ScreenBuffer.ITEM_SIZE = ScreenBuffer.ATTR_SIZE + ScreenBuffer.CHAR_SIZE ;

ScreenBuffer.DEFAULT_ATTR = ScreenBuffer.object2attr( { color: 'white' , bgColor: 'black' } ) ;
ScreenBuffer.CLEAR_ATTR = ScreenBuffer.object2attr( { color: 'white' , bgColor: 'black' , transparency: true } ) ;
ScreenBuffer.CLEAR_BUFFER = new Buffer( ScreenBuffer.ITEM_SIZE ) ;
ScreenBuffer.CLEAR_BUFFER = Buffer.allocUnsafe( ScreenBuffer.ITEM_SIZE ) ;
ScreenBuffer.CLEAR_BUFFER.writeInt32BE( ScreenBuffer.DEFAULT_ATTR , 0 ) ;
ScreenBuffer.CLEAR_BUFFER.write( ' \x00\x00\x00' , ScreenBuffer.ATTR_SIZE ) ; // space

Expand Down
4 changes: 2 additions & 2 deletions lib/gpm.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ module.exports = gpm ;


// Can't figure out the usage of the GPM_MAGIC constant ATM
var gpmMagic = new Buffer( 4 ) ;
var gpmMagic = Buffer.allocUnsafe( 4 ) ;
gpmMagic.writeUInt32LE( 0x47706D4C , 0 ) ;



// Return a Buffer containing a Gpm_Connect structure, using a pid and a ttyIndex
gpm.connectStructureBuffer = function connectStructureBuffer( gpmConnect )
{
var buffer = new Buffer( 16 ) ;
var buffer = Buffer.allocUnsafe( 16 ) ;

if ( gpmConnect.eventMask === undefined ) { gpmConnect.eventMask = 65535 ; }
if ( gpmConnect.defaultMask === undefined ) { gpmConnect.defaultMask = 0 ; }
Expand Down
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
{
"name": "terminal-kit",
"version": "0.24.30",
"version": "0.25.0",
"description": "256 colors, keys and mouse, input field, screen buffer, interactive 'yes or no', and many more... Whether you just need colors and styles, build a simple interactive command line tool or a complexe terminal app: this is the absolute terminal lib for Node.js!",
"main": "lib/termkit.js",
"directories": {
"test": "test"
},
"engines": {
"node": ">=4.0.0"
"node": ">=4.5.0"
},
"dependencies": {
"async-kit": "^2.1.6",
"nextgen-events": "^0.9.5",
"string-kit": "^0.5.10",
"async-kit": "^2.2.0",
"jshint": "^2.9.4",
"mocha": "^3.1.2",
"nextgen-events": "^0.9.8",
"string-kit": "^0.5.11",
"tree-kit": "^0.5.26"
},
"devDependencies": {
Expand All @@ -21,7 +23,7 @@
"mocha": "^3.0.2"
},
"scripts": {
"test": "mocha -R dot"
"test": "tea-time -R dot"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 7e98ab2

Please sign in to comment.