Socket
Socket
Sign inDemoInstall

memfs

Package Overview
Dependencies
Maintainers
1
Versions
152
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

memfs - npm Package Compare versions

Comparing version 4.8.2 to 4.9.0

11

lib/crud/types.d.ts

@@ -45,2 +45,9 @@ export interface CrudApi {

/**
* Iterates over all resources of a collection.
*
* @param collection Type of the resource, collection name.
* @returns Iterator of resources of the given type.
*/
scan: (collection: CrudCollection) => AsyncIterableIterator<CrudCollectionEntry>;
/**
* Fetches a list of resources of a collection, and sub-collections.

@@ -78,5 +85,1 @@ *

}
export interface CrudScanResult {
cursor: string | '';
list: CrudCollectionEntry[];
}

@@ -13,4 +13,5 @@ import type * as crud from '../crud/types';

readonly drop: (collection: crud.CrudCollection, silent?: boolean) => Promise<void>;
readonly scan: (collection: crud.CrudCollection) => AsyncIterableIterator<crud.CrudCollectionEntry>;
readonly list: (collection: crud.CrudCollection) => Promise<crud.CrudCollectionEntry[]>;
readonly from: (collection: crud.CrudCollection) => Promise<crud.CrudApi>;
}

@@ -121,27 +121,47 @@ "use strict";

};
this.scan = function (collection) {
return tslib_1.__asyncGenerator(this, arguments, function* () {
var _a, e_2, _b, _c;
(0, util_2.assertType)(collection, 'scan', 'crudfs');
const [dir] = yield tslib_1.__await(this.getDir(collection, false));
try {
for (var _d = true, _e = tslib_1.__asyncValues(dir.entries()), _f; _f = yield tslib_1.__await(_e.next()), _a = _f.done, !_a; _d = true) {
_c = _f.value;
_d = false;
const [id, handle] = _c;
if (handle.kind === 'file') {
yield yield tslib_1.__await({
type: 'resource',
id,
});
}
else if (handle.kind === 'directory') {
yield yield tslib_1.__await({
type: 'collection',
id,
});
}
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (!_d && !_a && (_b = _e.return)) yield tslib_1.__await(_b.call(_e));
}
finally { if (e_2) throw e_2.error; }
}
});
};
this.list = async (collection) => {
var _a, e_2, _b, _c;
(0, util_2.assertType)(collection, 'drop', 'crudfs');
const [dir] = await this.getDir(collection, false);
var _a, e_3, _b, _c;
const entries = [];
try {
for (var _d = true, _e = tslib_1.__asyncValues(dir.entries()), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) {
for (var _d = true, _e = tslib_1.__asyncValues(this.scan(collection)), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) {
_c = _f.value;
_d = false;
const [id, handle] = _c;
if (handle.kind === 'file') {
entries.push({
type: 'resource',
id,
});
}
else if (handle.kind === 'directory') {
entries.push({
type: 'collection',
id,
});
}
const entry = _c;
entries.push(entry);
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
catch (e_3_1) { e_3 = { error: e_3_1 }; }
finally {

@@ -151,3 +171,3 @@ try {

}
finally { if (e_2) throw e_2.error; }
finally { if (e_3) throw e_3.error; }
}

@@ -154,0 +174,0 @@ return entries;

@@ -20,4 +20,5 @@ import type { FsPromisesApi } from '../node/types';

readonly drop: (collection: crud.CrudCollection, silent?: boolean) => Promise<void>;
readonly scan: (collection: crud.CrudCollection) => AsyncIterableIterator<crud.CrudCollectionEntry>;
readonly list: (collection: crud.CrudCollection) => Promise<crud.CrudCollectionEntry[]>;
readonly from: (collection: crud.CrudCollection) => Promise<crud.CrudApi>;
}

@@ -156,33 +156,53 @@ "use strict";

};
this.scan = function (collection) {
return tslib_1.__asyncGenerator(this, arguments, function* () {
var _a, e_1, _b, _c;
(0, util_2.assertType)(collection, 'scan', 'crudfs');
const dir = yield tslib_1.__await(this.checkDir(collection));
const dirents = (yield tslib_1.__await(this.fs.readdir(dir, { withFileTypes: true })));
try {
for (var _d = true, dirents_1 = tslib_1.__asyncValues(dirents), dirents_1_1; dirents_1_1 = yield tslib_1.__await(dirents_1.next()), _a = dirents_1_1.done, !_a; _d = true) {
_c = dirents_1_1.value;
_d = false;
const entry = _c;
if (entry.isFile()) {
yield yield tslib_1.__await({
type: 'resource',
id: '' + entry.name,
});
}
else if (entry.isDirectory()) {
yield yield tslib_1.__await({
type: 'collection',
id: '' + entry.name,
});
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (!_d && !_a && (_b = dirents_1.return)) yield tslib_1.__await(_b.call(dirents_1));
}
finally { if (e_1) throw e_1.error; }
}
});
};
this.list = async (collection) => {
var _a, e_1, _b, _c;
(0, util_2.assertType)(collection, 'drop', 'crudfs');
const dir = await this.checkDir(collection);
const dirents = (await this.fs.readdir(dir, { withFileTypes: true }));
var _a, e_2, _b, _c;
const entries = [];
try {
for (var _d = true, dirents_1 = tslib_1.__asyncValues(dirents), dirents_1_1; dirents_1_1 = await dirents_1.next(), _a = dirents_1_1.done, !_a; _d = true) {
_c = dirents_1_1.value;
for (var _d = true, _e = tslib_1.__asyncValues(this.scan(collection)), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) {
_c = _f.value;
_d = false;
const entry = _c;
if (entry.isFile()) {
entries.push({
type: 'resource',
id: '' + entry.name,
});
}
else if (entry.isDirectory()) {
entries.push({
type: 'collection',
id: '' + entry.name,
});
}
entries.push(entry);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (!_d && !_a && (_b = dirents_1.return)) await _b.call(dirents_1);
if (!_d && !_a && (_b = _e.return)) await _b.call(_e);
}
finally { if (e_1) throw e_1.error; }
finally { if (e_2) throw e_2.error; }
}

@@ -189,0 +209,0 @@ return entries;

{
"name": "memfs",
"version": "4.8.2",
"version": "4.9.0",
"description": "In-memory file-system with Node's fs API.",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc