Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Porting old Buffer constructor to Buffer.from()/Buffer.alloc() #27

Merged
merged 1 commit into from
Feb 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ bleno.startAdvertisingIBeacon(uuid, major, minor, measuredPower[, callback(error
##### Start advertising with EIR data (__Linux only__)

```javascript
var scanData = new Buffer(...); // maximum 31 bytes
var advertisementData = new Buffer(...); // maximum 31 bytes
var scanData = Buffer.alloc(...); // maximum 31 bytes
var advertisementData = Buffer.alloc(...); // maximum 31 bytes

bleno.startAdvertisingWithEIRData(advertisementData[, scanData, callback(error)]);
```
Expand Down Expand Up @@ -227,7 +227,7 @@ Parameters to handler are

```javascript
var result = Characteristic.RESULT_SUCCESS;
var data = new Buffer( ... );
var data = Buffer.alloc( ... );

callback(result, data);
```
Expand Down
6 changes: 3 additions & 3 deletions examples/battery-service/battery-level-characteristic.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var BatteryLevelCharacteristic = function() {
}),
new Descriptor({
uuid: '2904',
value: new Buffer([0x04, 0x01, 0x27, 0xAD, 0x01, 0x00, 0x00 ]) // maybe 12 0xC unsigned 8 bit
value: Buffer.from([0x04, 0x01, 0x27, 0xAD, 0x01, 0x00, 0x00 ]) // maybe 12 0xC unsigned 8 bit
})
]
});
Expand All @@ -34,11 +34,11 @@ BatteryLevelCharacteristic.prototype.onReadRequest = function(offset, callback)
var percent = data.split('\t')[1].split(';')[0];
console.log(percent);
percent = parseInt(percent, 10);
callback(this.RESULT_SUCCESS, new Buffer([percent]));
callback(this.RESULT_SUCCESS, Buffer.from([percent]));
});
} else {
// return hardcoded value
callback(this.RESULT_SUCCESS, new Buffer([98]));
callback(this.RESULT_SUCCESS, Buffer.from([98]));
}
};

Expand Down
Loading