Skip to content

Instantly share code, notes, and snippets.

@mold
mold / get-float-value.js
Created September 12, 2018 12:23
Converting a 4-byte float (IEEE-11073) to a JavaScript number
/**
* Converts a DataView that represents a 4 byte float (IEEE-11073)
* to an actual float. Useful for example when reading temperature
* from a Bluetooth thermometer :)
*
* The DataView buffer should contain at least 4 bytes:
*
* [b0, b1, b2, b3]
* ^ ^ ^ └---------- Exponent
* └---└---└------- Will become the mantissa
@mold
mold / combine-latest-to-object.ts
Last active August 21, 2022 20:46
An rxjs combineLatest that takes an object of key/observable pairs and emits an object of key/values when any of the inner observables emits (typescript).
import { combineLatest, noop, Observable } from 'rxjs';
import { debounceTime, map, shareReplay, startWith, tap } from 'rxjs/operators';
export interface OperatorDict<X> {
[key: string]: Observable<X> | [Observable<X>, X];
}
/**
* Extracts the type `T` of an `Observable<T>`
*/