kubo-rpc-client-esm-cjs
Version:
A client library for the Kubo RPC API
42 lines • 2.05 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createAdd = void 0;
const add_all_js_1 = require("./add-all.js");
const it_last_1 = __importDefault(require("it-last"));
const configure_js_1 = require("./lib/configure.js");
const normalise_input_single_1 = require("ipfs-core-utils/files/normalise-input-single");
/**
* @param {import('./types').Options} options
*/
function createAdd(options) {
const all = (0, add_all_js_1.createAddAll)(options);
return (0, configure_js_1.configure)(() => {
/**
* @type {import('./types').RootAPI["add"]}
*/
function add(input, options = {}) {
return __awaiter(this, void 0, void 0, function* () {
const source = (0, normalise_input_single_1.normaliseInput)(input);
// @ts-expect-error - all may return undefined if source is empty
const addAllPromise = all(source, options);
// @ts-expect-error - last may return undefined if source is empty
return yield (0, it_last_1.default)(addAllPromise);
});
}
return add;
})(options);
}
exports.createAdd = createAdd;
//# sourceMappingURL=add.js.map