typed-conversions

typed-conversions

Usage no npm install needed!

<script type="module">
  import typedConversions from 'https://cdn.skypack.dev/typed-conversions';
</script>

README

typed-conversions

A small set of data conversion functions with Typescript 2.x typing. Conversions include:

General Use

  • hashToArray< T = any >(hash: IDictionary< T >): T[]
  • arrayToHash< T = any >(arr: T[]): IDictionary< T >
  • removeIdPropertyFromHash< T = any >(hash: IDictionary, keyProp: keyof T = "id"): IDictionary<Exclude<T, "id">>
  • flatten< T = any >(list: T[]): T[]

Firebase Specific

  • snapshotToArray<T>: T[]
  • snapshotToHash<T>: IDictionary<T> - combines snap.val() and snap.key into a JS Object
  • snapshotToOrderedArray<T>: T[]
  • snapshotToOrderedHash<T>: Array<IDictionary<T>>