Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@file-services/utils

Package Overview
Dependencies
Maintainers
4
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@file-services/utils - npm Package Compare versions

Comparing version 5.2.0 to 5.2.1

1

dist/index.d.ts

@@ -1,2 +0,1 @@

export * from './callbackify';
export * from './create-extended-api';

@@ -3,0 +2,0 @@ export * from './set-multi-map';

@@ -13,3 +13,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./callbackify"), exports);
__exportStar(require("./create-extended-api"), exports);

@@ -16,0 +15,0 @@ __exportStar(require("./set-multi-map"), exports);

40

dist/sync-to-async-fs.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.syncToAsyncFs = void 0;
const callbackify_1 = require("./callbackify");
function syncToAsyncFs(syncFs) {

@@ -57,17 +56,32 @@ return {

},
readFile: callbackify_1.callbackify(syncFs.readFileSync),
writeFile: callbackify_1.callbackify(syncFs.writeFileSync),
copyFile: callbackify_1.callbackify(syncFs.copyFileSync),
unlink: callbackify_1.callbackify(syncFs.unlinkSync),
readdir: callbackify_1.callbackify(syncFs.readdirSync),
mkdir: callbackify_1.callbackify(syncFs.mkdirSync),
rmdir: callbackify_1.callbackify(syncFs.rmdirSync),
stat: callbackify_1.callbackify(syncFs.statSync),
lstat: callbackify_1.callbackify(syncFs.lstatSync),
realpath: callbackify_1.callbackify(syncFs.realpathSync),
rename: callbackify_1.callbackify(syncFs.renameSync),
readlink: callbackify_1.callbackify(syncFs.readlinkSync),
readFile: callbackify(syncFs.readFileSync),
writeFile: callbackify(syncFs.writeFileSync),
copyFile: callbackify(syncFs.copyFileSync),
unlink: callbackify(syncFs.unlinkSync),
readdir: callbackify(syncFs.readdirSync),
mkdir: callbackify(syncFs.mkdirSync),
rmdir: callbackify(syncFs.rmdirSync),
stat: callbackify(syncFs.statSync),
lstat: callbackify(syncFs.lstatSync),
realpath: callbackify(syncFs.realpathSync),
rename: callbackify(syncFs.renameSync),
readlink: callbackify(syncFs.readlinkSync),
};
}
exports.syncToAsyncFs = syncToAsyncFs;
function callbackify(fn) {
return (...args) => {
const callback = args.pop();
if (typeof callback !== 'function') {
throw new Error('callback is not a function');
}
try {
const result = fn(...args);
callback(null, result);
}
catch (e) {
callback(e);
}
};
}
//# sourceMappingURL=sync-to-async-fs.js.map
{
"name": "@file-services/utils",
"description": "Common file system utility functions.",
"version": "5.2.0",
"version": "5.2.1",
"main": "dist/index.js",
"dependencies": {
"@file-services/types": "^5.2.0"
"@file-services/types": "^5.2.1"
},

@@ -9,0 +9,0 @@ "files": [

@@ -1,4 +0,3 @@

export * from './callbackify';
export * from './create-extended-api';
export * from './set-multi-map';
export * from './sync-to-async-fs';

@@ -1,3 +0,7 @@

import type { IBaseFileSystemSync, IBaseFileSystemAsync, IBaseFileSystemPromiseActions } from '@file-services/types';
import { callbackify } from './callbackify';
import type {
IBaseFileSystemSync,
IBaseFileSystemAsync,
IBaseFileSystemPromiseActions,
CallbackFnVoid,
} from '@file-services/types';

@@ -62,3 +66,3 @@ export function syncToAsyncFs(syncFs: IBaseFileSystemSync): IBaseFileSystemAsync {

readdir: callbackify(syncFs.readdirSync) as IBaseFileSystemAsync['readdir'],
mkdir: callbackify(syncFs.mkdirSync) as IBaseFileSystemAsync['mkdir'],
mkdir: (callbackify(syncFs.mkdirSync) as unknown) as IBaseFileSystemAsync['mkdir'],
rmdir: callbackify(syncFs.rmdirSync),

@@ -72,1 +76,16 @@ stat: callbackify(syncFs.statSync),

}
function callbackify<T extends unknown[], R>(fn: (...args: [...T]) => R) {
return (...args: [...T, (error: Error | null, value: R) => void]): void => {
const callback = args.pop() as (error: Error | null, value: R) => void;
if (typeof callback !== 'function') {
throw new Error('callback is not a function');
}
try {
const result = fn(...((args as unknown) as [...T]));
callback(null, result);
} catch (e) {
(callback as CallbackFnVoid)(e);
}
};
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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