GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - cloudcmd/node-fileop: file operations emitter middleware

BranchesTags
Open more actions menu

Latest commit

 

History

282 Commits
282 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
client
client
 
 
server
server
 
 
test
test
 
 
.babelrc.json
.babelrc.json
 
 
.browserslistrc
.browserslistrc
 
 
.eslintrc.json
.eslintrc.json
 
 
.gitignore
.gitignore
 
 
.madrun.js
.madrun.js
 
 
.npmignore
.npmignore
 
 
.nycrc.json
.nycrc.json
 
 
.putout.json
.putout.json
 
 
ChangeLog
ChangeLog
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
package.json
package.json
 
 
webpack.config.js
webpack.config.js
 
 

Repository files navigation

Fileop License NPM version Build Status

File operations emitter middleware.

Install

npm i @cloudcmd/fileop

Client

Could be loaded from url /fileop/fileop.js.

fileop([options, ]): Promise

Initialize operator.

  • options:
    • prefix - prefix of fileop (/fileop by default)
    • socketPrefix - prefix of socket.io (`/fileop' by default)

Returns operator in callback.

operator

It is EventEmitter from the inide produce next types of events:

  • error
  • progress
  • file
  • end

Supports next types of operations:

  • operator.copy(from, to, names)
  • operator.move(from, to, names)
  • operator.remove(from, names)
  • operator.extract(from, to)
  • operator.zip(from, to)
  • operator.tar(from, to)
const prefix = '/fileop';
const operator = await fileop({
    prefix,
});

const from = '/';
const to = '/tmp';

const names = ['bin'];

const progress = (value) => {
    console.log('progress:', value);
};

const end = (op) => () => {
    console.log('end');
    op.removelistener('progress', progress);
    op.removelistener('end', end);
};

const error = (op) => (data) => {
    const msg = `${data}\n continue?`;
    const is = confirm(msg);
    
    if (is)
        return op.continue();
    
    op.abort();
};

const op = await operator.copy(from, to, names);

op.on('progress', progress);
op.on('end', end(op));
op.on('error', error(op));

Server

import http from 'node:http';
import {fileop} from 'fileop';
import express from 'express';
import {Server} from 'socket.io';

const app = express();
const port = 1337;
const server = http.createServer(app);
const socket = new Server(server);

server.listen(port);

app.use(fileop({
    prefix: '/fileop', /* default */
}));

fileop.listen(socket, {
    // default
    prefix: '/fileop', // string or a function
    root: '/',
    auth: (accept, reject) => (username, password) => {
        if (username === 'root' && password === 'toor')
            accept();
        
        reject();
    },
});

Related

  • Spero - file copy emitter middleware based on socket.io and copymitter
  • Remedy - emitting middleware for file removing
  • Ishtar - pack and extract .tar.gz archives middleware
  • Omnes - extract zip, gz, tar, tar.gz, tgz archives middleware
  • Salam - pack and extract zip archives middleware

License

MIT

About

file operations emitter middleware

Topics

cloudcmdcopyexpressjsextractnodejsnodejs-modulesremovesocket-iotarzip

Resources

Readme
MIT license
Activity
Custom properties

Stars

3 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.