Current section

Files

Jump to
gossamer src gossamer blob.ffi.mjs
Raw

src/gossamer/blob.ffi.mjs

// src/utils/result.ts
import { Result$Error, Result$Ok } from "../../prelude.mjs";
function toResult(value) {
return value === null || value === void 0 ? Result$Error(void 0) : Result$Ok(value);
}
toResult.fromThrows = function(throws) {
try {
return Result$Ok(throws());
} catch (error) {
return Result$Error(
error instanceof Error ? error.message : String(error)
);
}
};
toResult.fromPromise = function(promise) {
return promise.then(
(value) => Result$Ok(value),
(error) => Result$Error(error instanceof Error ? error.message : String(error))
);
};
// src/gossamer/blob.ffi.ts
var new_ = () => {
return new Blob();
};
var from_string = (content) => {
return new Blob([content]);
};
var from_string_with_type = (content, mimeType) => {
return new Blob([content], { type: mimeType });
};
var from_bytes = (bytes2) => {
return new Blob([bytes2]);
};
var from_bytes_with_type = (bytes2, mimeType) => {
return new Blob([bytes2], { type: mimeType });
};
var size = (blob) => {
return blob.size;
};
var type_ = (blob) => {
return blob.type;
};
var array_buffer = (blob) => {
return toResult.fromPromise(blob.arrayBuffer());
};
var bytes = (blob) => {
return toResult.fromPromise(blob.bytes());
};
var slice = (blob, start, end) => {
return blob.slice(start, end);
};
var slice_with_type = (blob, start, end, contentType) => {
return blob.slice(start, end, contentType);
};
var stream = (blob) => {
return blob.stream();
};
var text = (blob) => {
return toResult.fromPromise(blob.text());
};
export {
array_buffer,
bytes,
from_bytes,
from_bytes_with_type,
from_string,
from_string_with_type,
new_,
size,
slice,
slice_with_type,
stream,
text,
type_
};