Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gridlock

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gridlock

lock one thing

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

gridlock - lock one thing

The gridlock Node.js module provides a simple locking mechanism for single things.

Build Status

Usage

var gridlock = require('gridlock')

function op (cb) {
  setTimeout(cb, 1000)
}
var locker = gridlock()
var id = 'abc'
locker.lock(id)
op(function () {
  locker.unlock(id)
})
if (locker.lock(id)) {
  locker.once(id, function () {
    console.log('done')
  })
}

types

gridlock()

Returns a new locker which is an instance of EventEmitter.

locker.lock(id)

Tries to store the provided identifier. Returns false if it succeeds and true if it fails meaning the id has already been stored (locked).

  • id String() is the identifier of a thing

locker.unlock(id)

Releases the provided identifier and emits it.

  • id String() is the identifier of a thing

exports

To access the Gridlock class require('gridlock').

Installation

With npm do:

$ npm install gridlock

License

MIT License

Keywords

FAQs

Package last updated on 18 Aug 2015

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