New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

aocudeo

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aocudeo

Process organizer of asynchronous or/and synchronous interdependent code units

latest
Source
npmnpm
Version
4.1.2
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

Aocudeo

github action github action Coverage Status

通过注册位置信息并在其上绑定工作器回调,本包可用于以正确的顺序组织异步或同步代码流程。

An Organizer of Code Units that Depend on Each Other - Aocudeo, can organize your pipelining work with the correct order through the 'Position' registered by 'Workers'.

用例 Usage

加载插件 Loading Plugins

  • 在索引模块中弄个加载器用来加载模块。

    Get a public loader for your plugins in the index.

    import Loader from 'aocudeo/async';
    
    export const loader = new Loader({ reuseable: false });
    
  • 根据插件名称和位置信息插入插件。

    Insert the plugin with its name and dependencies' name.

    loader
      .addPosition('foo', {
        after: ['bar', 'baz'],
        preOf: 'foobar',
      })
      .addWorker('foo', async () => {
        await import('./plugins/foo.ts');
      });
    
  • loader.execute();
    

简单流程工作 Simple Pipeline Work

借以 p-graph 的示例代码为例。

Do what p-graph's sample code do.

import Organizer, { Positions } from 'aocudeo/async';

const workers = new Map([
  ["putOnShirt", { run: () => Promise.resolve("put on your shirt") }],
  ["putOnShorts", { run: () => Promise.resolve("put on your shorts") }],
  ["putOnJacket", { run: () => Promise.resolve("put on your jacket") }],
  ["putOnShoes", { run: () => Promise.resolve("put on your shoes") }],
  ["tieShoes", { run: () => Promise.resolve("tie your shoes") }],
]);

const positions: Positions = [
  // You need to put your shoes on before you tie them!
  ["putOnShoes", "tieShoes"],
  ["putOnShirt", "putOnJacket"],
  ["putOnShorts", "putOnJacket"],
  ["putOnShorts", "putOnShoes"],
];

await new Organizer({ workers, positions }).execute();

流水线处理 Pipeline Process

以下这个用例导出一个用于得到一个穿好衣服的人的函数 getPerson

The following usage exports getPerson to obtain a person dressed properly.

import Organizer from "aocudeo/async";

export interface Person {
  shorts?: 'shorts';
  shoes?: 'shoes';
  tied: boolean;
}

const organizer = new Organizer<Person>()
  .addPositions({
    putOnShoes: 'putOnShorts',
    tieShoes: { postOf: 'putOnShoes' },
  })
  .addWorkers({
    async putOnShorts({ data: person }) {
      person.shorts = await Promise.resolve('shorts');
    },
    async putOnShoes({ data: person }) {
      person.shoes = await Promise.resolve('shoes');
    },
    async tieShoes({ data: person }) {
      person.tied = await Promise.resolve(true);
    },
  });

export async function getPerson() {
  return await organizer.execute({ tied: false });
}
  • p-graph

    功能上与本包类似。

    Functionally similar to this package.

Keywords

pipeline

FAQs

Package last updated on 24 Jul 2023

Did you know?

Socket

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