@capacitor-community/bluetooth-le
Advanced tools
Comparing version 6.0.1 to 6.0.2
@@ -23,3 +23,9 @@ /** | ||
export declare function numberToUUID(value: number): string; | ||
export declare function hexStringToDataView(value: string): DataView; | ||
/** | ||
* Convert a string of hex into a DataView of raw bytes. | ||
* Note: characters other than [0-9a-fA-F] are ignored | ||
* @param hex string of values, e.g. "00 01 02" or "000102" | ||
* @return DataView of raw bytes | ||
*/ | ||
export declare function hexStringToDataView(hex: string): DataView; | ||
export declare function dataViewToHexString(value: DataView): string; | ||
@@ -26,0 +32,0 @@ export declare function webUUIDToString(uuid: string | number): string; |
@@ -33,9 +33,21 @@ /** | ||
} | ||
export function hexStringToDataView(value) { | ||
const numbers = value | ||
.trim() | ||
.split(' ') | ||
.filter((e) => e !== '') | ||
.map((s) => parseInt(s, 16)); | ||
return numbersToDataView(numbers); | ||
/** | ||
* Convert a string of hex into a DataView of raw bytes. | ||
* Note: characters other than [0-9a-fA-F] are ignored | ||
* @param hex string of values, e.g. "00 01 02" or "000102" | ||
* @return DataView of raw bytes | ||
*/ | ||
export function hexStringToDataView(hex) { | ||
const bin = []; | ||
let i, c, isEmpty = 1, buffer = 0; | ||
for (i = 0; i < hex.length; i++) { | ||
c = hex.charCodeAt(i); | ||
if ((c > 47 && c < 58) || (c > 64 && c < 71) || (c > 96 && c < 103)) { | ||
buffer = (buffer << 4) ^ ((c > 64 ? c + 9 : c) & 15); | ||
if ((isEmpty ^= 1)) { | ||
bin.push(buffer & 0xff); | ||
} | ||
} | ||
} | ||
return numbersToDataView(bin); | ||
} | ||
@@ -42,0 +54,0 @@ export function dataViewToHexString(value) { |
@@ -82,9 +82,21 @@ 'use strict'; | ||
} | ||
function hexStringToDataView(value) { | ||
const numbers = value | ||
.trim() | ||
.split(' ') | ||
.filter((e) => e !== '') | ||
.map((s) => parseInt(s, 16)); | ||
return numbersToDataView(numbers); | ||
/** | ||
* Convert a string of hex into a DataView of raw bytes. | ||
* Note: characters other than [0-9a-fA-F] are ignored | ||
* @param hex string of values, e.g. "00 01 02" or "000102" | ||
* @return DataView of raw bytes | ||
*/ | ||
function hexStringToDataView(hex) { | ||
const bin = []; | ||
let i, c, isEmpty = 1, buffer = 0; | ||
for (i = 0; i < hex.length; i++) { | ||
c = hex.charCodeAt(i); | ||
if ((c > 47 && c < 58) || (c > 64 && c < 71) || (c > 96 && c < 103)) { | ||
buffer = (buffer << 4) ^ ((c > 64 ? c + 9 : c) & 15); | ||
if ((isEmpty ^= 1)) { | ||
bin.push(buffer & 0xff); | ||
} | ||
} | ||
} | ||
return numbersToDataView(bin); | ||
} | ||
@@ -91,0 +103,0 @@ function dataViewToHexString(value) { |
@@ -79,9 +79,21 @@ var capacitorCommunityBluetoothLe = (function (exports, core) { | ||
} | ||
function hexStringToDataView(value) { | ||
const numbers = value | ||
.trim() | ||
.split(' ') | ||
.filter((e) => e !== '') | ||
.map((s) => parseInt(s, 16)); | ||
return numbersToDataView(numbers); | ||
/** | ||
* Convert a string of hex into a DataView of raw bytes. | ||
* Note: characters other than [0-9a-fA-F] are ignored | ||
* @param hex string of values, e.g. "00 01 02" or "000102" | ||
* @return DataView of raw bytes | ||
*/ | ||
function hexStringToDataView(hex) { | ||
const bin = []; | ||
let i, c, isEmpty = 1, buffer = 0; | ||
for (i = 0; i < hex.length; i++) { | ||
c = hex.charCodeAt(i); | ||
if ((c > 47 && c < 58) || (c > 64 && c < 71) || (c > 96 && c < 103)) { | ||
buffer = (buffer << 4) ^ ((c > 64 ? c + 9 : c) & 15); | ||
if ((isEmpty ^= 1)) { | ||
bin.push(buffer & 0xff); | ||
} | ||
} | ||
} | ||
return numbersToDataView(bin); | ||
} | ||
@@ -88,0 +100,0 @@ function dataViewToHexString(value) { |
{ | ||
"name": "@capacitor-community/bluetooth-le", | ||
"version": "6.0.1", | ||
"version": "6.0.2", | ||
"description": "Capacitor plugin for Bluetooth Low Energy ", | ||
@@ -46,7 +46,6 @@ "main": "dist/plugin.cjs.js", | ||
"@capacitor/ios": "^6.0.0", | ||
"@ionic/eslint-config": "^0.3.0", | ||
"@ionic/eslint-config": "^0.4.0", | ||
"@ionic/prettier-config": "^2.0.0", | ||
"@ionic/swiftlint-config": "^1.1.2", | ||
"@types/jest": "^29.2.5", | ||
"@typescript-eslint/eslint-plugin": "^5.47.1", | ||
"eslint": "^8.31.0", | ||
@@ -53,0 +52,0 @@ "jest": "^29.3.1", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
643227
19
5289
1128
0