Methods
(inner) fileHash(path, encoding) → {string}
Compute a hash for a file's contents
Parameters:
Name | Type | Default | Description |
---|---|---|---|
path | string | File path | |
encoding | string | utf8 | [utf8] - File encoding |
Returns:
The hex encoded hash digest
- Type:
- string
(inner) safePath(file, base) → {string|undefined}
Examines if a relative path resolves under the CWD
Parameters:
Name | Type | Description |
---|---|---|
file | string | The relative file path |
base | string | [ |
Returns:
undefined
if file path is not considered safe
- Type:
- string |
undefined
Example
safePath('../../../../../etc/passwd'); // Returns `undefined`
(inner) validateType(name, value, type) → {undefined}
Validate th type of an argument
Parameters:
Name | Type | Description |
---|---|---|
name | string | The argument's name |
value | any | The argument's value |
type | string | The expected value type |
Throws:
Error if validation fails
Returns:
When validation passes
- Type:
- undefined