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

suspend-resource

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

suspend-resource

Ready resource with suspend/resume support

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
5.1K
91.26%
Maintainers
1
Weekly downloads
 
Created
Source

Suspend Resource

Ready resource with resume/suspend functionality.

npm install suspend-resource

Usage

const SuspendResource = require('suspend-resource')

class Thing extends SuspendResource {
  constructor () {
    super()
  }

  async _open () {
    // open the resource
  }

  async _close () {
    // close the resource
  }

  async _suspend() {
    // suspend the resource (only implement if suspend/resume is required)
  }

  async _resume_() {
    // resume the resource (only implement if suspend/resume is required)
  }
}

const r = new Thing()

await r.ready() // calls _open once
await r.ready() // noop

await r.suspend() // calls _suspend once
await r.suspend() // noop

await r.resume() // calls _resume once
await r.resume() // noop

await Promise.all([r.suspend(), r.resume()]) // ends up resumed, since resume is the last method to be called 

await r.close()

FAQs

Package last updated on 30 Jun 2025

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