@rocicorp/lock 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/out/lock.js CHANGED
@@ -1,8 +1,6 @@
1
- import { resolver } from './resolver.js';
1
+ import { resolver } from '@rocicorp/resolver';
2
2
  export class Lock {
3
- constructor() {
4
- this._lockP = null;
5
- }
3
+ _lockP = null;
6
4
  async lock() {
7
5
  const previous = this._lockP;
8
6
  const { promise, resolve } = resolver();
@@ -15,11 +13,9 @@ export class Lock {
15
13
  }
16
14
  }
17
15
  export class RWLock {
18
- constructor() {
19
- this._lock = new Lock();
20
- this._writeP = null;
21
- this._readP = [];
22
- }
16
+ _lock = new Lock();
17
+ _writeP = null;
18
+ _readP = [];
23
19
  read() {
24
20
  return this._lock.withLock(async () => {
25
21
  await this._writeP;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rocicorp/lock",
3
3
  "description": "Implements Lock and RWLock synchronization primitives.",
4
- "version": "1.0.0",
4
+ "version": "1.0.2",
5
5
  "repository": "github:rocicorp/lock",
6
6
  "license": "Apache-2.0",
7
7
  "engines": {
@@ -17,25 +17,29 @@
17
17
  "prepack": "npm run lint && npm run test "
18
18
  },
19
19
  "devDependencies": {
20
- "@types/chai": "^4.3.0",
21
- "@types/mocha": "^9.1.0",
22
- "@types/sinon": "^10.0.11",
23
- "@typescript-eslint/eslint-plugin": "^5.15.0",
24
- "@typescript-eslint/parser": "^5.15.0",
25
- "chai": "^4.3.6",
26
- "eslint": "^8.11.0",
27
- "mocha": "^9.2.2",
28
- "prettier": "^2.5.1",
29
- "sinon": "^13.0.1",
30
- "typescript": "^4.6.2"
20
+ "@types/chai": "^4.3.6",
21
+ "@types/mocha": "^10.0.1",
22
+ "@types/sinon": "^10.0.16",
23
+ "@typescript-eslint/eslint-plugin": "^6.7.0",
24
+ "@typescript-eslint/parser": "^6.7.0",
25
+ "chai": "^4.3.8",
26
+ "eslint": "^8.49.0",
27
+ "mocha": "^10.2.0",
28
+ "prettier": "^3.0.3",
29
+ "sinon": "^15.2.0",
30
+ "typescript": "^5.2.2"
31
31
  },
32
32
  "type": "module",
33
33
  "types": "out/lock.d.ts",
34
+ "module": "./out/lock.js",
34
35
  "exports": {
35
36
  ".": "./out/lock.js"
36
37
  },
37
38
  "files": [
38
39
  "out/*",
39
40
  "!out/*.test.*"
40
- ]
41
+ ],
42
+ "dependencies": {
43
+ "@rocicorp/resolver": "^1.0.0"
44
+ }
41
45
  }
package/out/resolver.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export interface Resolver<R = void, E = unknown> {
2
- promise: Promise<R>;
3
- resolve: (res: R) => void;
4
- reject: (err: E) => void;
5
- }
6
- export declare function resolver<R = void, E = unknown>(): Resolver<R, E>;
package/out/resolver.js DELETED
@@ -1,9 +0,0 @@
1
- export function resolver() {
2
- let resolve;
3
- let reject;
4
- const promise = new Promise((res, rej) => {
5
- resolve = res;
6
- reject = rej;
7
- });
8
- return { promise, resolve, reject };
9
- }