Module: kfs/utils

Methods

(static) coerceKey(key) → {String}

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

(static) coerceTablePath(tablePath) → {String}

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) → {String}

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(ridopt) → {String}

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

(static) createSbucketNameFromIndex(sBucketIndex) → {String}

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) → {Boolean}

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

(static) hashKey(key) → {String}

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

(static) isNotFoundError(error) → {Boolean}

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

(static) isValidKey(key) → {Boolean}

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) → {String}

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