Socket
Socket
Sign inDemoInstall

raspi-serial-number

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

raspi-serial-number - npm Package Compare versions

Comparing version 1.0.3 to 1.0.5

2

package.json
{
"name": "raspi-serial-number",
"version": "1.0.3",
"version": "1.0.5",
"description": "Small library to get a Raspberry's Serial number without dependencies",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -17,11 +17,57 @@ #Raspberry Pi Serial Number [![11.15.0](https://badge.fury.io/js/raspi-serial-number.svg)](https://badge.fury.io/js/raspi-serial-number)

####function getSerialNumber(callback: (error: any, data?: string) => void): void;
###Async - Promises
```ts
function getSerialNumber(): Promise<string>;
```
Almost the same as the previous one but returns a promise which will resolve into the serial number or reject with an exception.
###Async - Callback
```ts
function getSerialNumber(callback: (error: any, data?: string) => void): void;
```
Receives a callback function. If there is an error, the first parameter of the callback will be it. If not, the serial number will be passed to the second parameter.
####function getSerialNumber(): Promise<string>;
Almost the same as the previous one but returns a promise which will resolve into the serial number or reject with an exception.
####function getSerialNumberSync(): string;
###Sync
```ts
function getSerialNumberSync(): string;
```
Returns Raspberry Pi's serial number string or throws an exception if there is an error.
##Examples
###### (Typescript definitions already included)
###On ES5:
`const {getSerialNumber, getSerialNumberSync} = require('raspi-serial-number');`
###On ES6:
`import {getSerialNumber, getSerialNumberSync} from 'raspi-serial-number';`
###Async - Promises
```ts
getSerialNumber()
.then(d=>console.log("Promise result: ",d))
.catch(e=>console.log("Promise error: ",e));
```
###Async - Callback
```ts
getSerialNumber((error,data) => {
if(error)
console.error("Callback error: ",error);
else
console.log("Callback result: ",data)
});
```
###Sync
```ts
try {
console.log("Sync result: ",getSerialNumberSync());
} catch (e) {
console.error("Sync error: ",e);
}
```
##Future work

@@ -28,0 +74,0 @@ * Add options to allow specifying whether or not the leftmost zeros should be trimmed or not (current behaviour is trimming the leftmost zeros of the serial number)

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