New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

get-ready

Package Overview
Dependencies
Maintainers
14
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-ready

mixin to add one-time ready event callback handler

  • 3.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
14
Created
Source

get-ready

NPM version CI Test coverage npm download Node.js Version

Fork from supershabam/ready

one-time ready event object.

Usage

Create ready event object.

import { Ready } from 'get-ready';

const obj = new Ready();

// register a callback
obj.ready(() => console.log('ready'));

// mark ready
obj.ready(true);

Register

Register a callback to the callback stack, it will be called when mark as ready, see example above.

If the callback is undefined, register will return a promise.

obj.ready().then(() => console.log('ready'));
obj.ready(true);

If it has been ready, the callback will be called immediately.

// already ready
obj.ready(true);
obj.ready().then(() => console.log('ready'));

ReadyEventEmitter

import { ReadyEventEmitter } from 'get-ready';

class MyClass extends ReadyEventEmitter {
  // your handler here
}

Warning: the callback is called after nextTick

Emit

Mark it as ready, you can simply using .ready(true).

You can also mark it not ready.

obj.ready(true);
// call immediately
obj.ready(() => console.log('ready'));

obj.ready(false);
obj.ready(() => throw 'don\'t run');

When exception throws, you can pass an error object, then the callback will receive it as the first argument.

obj.ready(err => console.log(err));
obj.ready(new Error('err'));

License

MIT

Contributors

Contributors

Made with contributors-img.

Keywords

FAQs

Package last updated on 18 Dec 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc