npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@augejs/provider-scanner

v1.0.7

Published

`provider-scanner` is a scan framework for nodejs.

Downloads

80

Readme

npm version

https://augejs.github.io/provider-scanner/

provider-scanner is a Provider's metadata scan framework for nodeJs which is base on javascript Reflect.defineMetadata.

Installation

You can get the latest release and the type definitions using npm:

npm install @augejs/provider-scanner reflect-metadata --save

What is a Provider

To be honest, I don't know what a Provider exactly is. Maybe an Entity, a File, a structure, a component, a service, or a string. What ever, it can be defined with kinds of metadata.

The provider-scanner just focus on the scan process with kinds of metadata. Finally the result is what we want.

import { Metadata } from '@augejs/provider-scanner';

const employee = {
  fullName: 'xxxx',
  age: 12,
  headImageUrl: 'xxxx',
};
// here the employee structure consider as a provider

Metadata.defineMetadata(Metadata, 
{
  reporter: 'xxx',
  messageOwner: 'xxx'
}, employee);

// here we add a metadata to the employee structure.

A Provider can store kinds of metadata by using Reflect.defineMetadata. (Also this behavior can be used by Decorator).

provider model

Organize Provider

Let's take a look at below diagram, it a tree of Provider, I think the tree structure is a good idea to organize things, thinking about the user-interface elements, it's a tree structure. thinking about the computer file system, it's a tree structure.

provider tree

If the diagram means a school then the Provider means teachers and students.

If the diagram means a program then the Provider means logic unit.

ParentMetadata

Here is a Parent Metadata which can define the children metadata to Provider

import { ParentMetadata } from '@augejs/provider-scanner';

const employee = {
  fullName: 'xxxx',
  age: 12,
  headImageUrl: 'xxxx',
};
// here the employee structure consider as a provider

const manager = {
  fullName: 'xxxx',
  age: 54,
  headImageUrl: 'xxxx',
};
// here the manager structure consider as a provider

ParentMetadata.defineMetadata( 
[
  employee,
], manager);
// here we add the employee to the manager as this child node.

// we can easily use the `ParentMetadata` to build a tree structure which is composite of `providers` just the above diagram.

HookMetadata

Here is a HookMetadata which can define the metadata hooks to Provider. And the hook will execute in scan process.

hook-metadata

Single Provider Hooks Execute Model

Go back to Provider , Maybe we need do some logic process on Provider maybe process data, create new object, etc. The below diagram show the idea. Each logic process is call a hook, hook can be nested, and all hooks of Provider share the data structure ScanNode which can store some process results for current Provider

provider-hook

The hook execute order is A hook1-pre -> A hook2-pre -> A hook2-after->A hook1-after

The hook idea here is from KOA, it just a middleware in KOA.

async (context: any, next:Function) {
  // some logic before
  await next();
  // some logic after
}

The context here can get the current process ScanNode.

Onion

Maybe this diagram can explain how a middleware works.

Sibling Provider Hooks Execute Model

Provider C is sibling of provide B

sibling-provider-hook

The hook execute order is B hooks -> C hooks

Parent Provider Hooks Execute Model

Provider A is parent of Provider B

parent-provider-hook

The hook execute order is is A hook1-pre -> A hook2-pre -> B hooks -> A hook2-after->A hook1-after

the B hooks seem is inner A

So finally, the scanner go through the provider tree and execute all the hooks around the provide. You can do every thing you want base on provider metadata and hooks to build anything.

scan-execute-order

This is the Provide Tree(above diagram) scan execute order. It's like program function execute process right?