UNPKG

path-to-hash

Version:
20 lines (19 loc) 623 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var fs_1 = require("fs"); var data_to_hash_1 = require("data-to-hash"); function hashPath(algorithm, path, encoding) { if (encoding === void 0) { encoding = 'hex'; } return new Promise(function (resolve, reject) { fs_1.readFile(path, function (error, buffer) { error && reject(error); try { resolve(data_to_hash_1.default(algorithm, buffer, encoding)); } catch (error) { reject(error); } }); }); } exports.default = hashPath;