Module: kfs/utils

Source:

Methods


<static> coerceKey(key)

Coerces input into a valid file key
Parameters:
Name Type Description
key String The file key
Source:
Returns:
Type
String

<static> coerceTablePath(tablePath)

Ensures that the given path has a kfs extension
Parameters:
Name Type Description
tablePath String The path name to a kfs instance
Source:
Returns:
Type
String

<static> createItemKeyFromIndex(key, index)

Get the key name for a data hash + index
Parameters:
Name Type Description
key String Hash of the data
index Number The index of the file chunk
Source:
Returns:
Type
String

<static> createReferenceId( [rid])

Creates a random reference ID
Parameters:
Name Type Argument Description
rid String <optional>
An existing hex reference ID
Source:
Returns:
Type
String

<static> createSbucketNameFromIndex(sBucketIndex)

Get the file name of an s bucket based on it's index
Parameters:
Name Type Description
sBucketIndex Number The index fo the bucket in the B-table
Source:
Returns:
Type
String

<static> fileDoesExist(filePath)

Check if the given path exists
Parameters:
Name Type Description
filePath String
Source:
Returns:
Type
Boolean

<static> hashKey(key)

Hashes the given key
Parameters:
Name Type Description
key String The file key
Source:
Returns:
Type
String

<static> isNotFoundError(error)

Determines if the passed error object is a NotFound error
Parameters:
Name Type Description
error Error
Source:
Returns:
Type
Boolean

<static> isValidKey(key)

Tests if the string is a valid key
Parameters:
Name Type Description
key String The file key
Source:
Returns:
Type
Boolean

<static> noop()

A stubbed noop function
Source:

<static> toHumanReadableSize(bytes)

Takes a number of bytes and outputs a human readable size
Parameters:
Name Type Description
bytes Number The number of bytes to make readable
Source:
Returns:
Type
String