Socket
Socket
Sign inDemoInstall

@serialport/binding-abstract

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@serialport/binding-abstract - npm Package Compare versions

Comparing version 2.0.5 to 3.0.0

77

binding-abstract.js

@@ -25,8 +25,7 @@ const debug = require('debug')('serialport/binding-abstract')

/**
* Retrieves a list of available serial ports with metadata. The `comName` must be guaranteed, and all other fields should be undefined if unavailable. The `comName` is either the path or an identifier (eg `COM1`) used to open the serialport.
* Retrieves a list of available serial ports with metadata. The `path` must be guaranteed, and all other fields should be undefined if unavailable. The `path` is either the path or an identifier (eg `COM1`) used to open the serialport.
* @returns {Promise} resolves to an array of port [info objects](#module_serialport--SerialPort.list).
*/
static list() {
static async list() {
debug('list')
return Promise.resolve()
}

@@ -45,5 +44,5 @@

* @returns {Promise} Resolves after the port is opened and configured.
* @throws {TypeError} When given invalid arguments, a `TypeError` is thrown.
* @rejects {TypeError} When given invalid arguments, a `TypeError` is rejected.
*/
open(path, options) {
async open(path, options) {
if (!path) {

@@ -59,5 +58,4 @@ throw new TypeError('"path" is not a valid port')

if (this.isOpen) {
return Promise.reject(new Error('Already open'))
throw new Error('Already open')
}
return Promise.resolve()
}

@@ -68,10 +66,9 @@

* @returns {Promise} Resolves once the connection is closed.
* @throws {TypeError} When given invalid arguments, a `TypeError` is thrown.
* @rejects {TypeError} When given invalid arguments, a `TypeError` is rejected.
*/
close() {
async close() {
debug('close')
if (!this.isOpen) {
return Promise.reject(new Error('Port is not open'))
throw new Error('Port is not open')
}
return Promise.resolve()
}

@@ -88,5 +85,5 @@

* @returns {Promise} Resolves with the number of bytes read after a read operation.
* @throws {TypeError} When given invalid arguments, a `TypeError` is thrown.
* @rejects {TypeError} When given invalid arguments, a `TypeError` is rejected.
*/
read(buffer, offset, length) {
async read(buffer, offset, length) {
if (!Buffer.isBuffer(buffer)) {

@@ -106,9 +103,8 @@ throw new TypeError('"buffer" is not a Buffer')

if (buffer.length < offset + length) {
return Promise.reject(new Error('buffer is too small'))
throw new Error('buffer is too small')
}
if (!this.isOpen) {
return Promise.reject(new Error('Port is not open'))
throw new Error('Port is not open')
}
return Promise.resolve()
}

@@ -123,5 +119,5 @@

* @returns {Promise} Resolves after the data is passed to the operating system for writing.
* @throws {TypeError} When given invalid arguments, a `TypeError` is thrown.
* @rejects {TypeError} When given invalid arguments, a `TypeError` is rejected.
*/
write(buffer) {
async write(buffer) {
if (!Buffer.isBuffer(buffer)) {

@@ -133,5 +129,4 @@ throw new TypeError('"buffer" is not a Buffer')

if (!this.isOpen) {
return Promise.reject(new Error('Port is not open'))
throw new Error('Port is not open')
}
return Promise.resolve()
}

@@ -144,5 +139,5 @@

* @returns {Promise} Resolves once the port's baud rate changes.
* @throws {TypeError} When given invalid arguments, a `TypeError` is thrown.
* @rejects {TypeError} When given invalid arguments, a `TypeError` is rejected.
*/
update(options) {
async update(options) {
if (typeof options !== 'object') {

@@ -158,5 +153,4 @@ throw TypeError('"options" is not an object')

if (!this.isOpen) {
return Promise.reject(new Error('Port is not open'))
throw new Error('Port is not open')
}
return Promise.resolve()
}

@@ -173,5 +167,5 @@

* @returns {Promise} Resolves once the port's flags are set.
* @throws {TypeError} When given invalid arguments, a `TypeError` is thrown.
* @rejects {TypeError} When given invalid arguments, a `TypeError` is rejected.
*/
set(options) {
async set(options) {
if (typeof options !== 'object') {

@@ -182,5 +176,4 @@ throw new TypeError('"options" is not an object')

if (!this.isOpen) {
return Promise.reject(new Error('Port is not open'))
throw new Error('Port is not open')
}
return Promise.resolve()
}

@@ -191,10 +184,9 @@

* @returns {Promise} Resolves with the retrieved flags.
* @throws {TypeError} When given invalid arguments, a `TypeError` is thrown.
* @rejects {TypeError} When given invalid arguments, a `TypeError` is rejected.
*/
get() {
async get() {
debug('get')
if (!this.isOpen) {
return Promise.reject(new Error('Port is not open'))
throw new Error('Port is not open')
}
return Promise.resolve()
}

@@ -206,10 +198,9 @@

* @returns {Promise} Resolves with the current baud rate.
* @throws {TypeError} When given invalid arguments, a `TypeError` is thrown.
* @rejects {TypeError} When given invalid arguments, a `TypeError` is rejected.
*/
getBaudRate() {
async getBaudRate() {
debug('getbaudRate')
if (!this.isOpen) {
return Promise.reject(new Error('Port is not open'))
throw new Error('Port is not open')
}
return Promise.resolve()
}

@@ -220,10 +211,9 @@

* @returns {Promise} Resolves once the flush operation finishes.
* @throws {TypeError} When given invalid arguments, a `TypeError` is thrown.
* @rejects {TypeError} When given invalid arguments, a `TypeError` is rejected.
*/
flush() {
async flush() {
debug('flush')
if (!this.isOpen) {
return Promise.reject(new Error('Port is not open'))
throw new Error('Port is not open')
}
return Promise.resolve()
}

@@ -234,10 +224,9 @@

* @returns {Promise} Resolves once the drain operation finishes.
* @throws {TypeError} When given invalid arguments, a `TypeError` is thrown.
* @rejects {TypeError} When given invalid arguments, a `TypeError` is rejected.
*/
drain() {
async drain() {
debug('drain')
if (!this.isOpen) {
return Promise.reject(new Error('Port is not open'))
throw new Error('Port is not open')
}
return Promise.resolve()
}

@@ -244,0 +233,0 @@ }

@@ -6,2 +6,18 @@ # Change Log

# [3.0.0](https://github.com/node-serialport/node-serialport/compare/@serialport/binding-abstract@2.0.5...@serialport/binding-abstract@3.0.0) (2019-05-16)
### chore
* remove node6 support and upgrade codebase ([#1851](https://github.com/node-serialport/node-serialport/issues/1851)) ([d4f15c0](https://github.com/node-serialport/node-serialport/commit/d4f15c0))
### BREAKING CHANGES
* bindings now use async functions so they’ll never throw, only reject
## [2.0.5](https://github.com/node-serialport/node-serialport/compare/@serialport/binding-abstract@2.0.4...@serialport/binding-abstract@2.0.5) (2019-04-27)

@@ -8,0 +24,0 @@

{
"name": "@serialport/binding-abstract",
"version": "2.0.5",
"version": "3.0.0",
"main": "binding-abstract.js",

@@ -12,3 +12,3 @@ "keywords": [

"engines": {
"node": ">=6.0.0"
"node": ">=8.6.0"
},

@@ -23,3 +23,3 @@ "publishConfig": {

},
"gitHead": "4c723cc89e454017a28396e934bf7a00946fe866"
"gitHead": "524a2729003a94c9575904448d878a151f4f3790"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc