Socket
Socket
Sign inDemoInstall

@yarnpkg/fslib

Package Overview
Dependencies
Maintainers
6
Versions
131
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yarnpkg/fslib - npm Package Compare versions

Comparing version 3.0.0-rc.46 to 3.0.0-rc.47

12

lib/algorithms/opendir.d.ts
/// <reference types="node" />
/// <reference types="node" />
import { NoParamCallback } from 'fs';
import { Dir, Dirent, FakeFS } from '../FakeFS';
import { Dir, DirentNoPath, FakeFS } from '../FakeFS';
import { Filename, Path } from '../path';

@@ -13,9 +13,9 @@ export type CustomDirOptions = {

private readonly opts;
constructor(path: P, nextDirent: () => Dirent | null, opts?: CustomDirOptions);
constructor(path: P, nextDirent: () => DirentNoPath | null, opts?: CustomDirOptions);
closed: boolean;
throwIfClosed(): void;
[Symbol.asyncIterator](): AsyncGenerator<Dirent, void, unknown>;
read(): Promise<Dirent>;
read(cb: (err: NodeJS.ErrnoException | null, dirent: Dirent | null) => void): void;
readSync(): Dirent | null;
[Symbol.asyncIterator](): AsyncGenerator<DirentNoPath, void, unknown>;
read(): Promise<DirentNoPath>;
read(cb: (err: NodeJS.ErrnoException | null, dirent: DirentNoPath | null) => void): void;
readSync(): DirentNoPath | null;
close(): Promise<void>;

@@ -22,0 +22,0 @@ close(cb: NoParamCallback): void;

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

name: filename,
path: undefined,
});

@@ -63,0 +64,0 @@ };

@@ -18,18 +18,27 @@ /// <reference types="node" />

};
export type Dirent = Exclude<NodeDirent, 'name'> & {
export type Dirent<T extends Path> = Exclude<NodeDirent, 'name'> & {
name: Filename;
path: T;
};
export type DirentNoPath = Exclude<NodeDirent, 'name'> & {
name: Filename;
};
export type Dir<P extends Path> = {
readonly path: P;
[Symbol.asyncIterator](): AsyncIterableIterator<Dirent>;
[Symbol.asyncIterator](): AsyncIterableIterator<DirentNoPath>;
close(): Promise<void>;
close(cb: NoParamCallback): void;
closeSync(): void;
read(): Promise<Dirent | null>;
read(cb: (err: NodeJS.ErrnoException | null, dirent: Dirent | null) => void): void;
readSync(): Dirent | null;
read(): Promise<DirentNoPath | null>;
read(cb: (err: NodeJS.ErrnoException | null, dirent: DirentNoPath | null) => void): void;
readSync(): DirentNoPath | null;
};
export type OpendirOptions = Partial<{
bufferSize: number;
recursive: boolean;
}>;
export type ReaddirOptions = Partial<{
recursive: boolean;
withFileTypes: boolean;
}>;
export type CreateReadStreamOptions = Partial<{

@@ -79,4 +88,4 @@ encoding: BufferEncoding;

export type StatWatcher = EventEmitter & {
ref?: () => StatWatcher;
unref?: () => StatWatcher;
ref: () => StatWatcher;
unref: () => StatWatcher;
};

@@ -118,22 +127,78 @@ export type ExtractHintOptions = {

abstract realpathSync(p: P): P;
abstract readdirPromise(p: P): Promise<Array<Filename>>;
abstract readdirPromise(p: P, opts?: null): Promise<Array<Filename>>;
abstract readdirPromise(p: P, opts: {
withFileTypes: false;
} | null): Promise<Array<Filename>>;
recursive?: false;
withFileTypes: true;
}): Promise<Array<DirentNoPath>>;
abstract readdirPromise(p: P, opts: {
recursive?: false;
withFileTypes?: false;
}): Promise<Array<Filename>>;
abstract readdirPromise(p: P, opts: {
recursive?: false;
withFileTypes: boolean;
}): Promise<Array<DirentNoPath | Filename>>;
abstract readdirPromise(p: P, opts: {
recursive: true;
withFileTypes: true;
}): Promise<Array<Dirent>>;
}): Promise<Array<Dirent<P>>>;
abstract readdirPromise(p: P, opts: {
recursive: true;
withFileTypes?: false;
}): Promise<Array<P>>;
abstract readdirPromise(p: P, opts: {
recursive: true;
withFileTypes: boolean;
}): Promise<Array<Filename> | Array<Dirent>>;
abstract readdirSync(p: P): Array<Filename>;
}): Promise<Array<Dirent<P> | P>>;
abstract readdirPromise(p: P, opts: {
recursive: boolean;
withFileTypes: true;
}): Promise<Array<Dirent<P> | DirentNoPath>>;
abstract readdirPromise(p: P, opts: {
recursive: boolean;
withFileTypes?: false;
}): Promise<Array<P>>;
abstract readdirPromise(p: P, opts: {
recursive: boolean;
withFileTypes: boolean;
}): Promise<Array<Dirent<P> | DirentNoPath | P>>;
abstract readdirPromise(p: P, opts?: ReaddirOptions | null): Promise<Array<Dirent<P> | DirentNoPath | P>>;
abstract readdirSync(p: P, opts?: null): Array<Filename>;
abstract readdirSync(p: P, opts: {
withFileTypes: false;
} | null): Array<Filename>;
recursive?: false;
withFileTypes: true;
}): Array<DirentNoPath>;
abstract readdirSync(p: P, opts: {
recursive?: false;
withFileTypes?: false;
}): Array<Filename>;
abstract readdirSync(p: P, opts: {
recursive?: false;
withFileTypes: boolean;
}): Array<DirentNoPath | Filename>;
abstract readdirSync(p: P, opts: {
recursive: true;
withFileTypes: true;
}): Array<Dirent>;
}): Array<Dirent<P>>;
abstract readdirSync(p: P, opts: {
recursive: true;
withFileTypes?: false;
}): Array<P>;
abstract readdirSync(p: P, opts: {
recursive: true;
withFileTypes: boolean;
}): Array<Filename> | Array<Dirent>;
}): Array<Dirent<P> | P>;
abstract readdirSync(p: P, opts: {
recursive: boolean;
withFileTypes: true;
}): Array<Dirent<P> | DirentNoPath>;
abstract readdirSync(p: P, opts: {
recursive: boolean;
withFileTypes?: false;
}): Array<P>;
abstract readdirSync(p: P, opts: {
recursive: boolean;
withFileTypes: boolean;
}): Array<Dirent<P> | DirentNoPath | P>;
abstract readdirSync(p: P, opts?: ReaddirOptions | null): Array<Dirent<P> | DirentNoPath | P>;
abstract existsPromise(p: P): Promise<boolean>;

@@ -317,4 +382,8 @@ abstract existsSync(p: P): boolean;

readJsonSync(p: P): any;
writeJsonPromise(p: P, data: any): Promise<void>;
writeJsonSync(p: P, data: any): void;
writeJsonPromise(p: P, data: any, { compact }?: {
compact?: boolean;
}): Promise<void>;
writeJsonSync(p: P, data: any, { compact }?: {
compact?: boolean;
}): void;
preserveTimePromise(p: P, cb: () => Promise<P | void>): Promise<void>;

@@ -321,0 +390,0 @@ preserveTimeSync(p: P, cb: () => P | void): Promise<void>;

@@ -406,7 +406,13 @@ "use strict";

}
async writeJsonPromise(p, data) {
return await this.writeFilePromise(p, `${JSON.stringify(data, null, 2)}\n`);
async writeJsonPromise(p, data, { compact = false } = {}) {
const space = compact
? 0
: 2;
return await this.writeFilePromise(p, `${JSON.stringify(data, null, space)}\n`);
}
writeJsonSync(p, data) {
return this.writeFileSync(p, `${JSON.stringify(data, null, 2)}\n`);
writeJsonSync(p, data, { compact = false } = {}) {
const space = compact
? 0
: 2;
return this.writeFileSync(p, `${JSON.stringify(data, null, space)}\n`);
}

@@ -413,0 +419,0 @@ async preserveTimePromise(p, cb) {

@@ -15,4 +15,5 @@ import * as constants from './constants';

export type { CreateWriteStreamOptions } from './FakeFS';
export type { Dirent, Dir, SymlinkType } from './FakeFS';
export type { Dirent, DirentNoPath, Dir, SymlinkType } from './FakeFS';
export type { MkdirOptions } from './FakeFS';
export type { ReaddirOptions } from './FakeFS';
export type { RmdirOptions } from './FakeFS';

@@ -19,0 +20,0 @@ export type { WatchOptions } from './FakeFS';

@@ -5,3 +5,3 @@ /// <reference types="node" />

import { BigIntStats, Stats } from 'fs';
import { WatchOptions, WatchCallback, Watcher, StatOptions, StatSyncOptions } from './FakeFS';
import { WatchOptions, WatchCallback, Watcher, StatOptions, StatSyncOptions, DirentNoPath } from './FakeFS';
import { FakeFS, MkdirOptions, RmdirOptions, WriteFileOptions, OpendirOptions } from './FakeFS';

@@ -188,22 +188,76 @@ import { Dirent, SymlinkType } from './FakeFS';

readFileSync(p: FSPath<PortablePath>, encoding?: BufferEncoding | null): Buffer | string;
readdirPromise(p: PortablePath): Promise<Array<Filename>>;
readdirPromise(p: PortablePath, opts?: null): Promise<Array<Filename>>;
readdirPromise(p: PortablePath, opts: {
withFileTypes: false;
} | null): Promise<Array<Filename>>;
recursive?: false;
withFileTypes: true;
}): Promise<Array<DirentNoPath>>;
readdirPromise(p: PortablePath, opts: {
recursive?: false;
withFileTypes?: false;
}): Promise<Array<Filename>>;
readdirPromise(p: PortablePath, opts: {
recursive?: false;
withFileTypes: boolean;
}): Promise<Array<DirentNoPath | Filename>>;
readdirPromise(p: PortablePath, opts: {
recursive: true;
withFileTypes: true;
}): Promise<Array<Dirent>>;
}): Promise<Array<Dirent<PortablePath>>>;
readdirPromise(p: PortablePath, opts: {
recursive: true;
withFileTypes?: false;
}): Promise<Array<PortablePath>>;
readdirPromise(p: PortablePath, opts: {
recursive: true;
withFileTypes: boolean;
}): Promise<Array<Filename> | Array<Dirent>>;
readdirSync(p: PortablePath): Array<Filename>;
}): Promise<Array<Dirent<PortablePath> | PortablePath>>;
readdirPromise(p: PortablePath, opts: {
recursive: boolean;
withFileTypes: true;
}): Promise<Array<Dirent<PortablePath> | DirentNoPath>>;
readdirPromise(p: PortablePath, opts: {
recursive: boolean;
withFileTypes?: false;
}): Promise<Array<PortablePath>>;
readdirPromise(p: PortablePath, opts: {
recursive: boolean;
withFileTypes: boolean;
}): Promise<Array<Dirent<PortablePath> | DirentNoPath | PortablePath>>;
readdirSync(p: PortablePath, opts?: null): Array<Filename>;
readdirSync(p: PortablePath, opts: {
withFileTypes: false;
} | null): Array<Filename>;
recursive?: false;
withFileTypes: true;
}): Array<DirentNoPath>;
readdirSync(p: PortablePath, opts: {
recursive?: false;
withFileTypes?: false;
}): Array<Filename>;
readdirSync(p: PortablePath, opts: {
recursive?: false;
withFileTypes: boolean;
}): Array<DirentNoPath | Filename>;
readdirSync(p: PortablePath, opts: {
recursive: true;
withFileTypes: true;
}): Array<Dirent>;
}): Array<Dirent<PortablePath>>;
readdirSync(p: PortablePath, opts: {
recursive: true;
withFileTypes?: false;
}): Array<PortablePath>;
readdirSync(p: PortablePath, opts: {
recursive: true;
withFileTypes: boolean;
}): Array<Filename> | Array<Dirent>;
}): Array<Dirent<PortablePath> | PortablePath>;
readdirSync(p: PortablePath, opts: {
recursive: boolean;
withFileTypes: true;
}): Array<Dirent<PortablePath> | DirentNoPath>;
readdirSync(p: PortablePath, opts: {
recursive: boolean;
withFileTypes?: false;
}): Array<PortablePath>;
readdirSync(p: PortablePath, opts: {
recursive: boolean;
withFileTypes: boolean;
}): Array<Dirent<PortablePath> | DirentNoPath | PortablePath>;
readlinkPromise(p: PortablePath): Promise<PortablePath>;

@@ -210,0 +264,0 @@ readlinkSync(p: PortablePath): PortablePath;

@@ -5,3 +5,3 @@ /// <reference types="node" />

import fs, { BigIntStats, Stats } from 'fs';
import { CreateReadStreamOptions, CreateWriteStreamOptions, Dir, StatWatcher, WatchFileCallback, WatchFileOptions, OpendirOptions } from './FakeFS';
import { CreateReadStreamOptions, CreateWriteStreamOptions, Dir, StatWatcher, WatchFileCallback, WatchFileOptions, OpendirOptions, DirentNoPath } from './FakeFS';
import { Dirent, SymlinkType, StatSyncOptions, StatOptions } from './FakeFS';

@@ -139,22 +139,76 @@ import { BasePortableFakeFS, WriteFileOptions } from './FakeFS';

readFileSync(p: FSPath<PortablePath>, encoding?: BufferEncoding | null): Buffer | string;
readdirPromise(p: PortablePath): Promise<Array<Filename>>;
readdirPromise(p: PortablePath, opts?: null): Promise<Array<Filename>>;
readdirPromise(p: PortablePath, opts: {
withFileTypes: false;
} | null): Promise<Array<Filename>>;
recursive?: false;
withFileTypes: true;
}): Promise<Array<DirentNoPath>>;
readdirPromise(p: PortablePath, opts: {
recursive?: false;
withFileTypes?: false;
}): Promise<Array<Filename>>;
readdirPromise(p: PortablePath, opts: {
recursive?: false;
withFileTypes: boolean;
}): Promise<Array<DirentNoPath | Filename>>;
readdirPromise(p: PortablePath, opts: {
recursive: true;
withFileTypes: true;
}): Promise<Array<Dirent>>;
}): Promise<Array<Dirent<PortablePath>>>;
readdirPromise(p: PortablePath, opts: {
recursive: true;
withFileTypes?: false;
}): Promise<Array<PortablePath>>;
readdirPromise(p: PortablePath, opts: {
recursive: true;
withFileTypes: boolean;
}): Promise<Array<Filename> | Array<Dirent>>;
readdirSync(p: PortablePath): Array<Filename>;
}): Promise<Array<Dirent<PortablePath> | PortablePath>>;
readdirPromise(p: PortablePath, opts: {
recursive: boolean;
withFileTypes: true;
}): Promise<Array<Dirent<PortablePath> | DirentNoPath>>;
readdirPromise(p: PortablePath, opts: {
recursive: boolean;
withFileTypes?: false;
}): Promise<Array<PortablePath>>;
readdirPromise(p: PortablePath, opts: {
recursive: boolean;
withFileTypes: boolean;
}): Promise<Array<Dirent<PortablePath> | DirentNoPath | PortablePath>>;
readdirSync(p: PortablePath, opts?: null): Array<Filename>;
readdirSync(p: PortablePath, opts: {
withFileTypes: false;
} | null): Array<Filename>;
recursive?: false;
withFileTypes: true;
}): Array<DirentNoPath>;
readdirSync(p: PortablePath, opts: {
recursive?: false;
withFileTypes?: false;
}): Array<Filename>;
readdirSync(p: PortablePath, opts: {
recursive?: false;
withFileTypes: boolean;
}): Array<DirentNoPath | Filename>;
readdirSync(p: PortablePath, opts: {
recursive: true;
withFileTypes: true;
}): Array<Dirent>;
}): Array<Dirent<PortablePath>>;
readdirSync(p: PortablePath, opts: {
recursive: true;
withFileTypes?: false;
}): Array<PortablePath>;
readdirSync(p: PortablePath, opts: {
recursive: true;
withFileTypes: boolean;
}): Array<Filename> | Array<Dirent>;
}): Array<Dirent<PortablePath> | PortablePath>;
readdirSync(p: PortablePath, opts: {
recursive: boolean;
withFileTypes: true;
}): Array<Dirent<PortablePath> | DirentNoPath>;
readdirSync(p: PortablePath, opts: {
recursive: boolean;
withFileTypes?: false;
}): Array<PortablePath>;
readdirSync(p: PortablePath, opts: {
recursive: boolean;
withFileTypes: boolean;
}): Array<Dirent<PortablePath> | DirentNoPath | PortablePath>;
readlinkPromise(p: PortablePath): Promise<PortablePath>;

@@ -161,0 +215,0 @@ readlinkSync(p: PortablePath): PortablePath;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodePathFS = void 0;
const tslib_1 = require("tslib");
const buffer_1 = tslib_1.__importDefault(require("buffer"));
const url_1 = require("url");

@@ -32,3 +34,3 @@ const util_1 = require("util");

const str = path.toString();
if (Buffer.byteLength(str) !== path.byteLength)
if (!isUtf8(path, str))
throw new Error(`Non-utf8 buffers are not supported at the moment. Please upvote the following issue if you encounter this error: https://github.com/yarnpkg/berry/issues/4942`);

@@ -41,1 +43,7 @@ return str;

exports.NodePathFS = NodePathFS;
// TODO: remove the fallback when dropping support for Node.js < 18.14.0
function isUtf8(buf, str) {
if (typeof buffer_1.default.isUtf8 !== `undefined`)
return buffer_1.default.isUtf8(buf);
return Buffer.byteLength(str) === buf.byteLength;
}

@@ -35,2 +35,3 @@ declare enum PathType {

rc: Filename;
env: Filename;
};

@@ -37,0 +38,0 @@ export type TolerateLiterals<T> = {

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

rc: `.yarnrc.yml`,
env: `.env`,
};

@@ -33,0 +34,0 @@ exports.npath = Object.create(path_1.default);

@@ -5,3 +5,3 @@ /// <reference types="node" />

import { Stats, BigIntStats } from 'fs';
import { CreateReadStreamOptions, CreateWriteStreamOptions, FakeFS, ExtractHintOptions, WatchFileCallback, WatchFileOptions, StatWatcher, Dir, OpendirOptions } from './FakeFS';
import { CreateReadStreamOptions, CreateWriteStreamOptions, FakeFS, ExtractHintOptions, WatchFileCallback, WatchFileOptions, StatWatcher, Dir, OpendirOptions, DirentNoPath } from './FakeFS';
import { Dirent, SymlinkType, StatSyncOptions, StatOptions } from './FakeFS';

@@ -145,22 +145,76 @@ import { MkdirOptions, RmdirOptions, WriteFileOptions, WatchCallback, WatchOptions, Watcher } from './FakeFS';

readFileSync(p: FSPath<P>, encoding?: BufferEncoding | null): Buffer | string;
readdirPromise(p: P): Promise<Array<Filename>>;
readdirPromise(p: P, opts?: null): Promise<Array<Filename>>;
readdirPromise(p: P, opts: {
withFileTypes: false;
} | null): Promise<Array<Filename>>;
recursive?: false;
withFileTypes: true;
}): Promise<Array<DirentNoPath>>;
readdirPromise(p: P, opts: {
recursive?: false;
withFileTypes?: false;
}): Promise<Array<Filename>>;
readdirPromise(p: P, opts: {
recursive?: false;
withFileTypes: boolean;
}): Promise<Array<DirentNoPath | Filename>>;
readdirPromise(p: P, opts: {
recursive: true;
withFileTypes: true;
}): Promise<Array<Dirent>>;
}): Promise<Array<Dirent<P>>>;
readdirPromise(p: P, opts: {
recursive: true;
withFileTypes?: false;
}): Promise<Array<P>>;
readdirPromise(p: P, opts: {
recursive: true;
withFileTypes: boolean;
}): Promise<Array<Filename> | Array<Dirent>>;
readdirSync(p: P): Array<Filename>;
}): Promise<Array<Dirent<P> | P>>;
readdirPromise(p: P, opts: {
recursive: boolean;
withFileTypes: true;
}): Promise<Array<Dirent<P> | DirentNoPath>>;
readdirPromise(p: P, opts: {
recursive: boolean;
withFileTypes?: false;
}): Promise<Array<P>>;
readdirPromise(p: P, opts: {
recursive: boolean;
withFileTypes: boolean;
}): Promise<Array<Dirent<P> | DirentNoPath | P>>;
readdirSync(p: P, opts?: null): Array<Filename>;
readdirSync(p: P, opts: {
withFileTypes: false;
} | null): Array<Filename>;
recursive?: false;
withFileTypes: true;
}): Array<DirentNoPath>;
readdirSync(p: P, opts: {
recursive?: false;
withFileTypes?: false;
}): Array<Filename>;
readdirSync(p: P, opts: {
recursive?: false;
withFileTypes: boolean;
}): Array<DirentNoPath | Filename>;
readdirSync(p: P, opts: {
recursive: true;
withFileTypes: true;
}): Array<Dirent>;
}): Array<Dirent<P>>;
readdirSync(p: P, opts: {
recursive: true;
withFileTypes?: false;
}): Array<P>;
readdirSync(p: P, opts: {
recursive: true;
withFileTypes: boolean;
}): Array<Filename> | Array<Dirent>;
}): Array<Dirent<P> | P>;
readdirSync(p: P, opts: {
recursive: boolean;
withFileTypes: true;
}): Array<Dirent<P> | DirentNoPath>;
readdirSync(p: P, opts: {
recursive: boolean;
withFileTypes?: false;
}): Array<P>;
readdirSync(p: P, opts: {
recursive: boolean;
withFileTypes: boolean;
}): Array<Dirent<P> | DirentNoPath | P>;
readlinkPromise(p: P): Promise<P>;

@@ -167,0 +221,0 @@ readlinkSync(p: P): P;

@@ -203,3 +203,3 @@ "use strict";

}
async readdirPromise(p, opts) {
readdirPromise(p, opts) {
return this.baseFs.readdirPromise(this.mapToBase(p), opts);

@@ -206,0 +206,0 @@ }

@@ -5,4 +5,5 @@ /// <reference types="node" />

export declare const DEFAULT_MODE: number;
export declare class DirEntry {
export declare class DirEntry<T = undefined> {
name: Filename;
path: T;
mode: number;

@@ -9,0 +10,0 @@ isBlockDevice(): boolean;

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

this.name = ``;
this.path = ``;
this.mode = 0;

@@ -13,0 +14,0 @@ }

{
"name": "@yarnpkg/fslib",
"version": "3.0.0-rc.46",
"version": "3.0.0-rc.47",
"stableVersion": "2.10.3",

@@ -16,3 +16,3 @@ "license": "BSD-2-Clause",

"devDependencies": {
"@yarnpkg/libzip": "^3.0.0-rc.46"
"@yarnpkg/libzip": "^3.0.0-rc.47"
},

@@ -42,4 +42,4 @@ "scripts": {

"engines": {
"node": ">=14.15.0"
"node": ">=18.12.0"
}
}
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