npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-promfs

v3.7.0

Published

'fs' object extensions & promisifications

Downloads

20

Readme

node-promfs

'fs' object extensions & promisifications

Build status Coverage status Dependency status Dev dependency status Issues Pull requests

Installation

$ npm install node-promfs

Features

  • promise all fs asynchronous functions

  • checks for file & directory existence, with synchrone & asynchrone versions

  • extract directory's files, with synchrone & asynchrone versions

  • create & delete directories recursively, with synchrone & asynchrone versions

  • concat files content in a string or a file, with synchrone & asynchrone versions

  • copy files, with synchrone & asynchrone versions

Doc

$ npx node-promfs mkdirp <file: string> <?mode: number>

$ npx node-promfs rmdirp <file: string>

you can use following method by replacing uppercase by lowercase with "-" before (ex : directoryToFile => "directory-to-file") Array arguments "files-to-file", "files-to-string", etc... is just list of strings (ex : [ "1", "2" ] => "1" "2")

type tError = ReferenceError|TypeError|Error|null;
type tCallback = (err: tError, data: any) => void;
interface iReadJSONOptions {
  "encoding"?: string;
  "flag"?: string;
  "signal"?: AbortSignal;
}

interface iWriteJSONOptions extends iReadJSONOptions {
  "mode"?: number;
  "replacer"?: (k, v) => any;
  "space"?: string|number|null;
}

type tReadJSONOptions = string|iReadJSONOptions|null;
type tWriteJSONOptions = string|iWriteJSONOptions|null;

-- Extended --

in "separator" parameter, you can use "{{filename}}" pattern, it will be replaced by the file's basename (ex : separator = "\r\n\r\n--- {{filename}} ---\r\n\r\n")

[isFile] : does the file exists and is a regular file ?

  • isFile(file: string, callback: (err: tError, exists: boolean) => void): void
  • isFileSync(file: string): boolean
  • isFileProm(file: string): Promise<boolean>

[isDirectory] : does the file exists and is a directory ?

  • isDirectory(dir: string, callback: (err: tError, exists: boolean) => void): void
  • isDirectorySync(dir: string): boolean
  • isDirectoryProm(dir: string): Promise<boolean>

[copyFile] : copy a file with streams (copy then control with isFile)

  • copyFile(origin: string, target: string, callback: (err: tError) => void): void
  • copyFileSync(origin: string, target: string): void
  • copyFileProm(origin: string, target: string): Promise<void>

[extractFiles] : return only files from a directory

  • extractFiles(dir: string, callback: (err: tError, files: Array<string>) => void): void
  • extractFilesSync(dir: string): Array<string>
  • extractFilesProm(dir: string): Promise<Array<string>>

[writeJSONFile] : stringify JSON and writeFile

  • writeJSONFile(file: string, data: any, options: tCallback | tWriteJSONOptions, callback?: tCallback): void
  • writeJSONFileSync(file: string, data: any, options?: tReadJSONOptions): void
  • writeJSONFileProm(file: string, data: any, options?: tReadJSONOptions): Promise<void>

[readJSONFile] : readFile and parse JSON

  • readJSONFile(file: string, opts: tCallback | tReadJSONOptions, callback?: tCallback): void
  • readJSONFileSync(file: string, opts?: tReadJSONOptions): any
  • readJSONFileProm(file: string, opts?: tReadJSONOptions) : Promise<any>

[mkdirp] : recursively create a directory

  • The arguments are the same as the official documentation's ones for mkdir & mkdirSync
  • mkdirp(path: string, callback: (err: tError, data: any) => void): void
  • mkdirp(path: string, mode: number, callback: (err: tError, data: any) => void): void
  • mkdirpSync(path: string, mode?: number): void
  • mkdirpProm(path: string, mode?: number): Promise<void>

[rmdirp] : recursively delete a directory

  • rmdirp(path: string, callback: (err: tError) => void): void
  • rmdirpSync(path: string): void
  • rmdirpProm(path: string): Promise<void>

[filesToStream] : converge files content in a Readable stream

  • filesToStream(files: Array<string>, callback: (err: tError, Transform) => void): void
  • filesToStream(files: Array<string>, separator: string, callback: (err: tError, data: Transform) => void): void
  • filesToStreamSync(path: string, separator?: string): Transform
  • filesToStreamProm(path: string, separator?: string): Promise<Transform>

[filesToString] : concat files content in a string

  • filesToString(files: Array<string>, callback: (err: tError, data: string) => void): void
  • filesToString(files: Array<string>, separator: string, callback: (err: tError, data: string) => void): void
  • filesToStringSync(files: Array<string>, separator?: string): string
  • filesToStringProm(files: Array<string>, separator?: string): Promise<string>

[filesToFile] : concat files content in a file with streams

  • filesToFile(files: Array<string>, file: string, callback: (err: tError) => void): void
  • filesToFile(files: Array<string>, file: string, separator: string, callback: (err: tError) => void): void
  • filesToFileSync(files: Array<string>, file: string, separator?: string): void
  • filesToFileProm(files: Array<string>, file: string, separator?: string): Promise<void>

[directoryToStream] : converge directory's files content in a Readable stream

  • directoryToStream(directory: string, file: string, callback: (err: tError, data: Transform) => void): void
  • directoryToStream(directory: string, separator: string, callback: (err: tError, data: Transform) => void): void
  • directoryToStreamSync(directory: string, file: string, separator?: string): Transform
  • directoryToStreamProm(directory: string, file: string, separator?: string): Promise<Transform>

[directoryToString] : concat directory's files content in a string

  • directoryToString(directory: string, callback: (err: tError, data: Transform) => void): void
  • directoryToString(directory: string, separator: string, callback: (err: tError, data: Transform) => void): void
  • directoryToStringSync(directory: string, separator?: string): Transform
  • directoryToStringProm(directory: string, separator?: string): Promise<Transform>

[directoryToFile] : concat directory's files content in a file

  • directoryToFile(directory: string, file: string, callback: (err: tError) => void): void
  • directoryToFile(directory: string, file: string, separator: string, callback: (err: tError) => void)
  • directoryToFileSync(directory: string, file: string, separator?: string): void
  • directoryToFileProm(directory: string, file: string, separator?: string): Promise<void>

-- Classical --

  • The arguments are the same as the official documentation's ones
  • "then" data are the same as the callbacks' ones
  • all the methods cannot be tested (too much arguments)
  • accessProm(): Promise -> tested
  • appendFileProm(): Promise -> tested
  • chmodProm(): Promise -> tested
  • chownProm(): Promise -> tested
  • closeProm(): Promise -> tested
  • fchmodProm(): Promise
  • fchownProm(): Promise
  • fdatasyncProm(): Promise
  • fstatProm(): Promise
  • fsyncProm(): Promise
  • ftruncateProm(): Promise
  • futimesProm(): Promise
  • linkProm(): Promise
  • lstatProm(): Promise
  • mkdirProm(): Promise -> tested
  • mkdtempProm(): Promise
  • openProm(): Promise -> tested
  • readdirProm(): Promise -> tested
  • readFileProm(): Promise -> tested
  • realpathProm(): Promise -> tested
  • renameProm(): Promise -> tested
  • rmdirProm(): Promise -> tested
  • statProm(): Promise
  • truncateProm(): Promise
  • unlinkProm(): Promise -> tested
  • utimesProm(): Promise
  • writeProm(): Promise
  • writeFileProm(): Promise -> tested

Import

Native

const fs = require("node-promfs");
const { readJSONFileProm } = require("node-promfs");

Typescript

import fs = require("node-promfs");

Tests

$ git clone git://github.com/Psychopoulet/node-promfs.git
$ cd ./node-promfs
$ npm install
$ npm run-script tests

License

ISC