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

filic

v3.6.5

Published

An Advance File System API

Downloads

92

Readme

An Advance File System API

🏠 Homepage

Install

npm install filic

Ideology

This library aims to simplify how applications access File System via fs API. The Filic API is really simple to use to make your experience great with File System API.

Filic uses object oriented approach to handle files and directories.

Filic's First Priority is to make API type-safe and simple.

Quick Start

import Filic from 'filic';

const fs = Filic.create() // new Filic

const greetings = fs.openFile("greetings.json")

greetings.writeSync([
    "Good Morning",
    "Good Afternoon",
    "Good Night"
])

console.log(greetings.readSync()); // ["Good Morning","Good Afternoon","Good Night"]

API

Types

import * as FilicTypes from 'filic/types/Filic.d';
import * as DirectoryTypes from 'filic/types/Directory.d';
import * as FileTypes from 'filic/types/File.d';

Filic

  • static Filic.create

    Allows to create Filic Instance

        import Filic from 'filic'
    
        const fs = Filic.create(BasePath, autoCreate?);
    • BasePath: string
      • Path of Directory from where every path will be resolved. defaults to process.cwd()
    • autoCreateDir: boolean
      • if true and the BasePath does not exists, it will create the directory. if false client will not force create BasePath directory. defaults to true
  • Filic.openDir

    Opens Directory

        const users = fs.openDir("users", options?);
    • dirname: string
      • Name of Directory that you want open
    • options: FilicTypes.DirectoryOptions
  • Filic.openFile

    Opens File

        const foo = fs.openFile("foo", options?);
    • filename: string
      • Name of File that you want open
    • options: FilicTypes.FileOptions

Directory

const dir = fs.openDir(dirname, options?);
  • dirname: string

  • options: Filic.DirectoryOptions

  • Directory.openDir

    • opens a directory inside the directory
        dir.openDir(path, options?) // returns Directory
    • path: string
      • path of the directory
    • options: FilicTypes.DirectoryOptions
  • Directory.openFile

    • opens a file inside the directory
        dir.openFile(path, options?) // returns Directory
    • path: string
      • path of the file
    • options: FilicTypes.FileOptions
  • Directory.create

    • Create directory
        const dir = fs.openDir("dir", { autoCreate: false });
        dir.createSync(options?) // creates directory
    • options: DirectoryTypes.createSyncOptions
  • Directory.delete

    • Delete Directory
        dir.deleteSelfSync(options?)
    • options: DirectoryTypes.deleteSelfSyncOptions
  • Directory.listRaw

    • Raw Listing
        dir.listRawSync();
  • Directory.list

    • Listing as Entity Instances
        dir.listSync(); // returns (Directory | File)[]
  • Directory.deleteFile

    • delete File inside directory
        dir.deleteFileSync(path, openFileOptions?, deleteOptions?);
    • path: string | File
      • Path/File Instance of the file you want to delete
    • openFileOptions: FilicTypes.FileOptions
    • deleteOptions: FileTypes.deleteSyncOptions
  • Directory.deleteDir

    • delete Directory inside directory
        dir.deleteDirSync(path, openDirOptions?, deleteSelfOptions?);
    • path: string | Directory
      • Path/Directory Instance of the file you want to delete
    • openDirOptions: FilicTypes.DirectoryOptions
    • deleteSelfOptions: FileTypes.deleteSelfSyncOptions
  • Directory.clear

    • delete everything inside
        dir.clearSync()
  • Directory.has

    • checks if file or directory exists inside
        dir.has(path) // returns boolean
    • path: string
      • path of file or directory
  • Directory.copyAll

    • copies all file inside to destination directory
        dir.copyAllSync(destination, copyFileOptions?)
    • destination: Directory
    • copyFileOptions: FileTypes.copyFileOptions
  • Directory.copy

    • copies it self to destination directory
        dir.copySync(destination)
    • destination: Directory
  • Directory.moveAll

    • moves all file inside to destination directory
        dir.moveAllSync(destination)
    • destination: Directory
  • Directory.move

    • moves it self to destination directory
        dir.moveSync(destination)
    • destination: Directory
  • Directory.secondCopy

    • Creates second copy of self in parent directory
        dir.secondCopySync(dirname)
    • dirname: string
  • Directory.search

    • Creates second copy of self in parent directory
        dir.search(searchTerm, searchOptions)
    • searchTerm: string
    • searchOptions: DirectoryTypes.searchOptions
  • Directory.$

    • Executes a command in the directory
        dir.$(command, options?)
    • command: string
    • options: execa.Options
  • Directory.toFilic

    • creates Filic Instance of directory Path as BasePath
        dir.toFilic() // returns Filic
  • get Directory.size

    • returns size of directory in bytes
        dir.size // returns number
  • get Directory.dirname

    • returns directory name of directory
        dir.dirname // returns string

File

const file = fs.openFile(filename, options?);
  • dirname: string

  • options: Filic.FileOptions

  • File.create

    • Create File
        const file = fs.openFile("file", { autoCreate: false });
        file.createSync(options?) // creates File
    • options: FileTypes.createSyncOptions
  • File.delete

    • delete File
        file.deleteSync(options?) // deletes File
    • options: FileTypes.deleteSyncOptions
  • File.readRaw

    • reads content of file and returns as string
        file.readRawSync(options?)
    • options: FileTypes.readRawSyncOptions
  • File.read

    • reads content of file and returns custom string object
        file.readSync(options?) // returns FileTypes.readSyncReturn
    • options: FileTypes.readSyncOptions
  • File.writeRaw

    • writes string to file
        file.writeRawSync(options?)
    • options: FileTypes.writeRawSyncOptions
  • File.write

    • writes to file and tries to parse if not provided string
    • Parser tries to parse JSON, Buffer, number.
        file.writeSync(options?)
    • options: FileTypes.writeSyncOptions
  • File.append

    • Appends string at the end of the file
        file.appendSync(content, readRawSyncOptions?, writeRawSyncOptions?) // returns new content
    • content: string
    • readRawSyncOptions: FileTypes.readRawSyncOptions
    • writeRawSyncOptions: FileTypes.writeRawSyncOptions
  • File.prepend

    • Prepends string at the start of the file
        file.prependSync(content, readRawSyncOptions?, writeRawSyncOptions?) // returns new content
    • content: string
    • readRawSyncOptions: FileTypes.readRawSyncOptions
    • writeRawSyncOptions: FileTypes.writeRawSyncOptions
  • File.delete

    • deletes the file
        file.deleteSync(options?)
    • options: FileTypes.deleteSyncOptions
  • File.copy

    • copies the file to destination directory
        file.copySync(destination, filename?, options?)
    • destination: Directory
    • filename: string
    • options: FileTypes.copySyncOptions
  • File.move

    • moves the file to destination directory
        file.moveSync(destination, filename?, options?)
    • destination: Directory
    • filename: string
    • options: FileTypes.moveSyncOptions
  • File.secondCopy

    • Creates second copy of self in parent directory
        file.secondCopySync(filename)
    • filename: string
  • File.rename

    • rename the name of the file
        file.renameSync(filename)
    • filename: string
  • File.replaceWith

    • replace the file content with given File
        file.replaceWithSync(file)
    • file: File
  • File.update

    • updates file content with callback function
        file.updateSync((content)=>{
            return newContent
        });
    • callback: (content: FileTypes.readSyncReturn) => any
  • get File.size

    • returns size of file in bytes
        file.size // returns number
  • get File.dirname

    • returns name of file
        file.dirname // returns string
  • File.createReadStream

    • returns read stream of file
        file.createReadStream(options?);
    • options: FileTypes.createReadStreamOptions
  • File.createWriteStream

    • returns write stream of file
        file.createWriteStream(options?);
    • options: FileTypes.createWriteStreamOptions
  • File.checksum

    • returns checksum of file
        file.checksum(options?)
    • options: FileTypes.checksumOptions
  • File.encrypt

    • encrypts file and stores the encrypted result in given file.
        file.encrypt(key, file?, options?)
    • key: string
    • file: File
      • by default the result will be stored in the same directory in file with filename <filename>.enc
    • options: FileTypes.encryptOptions
  • File.decrypt

    • decrypts file and stores the decrypted result in given file.
        file.decrypt(key, file?, options?)
    • key: string
    • file: File
      • by default the result will be stored in the same directory in file with filename <filename>.dec
    • options: FileTypes.decryptOptions
  • get File.extension

    • returns extension of file
        file.extension // returns string

Common Methods between Directory and File

  • get absolutePath

    • returns absolute path of directory or file
        dir.absolutePath // string
        // or
        file.absolutePath // string
  • get Filic

    • returns parent filic instance
        dir.Filic // Filic
        // or
        file.Filic // Filic
  • get exists

    • returns if file or directory exists
        dir.exists // boolean
        // or
        file.exists // boolean
  • get parentDir

    • returns parent directory as Directory Instance
        dir.parentDir // Directory
        // or
        file.parentDir // Directory
  • get dirPath

    • returns parent directory absolute path
        dir.dirPath // string
        // or
        file.dirPath // string
  • get stats

    • returns stats of entity
        dir.stats // string
        // or
        file.stats // string

Author

👤 Henil Malaviya

🤝 Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!