@cobol-ts/cursor-record 0.0.2 → 0.0.4

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.
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const record_pool_1 = require("./record.pool");
4
+ test('reuses a released object without calling its allocator again', () => {
5
+ const pool = (0, record_pool_1.createSimpleRecordPool)();
6
+ let allocations = 0;
7
+ const create = () => ({ id: ++allocations });
8
+ const first = pool.acquire(create);
9
+ pool.release(first);
10
+ expect(pool.acquire(create)).toBe(first);
11
+ expect(allocations).toBe(1);
12
+ });
13
+ test('does not return objects still borrowed', () => {
14
+ const pool = (0, record_pool_1.createSimpleRecordPool)();
15
+ let id = 0;
16
+ const create = () => ({ id: ++id });
17
+ const first = pool.acquire(create);
18
+ expect(pool.acquire(create)).not.toBe(first);
19
+ });
20
+ test('reference-counted adapter preserves acquisition and reuse', () => {
21
+ const pool = (0, record_pool_1.createReferenceCountedRecordPool)();
22
+ let id = 0;
23
+ const create = () => ({ id: ++id });
24
+ const first = pool.acquire(create);
25
+ pool.release(first);
26
+ expect(pool.acquire(create)).toBe(first);
27
+ expect(id).toBe(1);
28
+ });
29
+ test('simple pool reuses one object over a million leases', () => {
30
+ const pool = (0, record_pool_1.createSimpleRecordPool)();
31
+ let allocations = 0;
32
+ function create() {
33
+ allocations++;
34
+ return { id: allocations };
35
+ }
36
+ for (let i = 0; i < 1_000_000; i++) {
37
+ const record = pool.acquire(create);
38
+ pool.release(record);
39
+ }
40
+ expect(allocations).toBe(1);
41
+ });
42
+ //# sourceMappingURL=record.pool.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record.pool.spec.js","sourceRoot":"","sources":["../../src/record.pool.spec.ts"],"names":[],"mappings":";;AAAA,+CAAuF;AAEvF,IAAI,CAAC,8DAA8D,EAAE,GAAG,EAAE;IACtE,MAAM,IAAI,GAAG,IAAA,oCAAsB,GAAg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,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,qDAAqD,EAAE,GAAG,EAAE;IAC7D,MAAM,IAAI,GAAG,IAAA,oCAAsB,GAAgB,CAAC;IAEpD,IAAI,WAAW,GAAG,CAAC,CAAC;IAEpB,SAAS,MAAM;QACX,WAAW,EAAE,CAAC;QACd,OAAO,EAAC,EAAE,EAAE,WAAW,EAAC,CAAC;IAC7B,CAAC;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC;QACjC,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAChC,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cobol-ts/cursor-record",
3
3
  "description": "physical record framing for the @cobol-ts cursor stack",
4
- "version": "0.0.2",
4
+ "version": "0.0.4",
5
5
  "main": "dist/index",
6
6
  "types": "dist/index",
7
7
  "browserslist": {
@@ -17,9 +17,9 @@
17
17
  ]
18
18
  },
19
19
  "dependencies": {
20
- "@cobol-ts/cursor-loader-types": "0.0.2",
21
- "@cobol-ts/ref_counted_pool": "0.0.2",
22
- "@cobol-ts/metrics": "0.0.2"
20
+ "@cobol-ts/cursor-loader-types": "0.0.4",
21
+ "@cobol-ts/ref_counted_pool": "0.0.4",
22
+ "@cobol-ts/metrics": "0.0.4"
23
23
  },
24
24
  "devDependencies": {
25
25
  "typescript": "^5.2.2",
@@ -49,7 +49,8 @@
49
49
  "dist/index.js",
50
50
  "dist/index.d.ts",
51
51
  "dist/src/",
52
- "build/"
52
+ "build/",
53
+ "dist/**/*"
53
54
  ],
54
55
  "keywords": [
55
56
  "indexing"