incubed
Version:
Typescript-version of the incubed client
16 lines • 792 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
class API {
constructor(_client) {
this.client = _client;
}
get(hash, resultEncoding) {
return this.client.sendRPC('ipfs_get', [hash, resultEncoding || 'base64'], '0x7d0')
.then(response => response.result ? Buffer.from(response.result, (resultEncoding || 'base64')) : Promise.reject(new Error(response.error || 'Hash not found')));
}
put(data, dataEncoding) {
return this.client.sendRPC('ipfs_put', [data.toString(dataEncoding || 'base64'), (dataEncoding || 'base64')], '0x7d0').then(response => response.result ? response.result : Promise.reject(new Error(response.error || 'Hash not found')));
}
}
exports.default = API;
//# sourceMappingURL=api.js.map