@squarecloud/blob
Version:
Official Square Cloud Blob SDK for NodeJS
56 lines (53 loc) • 1.98 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/utils/path-like.ts
var path_like_exports = {};
__export(path_like_exports, {
parsePathLike: () => parsePathLike
});
module.exports = __toCommonJS(path_like_exports);
var import_promises = require("fs/promises");
// src/structures/error.ts
var SquareCloudBlobError = class _SquareCloudBlobError extends Error {
constructor(code, message, cause) {
super(message, { cause });
this.name = _SquareCloudBlobError.name;
this.message = this.getMessage(code);
}
getMessage(rawCode) {
const code = rawCode.replaceAll("_", " ").toLowerCase().replace(/(^|\s)\S/g, (L) => L.toUpperCase());
const message = this.message ? `: ${this.message}` : "";
return `${code}${message}`;
}
};
// src/utils/path-like.ts
async function parsePathLike(pathLike) {
if (typeof pathLike === "string") {
const fileBuffer = await (0, import_promises.readFile)(pathLike).catch(() => void 0);
if (!fileBuffer) {
throw new SquareCloudBlobError("INVALID_FILE", "File not found");
}
return fileBuffer;
}
return pathLike;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
parsePathLike
});
//# sourceMappingURL=path-like.js.map