univ-conv
Version:
The universal binary and text converter
53 lines • 1.65 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getType = exports.isEmpty = exports.hasNoStartLength = exports.deleteStartLength = exports.getStartEnd = exports.EMPTY_UINT8_ARRAY = exports.EMPTY_ARRAY_BUFFER = exports.DEFAULT_BUFFER_SIZE = void 0;
exports.DEFAULT_BUFFER_SIZE = 96 * 1024;
exports.EMPTY_ARRAY_BUFFER = new ArrayBuffer(0);
exports.EMPTY_UINT8_ARRAY = new Uint8Array(0);
function getStartEnd(options, size) {
let start = options.start ?? 0;
if (size != null && size < start) {
start = size;
}
let end;
if (options.length == null) {
if (size != null) {
end = size;
}
}
else {
end = start + options.length;
}
if (size != null && end != null && size < end) {
end = size;
}
if (end != null && end < start) {
end = start;
}
return { start, end };
}
exports.getStartEnd = getStartEnd;
function deleteStartLength(options) {
options = { ...options };
delete options.start;
delete options.length;
return options;
}
exports.deleteStartLength = deleteStartLength;
function hasNoStartLength(options) {
return options.start == null && options.length == null;
}
exports.hasNoStartLength = hasNoStartLength;
function isEmpty(input, options) {
return !input || options?.length === 0;
}
exports.isEmpty = isEmpty;
function getType(input) {
const type = typeof input;
if (type === "function" || type === "object") {
return input?.constructor?.name || String.toString.call(input);
}
return type;
}
exports.getType = getType;
//# sourceMappingURL=core.js.map