raspi-serial-number
Advanced tools
Comparing version 1.0.3 to 1.0.5
{ | ||
"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) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13974
78