changedrive-cli
TypeScript icon, indicating that this package has built-in type declarations

2.0.3 • Public • Published

changedrive-cli (USB U盘变化监听 命令行软件)

支持的平台(Supported platforms) :win(Support) mac(preparation) linux(preparation)
使用的编程语言(Programming languages used) : rust typescript

如何使用(Operation method)

// require
let changeDrive = require("changedrive-cli").default;
let {changeDrive} = require("changedrive-cli");

// ejs 
import changeDrive from "changedrive-cli";
import {changeDrive} from "changedrive-cli";

// typescript 
import changeDrive = require("changedrive-cli").default;
import {changeDrive} = require("changedrive-cli");
import changeDrive from "changedrive-cli";
import {changeDrive} from "changedrive-cli";



changeDrive.changeDrive(function(Type,name,id,DriveContent){
	//做点什么事(Do something)
    console.log(Type,name,id,DriveContent);
     // start USB#VI... 60A...2F2 {event: 'start'... product_id: 49284...}
     // add USB#VI... 60A4....7402F2 {event: 'add'... product_id: 49284...}
});

changeDrive.on("add",console.log)
// USB#VID_0951&PID_1665#****fb951ed} 60A4****402F2 {event:...}

changeDrive.on("remove",console.log)
// USB#VID_0951&PID_1665#****fb951ed} 60A4****402F2 {event:...}

// 设置一个系列号(id)的解析方法
changeDrive.SetMatchIdFun(name=>{
    return (name||"") + "{:123456789:}";
})

// 系列号将变成:(id format redirect)
// 0501aa8fa{:123456789:}

//销毁监听并GC掉绑定(Destroy the listener and unbind it)
changeDrive.stop();

/// log =>exit null null

/**
 * @zh 枚举所有当前存在的驱动器(实时)
 * @en Enumerate all drives(Real-time)
 * @time 50.3291015625 ms
 */
changeDrive.forEach((id,DriveContent,index)=>{
    console.log(id,DriveContent,index);
    // 00E04...101 USB\...101 {event: 'add'... product_id: 49284...} 0
})

changeDrive.getDriveList 
// {event: 'forEach',description: 'Realtek',id: '00E04' ....}[]

Package Sidebar

Install

npm i changedrive-cli

Weekly Downloads

0

Version

2.0.3

License

MIT

Unpacked Size

401 kB

Total Files

14

Last publish

Collaborators

  • kihlh