Socket
Socket
Sign inDemoInstall

crawler.plugins.common

Package Overview
Dependencies
145
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    crawler.plugins.common

爬虫公共代码


Version published
Weekly downloads
10
increased by150%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

爬虫common

封装了seneca的一些decorator

  1. add

自动调用seneca的add方法

  1. init

自动调用seneca的init:plugin方法

  1. plugin

定义一个插件

demo

@Plugin("math-plugin", {})
@injectable()
export class MathPlugin {
    constructor( @inject(aaa) private aa: aaa) {
        // aa.aaaa.push("234234");
    }

    @Init()
    init(a: any, b: any, c: any): Promise<any> {
        return new Promise(async (resolve: (value?: any | PromiseLike<any>) => void, reject: (reason?: any) => void) => {
            await bluebird.delay(2000);

            resolve();
        });
    }

    @Wrap("role:math")
    wrap(msg: any) {
        if (!msg.ddd) {
            msg.ddd = 10;
        }

        console.log(this.aa.aaaa.length);
    }

    @Add("role:math,cmd:add")
    add(msg: any): { data: number } {
        this.aa.aaaa.push("234234");
        return { data: msg.left + msg.right };
    }

    @Add("role:math,cmd:remove")
    async remove(msg: any): Promise<{ data: number }> {
        this.aa.aaaa.push("234234");
        console.log(this.aa.aaaa.length);

        if (!msg.ddd) {
            throw new Error("缺少参数!");
        }

        return { data: msg.left - msg.right + msg.ddd };
    }
}

Keywords

FAQs

Last updated on 25 Sep 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc