UNPKG

univ-conv

Version:

The universal binary and text converter

45 lines 1.23 kB
export const DEFAULT_BUFFER_SIZE = 96 * 1024; export const EMPTY_ARRAY_BUFFER = new ArrayBuffer(0); export const EMPTY_UINT8_ARRAY = new Uint8Array(0); export 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 }; } export function deleteStartLength(options) { options = { ...options }; delete options.start; delete options.length; return options; } export function hasNoStartLength(options) { return options.start == null && options.length == null; } export function isEmpty(input, options) { return !input || options?.length === 0; } export function getType(input) { const type = typeof input; if (type === "function" || type === "object") { return input?.constructor?.name || String.toString.call(input); } return type; } //# sourceMappingURL=core.js.map