🚀 Launch Week Day 4:Introducing the Alert Details Page: A Better Way to Explore Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

lock-em-sock-em

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

lock-em-sock-em

atomic, cross-platform tcp domain servers & sockets

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

lock'em sock'em

atomic, cross-platform tcp domain servers & sockets

Install

npm i lock-em-sock-em

Usage

const { createServer, connect, lockemSockem } = require('lock-em-sock-em')

const id = 'lock-em-sock-em'

const server = await createServer(id)

server.on('connection', async (socket) => {
  let str = ''
  for await (const buf of socket) str += buf
  console.log(str)
})

const socket = await connect(id)

socket.write(Buffer.from(id))
socket.end()

const { acquired } = await lockemSockem(id)
console.log('acquired file lock?', acquired)

API

const server = await createServer(id)

server is an instance of net.Server()

const socket = await connect(id)

socket is an instance of net.Socket()

const { handle, lock, acquired, sock } = await lockemSockem(id)

  • handle is an instance of fs.FileHandle
  • lock is the String path of the file lock
  • acquired is a Boolean indicating whether the file lock was successfully acquired
  • sock is the String path of the domain socket

FAQs

Package last updated on 23 Jun 2022

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