mobiletto-base
Advanced tools
Comparing version 2.0.33 to 2.0.34
@@ -46,3 +46,3 @@ "use strict"; | ||
const UTILITY_FUNCTIONS = { | ||
list: (client) => (path, opts) => __awaiter(void 0, void 0, void 0, function* () { | ||
list: (client) => (path, opts, visitor) => __awaiter(void 0, void 0, void 0, function* () { | ||
path || (path = ""); | ||
@@ -62,4 +62,4 @@ const cache = client.scopedCache("list"); | ||
} | ||
const recursive = opts && opts.recursive ? opts.recursive : false; | ||
const visitor = opts && opts.visitor ? opts.visitor : undefined; | ||
const recursive = opts && (opts === true || (opts.recursive ? opts.recursive : false)); | ||
visitor = visitor ? visitor : typeof opts === "object" && opts.visitor ? opts.visitor : undefined; | ||
if (visitor && typeof visitor !== "function") { | ||
@@ -103,5 +103,5 @@ throw new mobiletto_common_1.MobilettoError(`list: visitor is not a function: ${typeof visitor}`); | ||
}), | ||
safeList: (client) => (path, opts) => __awaiter(void 0, void 0, void 0, function* () { | ||
const recursive = opts && opts.recursive ? opts.recursive : false; | ||
const visitor = opts && opts.visitor ? opts.visitor : undefined; | ||
safeList: (client) => (path, opts, visitor) => __awaiter(void 0, void 0, void 0, function* () { | ||
const recursive = (opts && opts === true) || (typeof opts === "object" && opts.recursive ? opts.recursive : false); | ||
visitor = visitor ? visitor : typeof opts === "object" && opts.visitor ? opts.visitor : undefined; | ||
try { | ||
@@ -108,0 +108,0 @@ // noinspection JSUnresolvedFunction |
@@ -324,2 +324,7 @@ "use strict"; | ||
const recursive = optsOrRecursive === true || (optsOrRecursive && optsOrRecursive.recursive) || false; | ||
visitor = visitor | ||
? visitor | ||
: typeof optsOrRecursive === "object" && optsOrRecursive.visitor | ||
? optsOrRecursive.visitor | ||
: undefined; | ||
const cacheKey = `${p} ~ ${recursive}`; | ||
@@ -326,0 +331,0 @@ const cache = visitor ? null : client.scopedCache("enc_list"); |
@@ -6,3 +6,3 @@ /// <reference types="node" /> | ||
export type MobilettoConnection = MobilettoMinimalClient & { | ||
safeList: (path?: string, opts?: MobilettoListOptions) => Promise<MobilettoMetadata[]>; | ||
safeList: (path?: string, opts?: MobilettoListOptions, visitor?: MobilettoVisitor) => Promise<MobilettoMetadata[]>; | ||
safeMetadata: (path: string) => Promise<MobilettoMetadata | null>; | ||
@@ -9,0 +9,0 @@ readFile: (path: string) => Promise<Buffer>; |
@@ -39,3 +39,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
const UTILITY_FUNCTIONS = { | ||
list: (client) => (path, opts) => __awaiter(void 0, void 0, void 0, function* () { | ||
list: (client) => (path, opts, visitor) => __awaiter(void 0, void 0, void 0, function* () { | ||
path || (path = ""); | ||
@@ -55,4 +55,4 @@ const cache = client.scopedCache("list"); | ||
} | ||
const recursive = opts && opts.recursive ? opts.recursive : false; | ||
const visitor = opts && opts.visitor ? opts.visitor : undefined; | ||
const recursive = opts && (opts === true || (opts.recursive ? opts.recursive : false)); | ||
visitor = visitor ? visitor : typeof opts === "object" && opts.visitor ? opts.visitor : undefined; | ||
if (visitor && typeof visitor !== "function") { | ||
@@ -96,5 +96,5 @@ throw new MobilettoError(`list: visitor is not a function: ${typeof visitor}`); | ||
}), | ||
safeList: (client) => (path, opts) => __awaiter(void 0, void 0, void 0, function* () { | ||
const recursive = opts && opts.recursive ? opts.recursive : false; | ||
const visitor = opts && opts.visitor ? opts.visitor : undefined; | ||
safeList: (client) => (path, opts, visitor) => __awaiter(void 0, void 0, void 0, function* () { | ||
const recursive = (opts && opts === true) || (typeof opts === "object" && opts.recursive ? opts.recursive : false); | ||
visitor = visitor ? visitor : typeof opts === "object" && opts.visitor ? opts.visitor : undefined; | ||
try { | ||
@@ -101,0 +101,0 @@ // noinspection JSUnresolvedFunction |
@@ -318,2 +318,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
const recursive = optsOrRecursive === true || (optsOrRecursive && optsOrRecursive.recursive) || false; | ||
visitor = visitor | ||
? visitor | ||
: typeof optsOrRecursive === "object" && optsOrRecursive.visitor | ||
? optsOrRecursive.visitor | ||
: undefined; | ||
const cacheKey = `${p} ~ ${recursive}`; | ||
@@ -320,0 +325,0 @@ const cache = visitor ? null : client.scopedCache("enc_list"); |
@@ -6,3 +6,3 @@ /// <reference types="node" /> | ||
export type MobilettoConnection = MobilettoMinimalClient & { | ||
safeList: (path?: string, opts?: MobilettoListOptions) => Promise<MobilettoMetadata[]>; | ||
safeList: (path?: string, opts?: MobilettoListOptions, visitor?: MobilettoVisitor) => Promise<MobilettoMetadata[]>; | ||
safeMetadata: (path: string) => Promise<MobilettoMetadata | null>; | ||
@@ -9,0 +9,0 @@ readFile: (path: string) => Promise<Buffer>; |
{ | ||
"name": "mobiletto-base", | ||
"version": "2.0.33", | ||
"version": "2.0.34", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "A storage layer that presents a uniform interface to Amazon S3, Backblaze B2, local and other storage systems.", |
159982
3032