rwlockfile

  • Version 2.0.25
  • Published
  • 38.2 kB
  • 3 dependencies
  • ISC license

Install

npm i rwlockfile
yarn add rwlockfile
pnpm add rwlockfile

Overview

lockfile utility with reader/writers

Index

Functions

function lockfile

lockfile: (prop: string, opts?: LockfileOptions) => MethodDecorator;

    function rwlockfile

    rwlockfile: (
    prop: string,
    type: 'read' | 'write',
    opts?: RWLockfileOptions
    ) => MethodDecorator;

      Classes

      class Lockfile

      class Lockfile {}

        constructor

        constructor(base: string, options?: LockfileOptions);
        • creates a new simple lockfile without read/write support

        property base

        base: string;

          property count

          readonly count: number;

            property dirPath

            readonly dirPath: string;

              property retryInterval

              retryInterval: number;

                property stale

                stale: number;

                  property timeout

                  timeout: number;

                    property uuid

                    uuid: string;

                      method add

                      add: (opts?: Partial<LockOptions>) => Promise<void>;
                      • adds 1 lock count

                      method addSync

                      addSync: (opts?: { reason?: string }) => void;
                      • adds 1 lock count

                      method check

                      check: () => Promise<boolean>;
                      • check if this instance can get a lock returns true if it already has a lock

                      method checkSync

                      checkSync: () => boolean;
                      • check if this instance can get a lock returns true if it already has a lock

                      method lock

                      lock: () => Promise<void>;
                      • creates a lock same as add

                      method lockSync

                      lockSync: () => void;
                      • creates a lock same as add

                      method remove

                      remove: () => Promise<void>;
                      • removes 1 lock count

                      method removeSync

                      removeSync: () => void;
                      • removes 1 lock count

                      method unlock

                      unlock: () => Promise<void>;
                      • removes all lock counts

                      method unlockSync

                      unlockSync: () => void;
                      • removes all lock counts

                      class LockfileError

                      class LockfileError extends Error {}

                        constructor

                        constructor({
                        msg,
                        file,
                        reason,
                        }: {
                        file: string;
                        msg?: string;
                        reason?: string;
                        });

                          property code

                          code: string;

                            property file

                            file: string;

                              property msg

                              msg: string;

                                property reason

                                reason: string;

                                  class RWLockfile

                                  class RWLockfile {}

                                    constructor

                                    constructor(base: string, options?: RWLockfileOptions);
                                    • creates a new read/write lockfile

                                      Parameter base

                                      base filepath to create lock from

                                    property base

                                    base: string;

                                      property count

                                      readonly count: { readonly read: number; readonly write: number };

                                        property file

                                        readonly file: string;

                                          property ifLocked

                                          ifLocked: IfLockedFn;

                                            property retryInterval

                                            retryInterval: number;

                                              property timeout

                                              timeout: number;

                                                method add

                                                add: (type: RWLockType, opts?: RWLockOptions) => Promise<void>;

                                                  method addSync

                                                  addSync: (type: RWLockType, opts?: { reason?: string }) => void;

                                                    method check

                                                    check: (type: RWLockType) => Promise<Status>;

                                                      method checkSync

                                                      checkSync: (type: RWLockType) => Status;

                                                        method remove

                                                        remove: (type: RWLockType) => Promise<void>;

                                                          method removeSync

                                                          removeSync: (type: RWLockType) => void;

                                                            method tryLock

                                                            tryLock: (type: RWLockType, reason?: string, inc?: boolean) => Promise<void>;

                                                              method unlock

                                                              unlock: (type?: RWLockType) => Promise<void>;

                                                                method unlockSync

                                                                unlockSync: (type?: RWLockType) => void;

                                                                  Package Files (5)

                                                                  Dependencies (3)

                                                                  Dev Dependencies (14)

                                                                  Peer Dependencies (0)

                                                                  No peer dependencies.

                                                                  Badge

                                                                  To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                  You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/rwlockfile.

                                                                  • Markdown
                                                                    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/rwlockfile)
                                                                  • HTML
                                                                    <a href="https://www.jsdocs.io/package/rwlockfile"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>