mirror of
https://github.com/siemens-mobile-hacks/node-serialport-bindings-cpp.git
synced 2026-11-25 18:37:19 +00:00
Hello,
I have a use case where size of an application is important, I'd like to
webpack as much as possible. The problematic part is related *.node
files, I found a potential solution, example with sqlite:
```
externals: {
'./sqlite3-binding.js': 'commonjs ./node_sqlite3.node',
}
```
I can replace sqlite3-binding.js [1] with *.node, then I copy
node_sqlite3.node to the main application folder. I'd like to try
something similar with the serialport. However, it is slightly more
complicated since serialport doesn't have single import file. This PR is
an attempt to fix the problem.
[1]
https://github.com/TryGhost/node-sqlite3/blob/master/lib/sqlite3-binding.js
---------
Co-authored-by: Krzysztof Rosiński <krzysiek@jrdltd.co.uk>
14 lines
1.6 KiB
TypeScript
14 lines
1.6 KiB
TypeScript
import { promisify } from 'util'
|
|
import { binding } from './serialport-bindings'
|
|
|
|
export const asyncClose = binding.close ? promisify(binding.close) : async () => { throw new Error('"binding.close" Method not implemented')}
|
|
export const asyncDrain = binding.drain ? promisify(binding.drain) : async () => { throw new Error('"binding.drain" Method not implemented')}
|
|
export const asyncFlush = binding.flush ? promisify(binding.flush) : async () => { throw new Error('"binding.flush" Method not implemented')}
|
|
export const asyncGet = binding.get ? promisify(binding.get) : async () => { throw new Error('"binding.get" Method not implemented')}
|
|
export const asyncGetBaudRate = binding.getBaudRate ? promisify(binding.getBaudRate) : async () => { throw new Error('"binding.getBaudRate" Method not implemented')}
|
|
export const asyncList = binding.list ? promisify(binding.list) : async () => { throw new Error('"binding.list" Method not implemented')}
|
|
export const asyncOpen = binding.open ? promisify(binding.open) : async () => { throw new Error('"binding.open" Method not implemented')}
|
|
export const asyncSet = binding.set ? promisify(binding.set) : async () => { throw new Error('"binding.set" Method not implemented')}
|
|
export const asyncUpdate = binding.update ? promisify(binding.update) : async () => { throw new Error('"binding.update" Method not implemented')}
|
|
export const asyncRead = binding.read ? promisify(binding.read) : async () => { throw new Error('"binding.read" Method not implemented')}
|
|
export const asyncWrite = binding.write ? promisify(binding.write) : async () => { throw new Error('"binding.write" Method not implemented')}
|