Socket
Socket
Sign inDemoInstall

blocpkg

Package Overview
Dependencies
95
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    blocpkg

[WIP] BlocPkg is a reusable code module


Version published
Maintainers
1
Install size
4.70 MB
Created

Readme

Source

BlocPkg

BlocPkg is the module you use to build create a blocpkg.

A blocpkg is a package of blocs of code. A bloc is:

  • a single unit of executable code
  • validates input
  • has tests
  • includes documentation
  • returns bloc types for discovery

Usage

const blocpkg = require('blocpkg')
module.exports = blocpkg({
  docs: fs.readFileSync('./README.md', 'utf-8'),
  blocs: {
    MYBLOC: {
      validate: payload => true,
      exec: payload => Promise.resolve({ text: 'OK'}),
      test: payload => true
    }
  }
})

You can create your bloc then publish it on npm, lets say you call it blocpkg-mybloc

** using the blocpkg prefix will make sure your bloc is discoverable by other bloc users.

Consumer

  const bus = require('nanobus')()
  const mybloc = require('blocpkg-mybloc')
  // no config
  const { blocs } = mybloc.register(null, bus)

  // ...
  const exec = require('bloc-promise')(bus)
  exec(blocs.MYBLOC, { hello: 'world' })
    .then(res => {
      if (res.ok) {
        console.log(res.text)
      }
    })

Getting Started

...

Keywords

FAQs

Last updated on 17 May 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