whistle-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

whistle-sdk

为 whistle 封装的 npm 库,用于在模块中调用。

安装

$ npm install whistle-sdk --save

示例:

const WhistleSDK = require('../').default;

(async () => {
  const whistleSDK = new WhistleSDK();

  // 启动
  await whistleSDK.start();
  
  // 设置代理规则
  await whistleSDK.setRules({
    forceOverride: true,
    saveDir: path.join(__dirname, 'tmp'),
    fileName: 'test.whistle.js',
    getWhistleRules: () => {
      return {
        name: 'mmm2',
        rules: [
          'now.qq.com 1.2.3.4',
        ].join('\n'),
      };
    },
    handleRuleContent: (ruleContent, saveDir) => {
      return ruleContent + '\n# ' + saveDir;
    },
  });
  
  // 停止
  setTimeout(async () => {
    await whistleSDK.stop();
  }, 6000);
})();

TODO

自定义存储目录文件在 ~/.WhistleAppData/.whistle/custom_dirs ,应该要提供一个方法用于清理或者备份它。

Readme

Keywords

Package Sidebar

Install

npm i whistle-sdk

Weekly Downloads

1

Version

0.2.0

License

MIT

Unpacked Size

36.6 kB

Total Files

29

Last publish

Collaborators

  • helinjiang