🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

@cubelets/replug

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cubelets/replug

A lightweight plugin manager

0.2.1
latest
npm
Version published
Weekly downloads
0
-100%
Maintainers
2
Weekly downloads
 
Created
Source

replug

A lightweight plugin manager for the Map/Reduce and the Observable world

Install

Using npm:

npm install --save @cubelets/replug

or using yarn:

yarn add @cubelets/replug --dev

Usage

You want to use plugins to extend the functionality of your code. Given a list of plugins, your application will first initialise and then run them.

Hello World

import {examplePlugin} from './examplePlugin.js
const pluginsList = [examplePlugin]
const config = {
	lang: 'en'
}
const plugins = replug(pluginsList, config)

const initialData = 'Hello'
const result = plugins('message', initialData) // 'Hello, world'

Each plugin exports a hash of hooks that can process input and return an output.
examplePlugin.js

export default { 'exampleMessage': config => data => ${data}, world! }

Content Moderation

You want to use plugins to moderate content before rendering

module.js

import {moderation} from './moderation.js
const pluginsList = [moderation]
const config = { }
const plugins = replug(pluginsList, config)

const initialData[] = await fetch('/api/getMessages').then(x=>x.json())
const result = plugins('moderate', data)

moderation.js

export default {
	'moderate': config => {
		const blackList = await fetch('/word-blacklist').then(x=>x.json())
		return data[] => data.map(str => blackList.forEach(word => str.replace(word, '###redacted###')))
	}
}

### HTML Plugins


### Duplex streams via Observables (like a messagebus)

Keywords

javascript

FAQs

Package last updated on 03 Mar 2021

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