🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

pear-opstream

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pear-opstream

Pear operations stream base class

latest
Source
npmnpm
Version
1.2.0
Version published
Weekly downloads
152
-54.63%
Maintainers
1
Weekly downloads
 
Created
Source

Opstream

Pear operations stream base class

Readable stream wrapper around an async op(params) function.

Emits status object data events, at minimum:

  • zero or one { tag: 'error', ... } objects - logical errors from op, not stream errors
  • exactly one { tag: 'final', ... } object

For convenience consumer counterpart library see pear-opwait.

Install

npm install pear-opstream

API: new Opstream(op, params, done?)

Create a new Opstream Instance.

Parameters

  • op: (params) => Promise<any> Async function called once when the stream eagerly reads.

  • params: Object Input passed into op.

    • if `params.linka is present, it is normalized at origin:
      params.link = plink.normalize(params.link)
      
  • done?: () => void Optional callback once emitted after the final chunk and stream ends.

Emitted data status objects

  • if op rejects.

    {
      tag: 'error',
      data: { stack, code, message, success: false, info }
    }
    
  • final status object always emitted exactly once:

    {
      tag: 'final',
      data: { success, ...final }
    }
    

Custom final

The { tag: 'final', ... } status object merges with instance.final.

Set this.final in subclass to declare final return value of opstream.

this.final = { result: 42 }

final chunk:

{
  tag: 'final',
  data: { success: true, result: 42 }
}

License

Apache-2.0

FAQs

Package last updated on 05 Jun 2026

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