Skip to content

Commit

Permalink
Merge pull request #30 from coachcare/typescript
Browse files Browse the repository at this point in the history
Typescript
  • Loading branch information
CaptainJeff committed Feb 24, 2021
2 parents 7f5fd3c + 48cf07d commit dc58867
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 18 deletions.
16 changes: 8 additions & 8 deletions docs/assets/anchor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* eslint-env amd, node */

// https://github.com/umdjs/umd/blob/master/templates/returnExports.js
(function (root, factory) {
(function(root, factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
Expand All @@ -21,7 +21,7 @@
root.AnchorJS = factory();
root.anchors = new root.AnchorJS();
}
})(this, function () {
})(this, function() {
'use strict';
function AnchorJS(options) {
this.options = options || {};
Expand Down Expand Up @@ -51,7 +51,7 @@
* https://github.com/Modernizr/Modernizr/blob/da22eb27631fc4957f67607fe6042e85c0a84656/feature-detects/touchevents.js#L40
* @returns {Boolean} - true if the current device supports touch.
*/
this.isTouchDevice = function () {
this.isTouchDevice = function() {
return !!(
'ontouchstart' in window ||
(window.DocumentTouch && document instanceof DocumentTouch)
Expand All @@ -64,7 +64,7 @@
* to. Also accepts an array or nodeList containing the relavant elements.
* @returns {this} - The AnchorJS object
*/
this.add = function (selector) {
this.add = function(selector) {
var elements,
elsWithIds,
idList,
Expand Down Expand Up @@ -193,7 +193,7 @@
* OR a nodeList / array containing the DOM elements.
* @returns {this} - The AnchorJS object
*/
this.remove = function (selector) {
this.remove = function(selector) {
var index,
domAnchor,
elements = _getElements(selector);
Expand All @@ -216,7 +216,7 @@
/**
* Removes all anchorjs links. Mostly used for tests.
*/
this.removeAll = function () {
this.removeAll = function() {
this.remove(this.elements);
};

Expand All @@ -229,7 +229,7 @@
* @param {String} text - Any text. Usually pulled from the webpage element we are linking to.
* @returns {String} - hyphen-delimited text for use in IDs and URLs.
*/
this.urlify = function (text) {
this.urlify = function(text) {
// Regex for finding the nonsafe URL characters (many need escaping): & +$,:;=?@"#{}|^~[`%!'<>]./()*\
var nonsafeChars = /[& +$,:;=?@"#{}|^~[`%!'<>\]\.\/\(\)\*\\]/g,
urlText;
Expand Down Expand Up @@ -260,7 +260,7 @@
* @param {HTMLElemnt} el - a DOM node
* @returns {Boolean} true/false
*/
this.hasAnchorJSLink = function (el) {
this.hasAnchorJSLink = function(el) {
var hasLeftAnchor =
el.firstChild &&
(' ' + el.firstChild.className + ' ').indexOf(' anchorjs-link ') > -1,
Expand Down
14 changes: 7 additions & 7 deletions docs/assets/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ anchors.add('h3');
// Filter UI
var tocElements = document.getElementById('toc').getElementsByTagName('li');

document.getElementById('filter-input').addEventListener('keyup', function (e) {
document.getElementById('filter-input').addEventListener('keyup', function(e) {
var i, element, children;

// enter key
Expand All @@ -22,14 +22,14 @@ document.getElementById('filter-input').addEventListener('keyup', function (e) {
}
}

var match = function () {
var match = function() {
return true;
};

var value = this.value.toLowerCase();

if (!value.match(/^\s*$/)) {
match = function (element) {
match = function(element) {
var html = element.firstChild.innerHTML;
return html && html.toLowerCase().indexOf(value) !== -1;
};
Expand Down Expand Up @@ -114,12 +114,12 @@ var cw_without_sb = split_left.clientWidth;
split_left.style.overflow = '';

Split(['#split-left', '#split-right'], {
elementStyle: function (dimension, size, gutterSize) {
elementStyle: function(dimension, size, gutterSize) {
return {
'flex-basis': 'calc(' + size + '% - ' + gutterSize + 'px)'
};
},
gutterStyle: function (dimension, gutterSize) {
gutterStyle: function(dimension, gutterSize) {
return {
'flex-basis': gutterSize + 'px'
};
Expand Down Expand Up @@ -152,9 +152,9 @@ function loadState(ev) {
}
}

window.addEventListener('load', function () {
window.addEventListener('load', function() {
// Restore after Firefox scrolls to hash.
setTimeout(function () {
setTimeout(function() {
loadState();
// Update with initial scroll position.
updateState();
Expand Down
5 changes: 5 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15702,6 +15702,11 @@ <h3 class='fl m0' id='bleerrorcodemessagemapping'>

<div class='pre p1 fill-light mt0'>BleErrorCodeMessageMapping</div>

<p>
Type:
{}
</p>




Expand Down
127 changes: 127 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,133 @@ declare module 'react-native-ble-plx' {
transactionId?: TransactionId
): Subscription

monitorTrackerResponse(
deviceIdentifier: DeviceId,
listener: (error: BleError | null, characteristic: Characteristic | null) => void,
transactionId?: TransactionId
): Subscription

listenForAlternativeScaleResponse(
deviceIdentifier: DeviceId,
listener: (error: BleError | null, characteristic: Characteristic | null) => void,
transactionId?: TransactionId
): Subscription

monitorGlucometerResponse(
deviceIdentifier: DeviceId,
listener: (error: BleError | null, characteristic: Characteristic | null) => void,
transactionId?: TransactionId
): Subscription


monitorScaleResponse(
deviceIdentifier: DeviceId,
listener: (error: BleError | null, characteristic: Characteristic | null) => void,
transactionId?: TransactionId
): Subscription

monitorAlternativeScaleFinalResponse(
deviceIdentifier: DeviceId,
listener: (error: BleError | null, characteristic: Characteristic | null) => void,
transactionId?: TransactionId
): Subscription

monitorBloodPressureResponse(
deviceIdentifier: DeviceId,
listener: (error: BleError | null, characteristic: Characteristic | null) => void,
transactionId?: TransactionId
): Subscription

setBloodPressureTime(
deviceIdentifier: DeviceId,
date: string | number
): Promise<Characteristic>

turnBloodPressureVoiceOff(
deviceIdentifier: DeviceId
): Promise<Characteristic>

setGlucometerTime(
deviceIdentifier: DeviceId
): Promise<Characteristic>

getSummaryDayActivity(
deviceIdentifier: DeviceId,
count: number
): Promise<Characteristic>

activateVibration(
deviceIdentifier: DeviceId,
count: number
): Promise<Characteristic>

setDeviceTime(
deviceIdentifier: DeviceId,
date: string
): Promise<Characteristic>

setTrackerDistanceUnit(
deviceIdentifier: DeviceId,
unit: string
): Promise<Characteristic>

startBloodPressureTesting(
deviceIdentifier: DeviceId
): Promise<Characteristic>

glucometerCountdown(
response: string
): number

glucometerFinalMeasurement(
response: string
): any

glucometerInfoReading(
response: string
): any

glucometerInfoReading(
response: string
): any

setUserProfileToScales(
deviceIdentifier: DeviceId,
age: number,
height: number,
gender: string,
): Promise<Characteristic>

synchronizeAlternativeScale(
deviceIdentifier: DeviceId,
user: string,
measurement: string,
): Promise<Characteristic>

setUserProfileToAlternativeScale(
deviceIdentifier: DeviceId,
user: string,
age: number,
height: number,
gender: number
): Promise<Characteristic>

resetAlternativeScale(
deviceIdentifier: DeviceId
): Promise<Characteristic>

resetAlternativeScale(
deviceIdentifier: DeviceId
): Promise<Characteristic>

selectProfileAlternativeScale(
deviceIdentifier: DeviceId,
user: string
): Promise<Characteristic>




// Mark: Descriptors operations ----------------------------------------------------------------------------------

/**
Expand Down
6 changes: 3 additions & 3 deletions src/BleManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ export class BleManager {
user: string,
age: number,
height: number,
gender: string,
gender: number,
transactionId: ? TransactionId
): Promise < Characteristic > {
if (!transactionId) {
Expand Down Expand Up @@ -907,14 +907,14 @@ export class BleManager {
async synchronizeAlternativeScale(
deviceIdentifier: DeviceId,
user: string,
measurement: number,
measurement: string,
transactionId: ? TransactionId
): Promise < Characteristic > {
if (!transactionId) {
transactionId = this._nextUniqueID()
}

const measurementUnit = measurementUnit === "metric" ? 0 : 1;
const measurementUnit = measurement === "metric" ? 0 : 1;

var uint16 = new Uint8Array(13)
uint16[0] = 0x41;
Expand Down

0 comments on commit dc58867

Please sign in to comment.