API Docs for: 0.50.0
Show:

TinCan.Utils Class

Defined in: src/Utils.js:26
Module: TinCan.Utils
Parent Module: TinCan

Methods

convertISO8601DurationToMilliseconds

(
  • ISO8601Duration
)
Int static

Defined in src/Utils.js:92

Parameters:

  • ISO8601Duration String

    Duration in ISO8601 format

Returns:

Int:

Duration in milliseconds

Note: does not handle input strings with years, months and days

convertMillisecondsToISO8601Duration

(
  • inputMilliseconds
)
String static

Defined in src/Utils.js:144

Parameters:

  • inputMilliseconds Int

    Duration in milliseconds

Returns:

String:

Duration in ISO8601 format

getBase64String

(
  • str
)
String static

Defined in src/Utils.js:212

Parameters:

  • str String

    Content to encode

Returns:

String:

Base64 encoded contents

getContentTypeFromHeader

(
  • header
)
String static

Defined in src/Utils.js:380

Parameters:

  • header String

    Content-Type header value

Returns:

String:

Primary value from Content-Type

getISODateString

(
  • date
)
String static

Defined in src/Utils.js:56

Parameters:

  • date Date

    Date to stringify

Returns:

String:

ISO date String

getLangDictionaryValue

(
  • prop
  • [lang]
)
String

Defined in src/Utils.js:226

Intended to be inherited by objects with properties that store display values in a language based "dictionary"

Parameters:

  • prop String

    Property name storing the dictionary

  • [lang] String optional

    Language to return

Returns:

String:

getServerRoot

(
  • absoluteUrl
)
String private

Defined in src/Utils.js:369

Parameters:

  • absoluteUrl String

Returns:

String:

server root of url

getSHA1String

(
  • str
)
String static

Defined in src/Utils.js:185

Parameters:

  • str String

    Content to hash

Returns:

String:

SHA1 for contents

getSHA256String

(
  • content
)
String static

Defined in src/Utils.js:197

Parameters:

  • content ArrayBuffer | String

    Content to hash

Returns:

String:

SHA256 for contents

getUUID

() String static

Defined in src/Utils.js:32

Generates a UUIDv4 compliant string that should be reasonably unique

Returns:

String:

UUID

isApplicationJSON

(
  • header
)
Boolean static

Defined in src/Utils.js:390

Parameters:

  • header String

    Content-Type header value

Returns:

Boolean:

whether "application/json" was matched

parseURL

(
  • url
  • [options]
)
Object private

Defined in src/Utils.js:257

Parameters:

  • url String
  • [options] Object optional
    • [allowRelative] Boolean optional

      Option to allow relative URLs

Returns:

Object:

Object of values

stringFromArrayBuffer

(
  • content
  • [encoding]
)
String static

Defined in src/Utils.js:411

Parameters:

  • content ArrayBuffer

    ArrayBuffer of content to convert to a String

  • [encoding] String optional

    Encoding to use for conversion

Returns:

String:

Converted content

stringToArrayBuffer

(
  • content
  • [encoding]
)
ArrayBuffer static

Defined in src/Utils.js:400

Parameters:

  • content String

    String of content to convert to an ArrayBuffer

  • [encoding] String optional

    Encoding to use for conversion

Returns:

ArrayBuffer:

Converted content