@cobol-ts/arrays 0.0.0-stage → 0.0.1

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/README.md CHANGED
@@ -1,3 +1,44 @@
1
- # Temporary Holding Version
1
+ # @cobol-ts/arrays — ProjectedArray
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `ProjectedArray<T>` extends `ReadonlyArray<T>`. An ordinary `Array<T>` satisfies it.
4
+ A lazy projected array preserves its native array interface without creating
5
+ its child objects until they are accessed. Its `length` comes from the current
6
+ logical record; its internal cached projections may retain more slots.
7
+
8
+ `createProjectedArray(source)` wraps an empty native array using a proxy.
9
+ Element lookup delegates to the supplied source, while `map`, `slice`,
10
+ `forEach`, iteration, `at` and the other readonly array methods are inherited
11
+ from `Array.prototype`. Operations such as `map` allocate their returned array
12
+ just as they would for an ordinary JavaScript array. No data-format-specific
13
+ logic or record ownership exists in this package. Mutation is rejected.
14
+
15
+ The projection package supplies the mutable source and retains reusable
16
+ child projections in pooled physical-record state. Borrowed elements are invalid
17
+ after their owning file-result lease closes.
18
+
19
+ ## ArrayWithSize — reusable contiguous prefixes
20
+
21
+ `ArrayWithSize<T>` is a small, independent abstraction for buffers where the
22
+ valid data is exactly `values[0..size)`. Its backing array may retain entries
23
+ beyond `size` after reset. `createArrayWithSize()`, `appendArrayWithSize()` and
24
+ `resetArrayWithSize()` let a caller grow and reuse a prefix without allocating
25
+ another array on each lease:
26
+
27
+ ```typescript
28
+ const boundaries = createArrayWithSize<number>();
29
+ appendArrayWithSize(boundaries, 100);
30
+ appendArrayWithSize(boundaries, 124);
31
+ resetArrayWithSize(boundaries); // size = 0, values' storage retained
32
+ appendArrayWithSize(boundaries, 200); // overwrites the first slot
33
+ ```
34
+
35
+ Reset invalidates the prefix; it does not clear object references beyond it.
36
+ Do not use this abstraction *as the indexed lookup array* for sparse projected children. It **is** appropriate for the separate dense list of child references activated during the current lease. In the projection and ODO caches, sparse indexed storage remains independent of this `ArrayWithSize` cleanup prefix.
37
+
38
+ ## Projected-array access metrics
39
+
40
+ `createProjectedArray(source, metrics?)` optionally counts direct Proxy `length` requests, numeric property selections and valid numeric selections. Its default `NullMetrics` performs no storage or I/O. A numeric index access calls the provider's length method to validate bounds; the projection package separately counts provider length-resolution work, selection, binding and cleanup. No new array elements are materialised by the counters.
41
+
42
+ ## Native arrays versus the Proxy adapter
43
+
44
+ The `ProjectedArray` Proxy adapter is the **lazy** selection mechanism: numeric property access asks a source for its active length and selected element, and the projection layer manages reusable high-water child views. Small fixed-position COBOL arrays may instead use real JavaScript arrays of reusable projection children, selected by the COBOL projection runtime. That does not change the contract of `createProjectedArray` or make the Proxy unnecessary; symbolic/ODO and complex arrays still require it. The native-array strategy holds views, not scalar values, and the byte-backed borrowed lifetime is enforced by the owning projection/record binding rather than by JavaScript array indexing.
@@ -0,0 +1,3 @@
1
+ export * from './src/arrays';
2
+ export * from "./src/projected.array";
3
+ export * from "./src/array.with.size";
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./src/arrays"), exports);
18
+ __exportStar(require("./src/projected.array"), exports);
19
+ __exportStar(require("./src/array.with.size"), exports);
20
+ //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,62 @@
1
1
  {
2
2
  "name": "@cobol-ts/arrays",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "description": "utilities about arrays",
4
+ "version": "0.0.1",
5
+ "main": "dist/index",
6
+ "types": "dist/index",
7
+ "browserslist": {
8
+ "development": [
9
+ "last 1 chrome version",
10
+ "last 1 firefox version",
11
+ "last 1 safari version"
12
+ ],
13
+ "production": [
14
+ ">0.2%",
15
+ "not dead",
16
+ "not op_mini all"
17
+ ]
18
+ },
19
+ "dependencies": {
20
+ "@cobol-ts/metrics": "0.0.1"
21
+ },
22
+ "devDependencies": {
23
+ "@testing-library/jest-dom": "^6.1.4",
24
+ "@types/jest": "^29.0.0",
25
+ "@types/node": "^14.0.0",
26
+ "jest": "^29.0.0",
27
+ "ts-jest": "^29.0.0",
28
+ "typescript": "^5.2.2"
29
+ },
30
+ "eslintConfig": {
31
+ "extends": [
32
+ "react-app",
33
+ "react-app/jest"
34
+ ],
35
+ "overrides": [
36
+ {
37
+ "files": [
38
+ "**/*.stories.*"
39
+ ],
40
+ "rules": {
41
+ "import/no-anonymous-default-export": "off"
42
+ }
43
+ }
44
+ ]
45
+ },
46
+ "files": [
47
+ "dist/index.js",
48
+ "dist/index.d.ts",
49
+ "dist/src/",
50
+ "build/"
51
+ ],
52
+ "keywords": [
53
+ "indexing"
54
+ ],
55
+ "license": "MIT",
56
+ "repository": "git@github.com:intellimaintain/intellimaintain.git",
57
+ "scripts": {
58
+ "test": "jest --config jest.config.json --env node",
59
+ "test:watch": "npm run test -- --watch",
60
+ "start": "react-scripts start"
61
+ }
6
62
  }