Options
All
  • Public
  • Public/Protected
  • All
Menu

fitbit-settings-commons

Index

Type aliases

ASIS

ASIS: typeof ASIS

NonUndefined

NonUndefined<T>: T extends undefined ? never : T

utility type, remove 'undefined' from T

Type parameters

  • T

PackerUnpackerOption

PackerUnpackerOption<SettingsType>: {}

Type of the optional second parameter of the constructor of TypedSettingProps, to customise pack / unpack / initiate behaviour of the wrapper for individual SettingsType properties. Expects an object, with matching keys of the SettingsType. Under a matching key, 'packer' and 'unpackInitiator' can be provided as functions. For example:

 {
   stringConfusingVal: {
     packer: v => v,
     unpackInitiator: v => v
   }
 }

A packer function receives a value of the type of the matching SettingsType property and returns a string. An unpackInitiator receives a string or undefined and returns a value of the type of the matching SettingsType property. If an unpackInitiator is provided, but no setting is under the matching key, the unpackInitiator will be called with 'undefined', acting as an initiator to return a default value for the key.

Type parameters

  • SettingsType: object

Type declaration

Variables

Const ASIS

ASIS: Readonly<object>

A marker, to be used with TypedSettingProps.update()

Functions

Const jsonParseUnpackInitiator

  • jsonParseUnpackInitiator(setting: string | undefined): any
  • The default unpacker/initiator of the wrapper. First attempt to JSON.parse(setting), if fails, just return setting as string.

    Parameters

    • setting: string | undefined

      setting string

    Returns any

Const stringifyNonString

  • stringifyNonString(value: any): string
  • Return JSON.stringify(value) if value is not string, otherwise just return value. Can be used as packer if desired.

    Parameters

    • value: any

    Returns string

Generated using TypeDoc