@shapediver/sdk.sdtf-v1
Version:
Official sdTF SDK for TypeScript
33 lines • 1.7 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());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SdtfHttpBufferCache = void 0;
const SdtfBinaryBufferCache_1 = require("./SdtfBinaryBufferCache");
class SdtfHttpBufferCache extends SdtfBinaryBufferCache_1.SdtfBinaryBufferCache {
constructor(httpClient) {
super();
this.httpClient = httpClient;
}
acquireBuffer(uri, offset, length) {
return __awaiter(this, void 0, void 0, function* () {
const [partialBuffer, entireBuffer] = yield this.httpClient.getBinaryBuffer(uri, offset, length);
if (entireBuffer) {
this.storeInCache(this.calcCacheKey(uri), this.cacheIdFullBuffer, new DataView(entireBuffer));
}
else {
this.storeInCache(this.calcCacheKey(uri), this.calcCacheId(offset, length), partialBuffer);
}
return partialBuffer;
});
}
}
exports.SdtfHttpBufferCache = SdtfHttpBufferCache;
//# sourceMappingURL=SdtfHttpBufferCache.js.map