# Module utils

### Functions

- appendExtraResponseAttributes
- asyncForEach
- compareTimestamps
- convertToCSV
- createAxiosInstance
- delay
- fetchLog
- fetchLogByChunks
- formatDataForRequest
- getValidJson
- isIEorEdgeOrOldFirefox
- isNode
- isRelativePath
- isUri
- isUrl
- needsRetry
- parseGeneratedCode
- parseSasViyaDebugResponse
- parseSasViyaLog
- parseSourceCode
- parseWeboutResponse
- serialize
- splitChunks

## Functions

### appendExtraResponseAttributes

- appendExtraResponseAttributes(response: any, extraResponseAttributes: ExtraResponseAttributes[]): Promise<object>

- - Defined in src/utils/appendExtraResponseAttributes.ts:3

  #### Parameters

  - ##### response: any

  - ##### extraResponseAttributes: ExtraResponseAttributes[]

  #### Returns Promise<object>

### asyncForEach

- asyncForEach(array: any[], callback: any): Promise<void>

- - Defined in src/utils/asyncForEach.ts:1

  #### Parameters

  - ##### array: any[]

  - ##### callback: any

  #### Returns Promise<void>

### Const compareTimestamps

- compareTimestamps(a: SASjsRequest, b: SASjsRequest): number

- - Defined in src/utils/compareTimestamps.ts:7

  Comparator for SASjs request timestamps.

  #### Parameters

  - ##### a: SASjsRequest

  - ##### b: SASjsRequest

  #### Returns number

### Const convertToCSV

- convertToCSV(data: any): string

- - Defined in src/utils/convertToCsv.ts:5

  Converts the given JSON object array to a CSV string.

  #### Parameters

  - ##### data: any

    the array of JSON objects to convert.

  #### Returns string

### Const createAxiosInstance

- createAxiosInstance(baseURL: string, httpsAgent?: https.Agent): AxiosInstance

- - Defined in src/utils/createAxiosInstance.ts:4

  #### Parameters

  - ##### baseURL: string

  - ##### Optional httpsAgent: https.Agent

  #### Returns AxiosInstance

### Const delay

- delay(ms: number): Promise<unknown>

- - Defined in src/utils/delay.ts:1

  #### Parameters

  - ##### ms: number

  #### Returns Promise<unknown>

### Const fetchLog

- fetchLog(requestClient: RequestClient, accessToken: string, logUrl: string, start: number, end: number): Promise<string>

- - Defined in src/utils/fetchLogByChunks.ts:30

  Fetches a section of the log file delineated by start and end lines

  #### Parameters

  - ##### requestClient: RequestClient

    client object of Request Client.

  - ##### accessToken: string

    an access token for an authorized user.

  - ##### logUrl: string

    url of the log file.

  - ##### start: number

    the line at which to start fetching the log.

  - ##### end: number

    the line at which to stop fetching the log.

  #### Returns Promise<string>

  an string containing log lines.

### Const fetchLogByChunks

- fetchLogByChunks(requestClient: RequestClient, accessToken: string, logUrl: string, logCount: number): Promise<string>

- - Defined in src/utils/fetchLogByChunks.ts:12

  Fetches content of the log file

  #### Parameters

  - ##### requestClient: RequestClient

    client object of Request Client.

  - ##### accessToken: string

    an access token for an authorized user.

  - ##### logUrl: string

    url of the log file.

  - ##### logCount: number

  #### Returns Promise<string>

  an string containing log lines.

### Const formatDataForRequest

- formatDataForRequest(data: any): any

- - Defined in src/utils/formatDataForRequest.ts:4

  #### Parameters

  - ##### data: any

  #### Returns any

### Const getValidJson

- getValidJson(str: string | object): object

- - Defined in src/utils/getValidJson.ts:7

  if string passed then parse the string to json else if throw error for all other types unless it is not a valid json object.

  #### Parameters

  - ##### str: string | object

    string to check.

  #### Returns object

### isIEorEdgeOrOldFirefox

- isIEorEdgeOrOldFirefox(): boolean

- - Defined in src/utils/isIeOrEdge.ts:1

  #### Returns boolean

### Const isNode

- isNode(): boolean

- - Defined in src/utils/isNode.ts:1

  #### Returns boolean

### Const isRelativePath

- isRelativePath(uri: string): boolean

- - Defined in src/utils/isRelativePath.ts:1

  #### Parameters

  - ##### uri: string

  #### Returns boolean

### Const isUri

- isUri(str: string): boolean

- - Defined in src/utils/isUri.ts:5

  Checks if string is in URI format.

  #### Parameters

  - ##### str: string

    string to check.

  #### Returns boolean

### Const isUrl

- isUrl(str: string): boolean

- - Defined in src/utils/isUrl.ts:5

  Checks if string is in URL format.

  #### Parameters

  - ##### str: string

    string to check.

  #### Returns boolean

### Const needsRetry

- needsRetry(responseText: string): boolean

- - Defined in src/utils/needsRetry.ts:1

  #### Parameters

  - ##### responseText: string

  #### Returns boolean

### Const parseGeneratedCode

- parseGeneratedCode(log: string): string

- - Defined in src/utils/parseGeneratedCode.ts:1

  #### Parameters

  - ##### log: string

  #### Returns string

### Const parseSasViyaDebugResponse

- parseSasViyaDebugResponse(response: string, requestClient: RequestClient, serverUrl: string): Promise<object>

- - Defined in src/utils/parseViyaDebugResponse.ts:14

  When querying a Viya job using the Web approach (as opposed to using the APIs) with _DEBUG enabled, the first response contains the log with the content in an iframe. Therefore when debug is enabled, and the serverType is VIYA, and useComputeApi is null (WEB), we call this function to extract the (_webout) content from the iframe.

  #### Parameters

  - ##### response: string

    first response from viya job

  - ##### requestClient: RequestClient

  - ##### serverUrl: string

  #### Returns Promise<object>

### Const parseSasViyaLog

- parseSasViyaLog(logResponse: object): string | object

- - Defined in src/utils/parseSasViyaLog.ts:1

  #### Parameters

  - ##### logResponse: object

    - ##### items: any[]

  #### Returns string | object

### Const parseSourceCode

- parseSourceCode(log: string): string

- - Defined in src/utils/parseSourceCode.ts:1

  #### Parameters

  - ##### log: string

  #### Returns string

### Const parseWeboutResponse

- parseWeboutResponse(response: string, url?: undefined | string): string

- - Defined in src/utils/parseWeboutResponse.ts:3

  #### Parameters

  - ##### response: string

  - ##### Optional url: undefined | string

  #### Returns string

### Const serialize

- serialize(obj: any): string

- - Defined in src/utils/serialize.ts:1

  #### Parameters

  - ##### obj: any

  #### Returns string

### Const splitChunks

- splitChunks(content: string): any[]

- - Defined in src/utils/splitChunks.ts:1

  #### Parameters

  - ##### content: string

  #### Returns any[]

Generated using TypeDoc