@mtt/navigator.locks
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

web-locks

A polyfill of Web Locks API with localstorage, support the mainstream browsers usage

usage:

install this lib

npm i navigator.locks

import this lib and use it follow Web Locks API

import locks from "navigator.locks";

locks.request("my_resource", async (lock) => {
  // The lock has been acquired.
  await do_something();
  await do_something_else();
  // Now the lock will be released.
});

online demo

demo link

you could open this url in two tabs, operate the lock buttons and see the page and console

process:

  • [x] lock.request

    • [x] lock.request option -> mode
    • [x] lock.request option -> ifAvailable
    • [x] lock.request option -> steal
    • [x] lock.request option -> 1signal
  • [x] lock.query

  • [x] CI/CD

  • [x] Unit test

Package Sidebar

Install

npm i @mtt/navigator.locks

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

278 kB

Total Files

39

Last publish

Collaborators

  • mtt