Giter VIP home page Giter VIP logo

node-unrar's Introduction

node-rar

Native NodeJS rar addon.

This library is inspired by https://github.com/davidcroda/node-rar and the original library. I needed a native unrar addon that worked with the new versions of node. I also updated the addon to be able to process an archive asynchronously.

Install

npm install @fknop/node-unrar

It's published under the @fknop scope to avoid using a name like node-unrar2 or something like that.

API

OpenMode

  • List = 0,
  • Extract = 1

RarResult

  • name: the archive name
  • files: an array of files in the archive (see RarOptions.humanResults for more details)

RarOptions

  • openMode: the archive open mode
  • dest: the destination directory for extraction (ignored in list mode).
  • password: the archive password
  • humanResults: instead of an array of raw string names, display the files as a tree

Without humanResults:

{
  name: 'archive.rar',
  files: [
    'dir',
    'dir/file1',
    'dir/file2',
    'dir/file3',
    'dir/dir2/file4',
    'dir/dir2/file5',
    'file'
  ]
}

With humanResults:

{
  name: 'archive.rar',
  files: {
    'dir': {
      'file1': {},
      'file2': {},
      'file3': {},
      'dir2': {
        'file4': {},
        'file5': {}
      }
    },
    'file': {}
  }
}

RarCallback

RarCallback is a simple node callback (err, results) => { ... }.

processArchive(path: string, options?: RarOptions|RarCallback, cb?: RarCallback): Promise<RarResult>|void

Process an archive asynchronously. By default, it lists files.

  • path: the path of the archive
  • options: The options, or the callback if no options are needed
  • cb: the callback if options are needed

If no callback is provided, a promise will be returned.

list(path: string, options?: RarOptions|RarCallback, cb?: RarCallback): Promise<RarResult>|void

Alias for processArchive with OpenMode.List.

extract(path: string, options?: RarOptions|RarCallback, cb?: RarCallback): Promise<RarResult>|void

Alias for processArchive with OpenMode.Extract.

processArchiveSync(path: string, options?: RarOptions): RarResult

Process an archive synchronously. By default, it lists files. If an error occurs, it will throw an exception.

listSync(path: string, options?: RarOptions): RarResult

Alias for processArchiveSync with OpenMode.List.

extractSync(path: string, options?: RarOptions): RarResult

Alias for processArchiveSync with OpenMode.Extract.

Todo

  • Tests

node-unrar's People

Contributors

fknop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

node-unrar's Issues

I can not import the module

I'm trying to import the module and I get this message:

Details:Error: Error relocating /src/node_modules/@fknop/node-unrar/build/Release/node-unrar.node: __swprintf_chk: symbol not found

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.