@featurevisor/core 2.7.0 → 2.9.0

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.
Files changed (78) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/coverage/clover.xml +110 -443
  3. package/coverage/coverage-final.json +3 -9
  4. package/coverage/lcov-report/{src/builder → builder}/allocator.ts.html +10 -10
  5. package/coverage/lcov-report/{src/builder → builder}/buildScopedConditions.ts.html +10 -10
  6. package/coverage/lcov-report/{src/builder → builder}/buildScopedDatafile.ts.html +10 -10
  7. package/coverage/lcov-report/{src/builder → builder}/buildScopedSegments.ts.html +10 -10
  8. package/coverage/lcov-report/{src/builder → builder}/index.html +10 -10
  9. package/coverage/lcov-report/{src/builder → builder}/revision.ts.html +10 -10
  10. package/coverage/lcov-report/{src/builder → builder}/traffic.ts.html +10 -10
  11. package/coverage/lcov-report/index.html +27 -57
  12. package/coverage/lcov-report/{src/list → list}/index.html +10 -10
  13. package/coverage/lcov-report/{src/list → list}/matrix.ts.html +10 -10
  14. package/coverage/lcov-report/{lib/tester → parsers}/index.html +41 -26
  15. package/coverage/lcov-report/parsers/json.ts.html +118 -0
  16. package/coverage/lcov-report/parsers/yml.ts.html +589 -0
  17. package/coverage/lcov-report/{src/tester → tester}/helpers.ts.html +10 -10
  18. package/coverage/lcov-report/{src/tester → tester}/index.html +10 -10
  19. package/coverage/lcov.info +198 -858
  20. package/jest.config.js +1 -0
  21. package/lib/config/index.d.ts +0 -1
  22. package/lib/config/index.js +0 -1
  23. package/lib/config/index.js.map +1 -1
  24. package/lib/config/projectConfig.d.ts +1 -1
  25. package/lib/config/projectConfig.js +1 -1
  26. package/lib/config/projectConfig.js.map +1 -1
  27. package/lib/datasource/datasource.js.map +1 -1
  28. package/lib/datasource/filesystemAdapter.js +1 -1
  29. package/lib/datasource/filesystemAdapter.js.map +1 -1
  30. package/lib/index.d.ts +1 -0
  31. package/lib/index.js +1 -0
  32. package/lib/index.js.map +1 -1
  33. package/lib/linter/conditionSchema.js +45 -6
  34. package/lib/linter/conditionSchema.js.map +1 -1
  35. package/lib/linter/featureSchema.d.ts +88 -88
  36. package/lib/{config/parsers.d.ts → parsers/index.d.ts} +5 -5
  37. package/lib/parsers/index.js +15 -0
  38. package/lib/parsers/index.js.map +1 -0
  39. package/lib/parsers/json.d.ts +2 -0
  40. package/lib/parsers/json.js +13 -0
  41. package/lib/parsers/json.js.map +1 -0
  42. package/lib/parsers/json.spec.d.ts +1 -0
  43. package/lib/parsers/json.spec.js +35 -0
  44. package/lib/parsers/json.spec.js.map +1 -0
  45. package/lib/parsers/yml.d.ts +2 -0
  46. package/lib/parsers/yml.js +154 -0
  47. package/lib/parsers/yml.js.map +1 -0
  48. package/lib/parsers/yml.spec.d.ts +1 -0
  49. package/lib/parsers/yml.spec.js +143 -0
  50. package/lib/parsers/yml.spec.js.map +1 -0
  51. package/lib/utils/git.js.map +1 -1
  52. package/package.json +4 -8
  53. package/src/config/index.ts +0 -1
  54. package/src/config/projectConfig.ts +1 -1
  55. package/src/datasource/datasource.ts +2 -1
  56. package/src/datasource/filesystemAdapter.ts +3 -2
  57. package/src/index.ts +1 -0
  58. package/src/linter/conditionSchema.ts +43 -6
  59. package/src/parsers/index.ts +22 -0
  60. package/src/parsers/json.spec.ts +36 -0
  61. package/src/parsers/json.ts +11 -0
  62. package/src/parsers/yml.spec.ts +174 -0
  63. package/src/parsers/yml.ts +168 -0
  64. package/src/utils/git.ts +2 -1
  65. package/tsconfig.cjs.json +2 -1
  66. package/coverage/lcov-report/lib/builder/allocator.js.html +0 -196
  67. package/coverage/lcov-report/lib/builder/buildScopedConditions.js.html +0 -373
  68. package/coverage/lcov-report/lib/builder/buildScopedDatafile.js.html +0 -403
  69. package/coverage/lcov-report/lib/builder/buildScopedSegments.js.html +0 -379
  70. package/coverage/lcov-report/lib/builder/index.html +0 -191
  71. package/coverage/lcov-report/lib/builder/revision.js.html +0 -148
  72. package/coverage/lcov-report/lib/builder/traffic.js.html +0 -493
  73. package/coverage/lcov-report/lib/list/index.html +0 -116
  74. package/coverage/lcov-report/lib/list/matrix.js.html +0 -532
  75. package/coverage/lcov-report/lib/tester/helpers.js.html +0 -295
  76. package/lib/config/parsers.js +0 -32
  77. package/lib/config/parsers.js.map +0 -1
  78. package/src/config/parsers.ts +0 -40
@@ -0,0 +1,174 @@
1
+ import { ymlParser } from "./yml";
2
+
3
+ describe("core :: parser :: ymlParser", () => {
4
+ it("should parse YAML string into object", () => {
5
+ const yamlString = `
6
+ foo: 1
7
+ bar: baz
8
+ arr:
9
+ - 1
10
+ - 2
11
+ `;
12
+ const result = ymlParser.parse<{ foo: number; bar: string; arr: number[] }>(yamlString);
13
+ expect(result).toEqual({ foo: 1, bar: "baz", arr: [1, 2] });
14
+ });
15
+
16
+ it("should stringify object into YAML string", () => {
17
+ const obj = { foo: 1, bar: "baz", arr: [1, 2] };
18
+ const yamlString = ymlParser.stringify(obj);
19
+ expect(yamlString.trim()).toBe(`foo: 1
20
+ bar: baz
21
+ arr:
22
+ - 1
23
+ - 2`);
24
+ });
25
+
26
+ it("should parse and then stringify to preserve YAML content semantically", () => {
27
+ const original = {
28
+ alpha: "a",
29
+ num: 42,
30
+ bool: true,
31
+ nullish: null,
32
+ nested: { z: "x", y: [1, 2] },
33
+ };
34
+ const str = ymlParser.stringify(original);
35
+ const reparsed = ymlParser.parse<typeof original>(str);
36
+ expect(reparsed).toEqual(original);
37
+ });
38
+
39
+ it("should throw if invalid YAML string is provided to parse", () => {
40
+ expect(() => {
41
+ ymlParser.parse("foo: : bar");
42
+ }).toThrow();
43
+ });
44
+
45
+ describe("stringify() with filePath argument (existing file for ordering/comments only)", () => {
46
+ const fs = require("fs");
47
+ const path = require("path");
48
+ const os = require("os");
49
+
50
+ let tempFile: string;
51
+
52
+ beforeEach(() => {
53
+ tempFile = path.join(os.tmpdir(), `test_${Math.random()}.yml`);
54
+ });
55
+
56
+ afterEach(() => {
57
+ if (fs.existsSync(tempFile)) {
58
+ fs.unlinkSync(tempFile);
59
+ }
60
+ });
61
+
62
+ it("should save exactly the new object; existing file is only for ordering/comments", () => {
63
+ const beforeYaml =
64
+ `
65
+ foo: 1 # foo comment here
66
+ extra: blah
67
+
68
+ ##
69
+ # Comment above nested
70
+ #
71
+ nested:
72
+ a: x
73
+ b: y # b comment
74
+ array:
75
+ - one # one
76
+ - two # two
77
+ - three # three
78
+ `.trim() + "\n";
79
+
80
+ const newContent = {
81
+ foo: 42,
82
+ bar: "new",
83
+ nested: { b: "updated", c: "added" },
84
+ array: ["two", "three", "four"],
85
+ };
86
+
87
+ const afterYaml =
88
+ `
89
+ foo: 42 # foo comment here
90
+ bar: new
91
+ ##
92
+ # Comment above nested
93
+ #
94
+ nested:
95
+ b: updated # b comment
96
+ c: added
97
+ array:
98
+ - two # two
99
+ - three # three
100
+ - four
101
+ `.trim() + "\n";
102
+
103
+ fs.writeFileSync(tempFile, beforeYaml);
104
+
105
+ const output = ymlParser.stringify(newContent, tempFile);
106
+
107
+ expect(output).toBe(afterYaml);
108
+ });
109
+
110
+ it("should replace the root if YAML file is empty", () => {
111
+ const beforeYaml = "";
112
+ const afterYaml =
113
+ `
114
+ hello: world
115
+ test:
116
+ - 1
117
+ - 2
118
+ - 3
119
+ `.trim() + "\n";
120
+
121
+ fs.writeFileSync(tempFile, beforeYaml);
122
+
123
+ const obj = { hello: "world", test: [1, 2, 3] };
124
+ const output = ymlParser.stringify(obj, tempFile);
125
+
126
+ expect(output).toBe(afterYaml);
127
+ });
128
+
129
+ it("should throw if trying to set YAML document root to a primitive", () => {
130
+ const beforeYaml =
131
+ `
132
+ foo: bar
133
+ `.trim() + "\n";
134
+
135
+ fs.writeFileSync(tempFile, beforeYaml);
136
+
137
+ // Root must be an object when using filePath; primitives throw
138
+ expect(() => {
139
+ ymlParser.stringify("primitive", tempFile);
140
+ }).toThrow(/Cannot set root document to a primitive value/);
141
+ });
142
+
143
+ it("should fall back to simple stringify if filePath does not exist", () => {
144
+ const fakeFilePath = path.join(os.tmpdir(), `notfound_${Math.random()}.yml`);
145
+ const afterYaml =
146
+ `
147
+ only: in-memory
148
+ `.trim() + "\n";
149
+
150
+ const obj = { only: "in-memory" };
151
+ const output = ymlParser.stringify(obj, fakeFilePath);
152
+
153
+ expect(output).toBe(afterYaml);
154
+ expect(fs.existsSync(fakeFilePath)).toBe(false); // should not create the file
155
+ });
156
+
157
+ it("should not mutate the original YAML file", () => {
158
+ const beforeYaml =
159
+ `
160
+ foo: unchanged
161
+ bar: before
162
+ `.trim() + "\n";
163
+
164
+ fs.writeFileSync(tempFile, beforeYaml);
165
+ const onDiskBefore = fs.readFileSync(tempFile, "utf8");
166
+
167
+ const obj = { bar: "after" };
168
+ ymlParser.stringify(obj, tempFile);
169
+
170
+ const onDiskAfter = fs.readFileSync(tempFile, "utf8");
171
+ expect(onDiskAfter).toBe(onDiskBefore); // file on disk unchanged
172
+ });
173
+ });
174
+ });
@@ -0,0 +1,168 @@
1
+ import * as fs from "fs";
2
+
3
+ import { parse, parseDocument, stringify } from "yaml";
4
+ import type { Pair, YAMLMap, YAMLSeq } from "yaml/types";
5
+ import { Scalar as ScalarCtor } from "yaml/types";
6
+
7
+ import type { CustomParser } from "./index";
8
+
9
+ function getKeyString(keyNode: unknown): string | undefined {
10
+ if (keyNode == null) return undefined;
11
+ if (typeof (keyNode as { value?: unknown }).value !== "undefined") {
12
+ return String((keyNode as { value: unknown }).value);
13
+ }
14
+ return typeof keyNode === "string" ? keyNode : undefined;
15
+ }
16
+
17
+ function copyComments(source: Pair, target: Pair): void {
18
+ if (source.comment != null) target.comment = source.comment;
19
+ if (source.commentBefore != null) target.commentBefore = source.commentBefore;
20
+ const srcVal = source.value as
21
+ | { comment?: string | null; commentBefore?: string | null }
22
+ | undefined;
23
+ const tgtVal = target.value;
24
+ if (srcVal && tgtVal && typeof tgtVal === "object" && tgtVal !== null) {
25
+ const t = tgtVal as { comment?: string | null; commentBefore?: string | null };
26
+ if (srcVal.comment != null) t.comment = srcVal.comment;
27
+ if (srcVal.commentBefore != null) t.commentBefore = srcVal.commentBefore;
28
+ }
29
+ }
30
+
31
+ function isYamlMap(node: unknown): node is YAMLMap {
32
+ return node != null && typeof node === "object" && Array.isArray((node as YAMLMap).items);
33
+ }
34
+
35
+ function isYamlSeq(node: unknown): node is YAMLSeq {
36
+ return node != null && typeof node === "object" && Array.isArray((node as YAMLSeq).items);
37
+ }
38
+
39
+ function seqItemValueKey(item: unknown): string {
40
+ if (item == null) return String(item);
41
+ const n = item as { value?: unknown; toJSON?: () => unknown };
42
+ if (typeof n.value !== "undefined") return JSON.stringify(n.value);
43
+ if (typeof n.toJSON === "function") return JSON.stringify(n.toJSON());
44
+ return JSON.stringify(item);
45
+ }
46
+
47
+ function primitiveValueKey(v: unknown): string {
48
+ return JSON.stringify(v);
49
+ }
50
+
51
+ function createValueWithComments(
52
+ schema: { createNode: (v: unknown) => unknown; createPair: (k: unknown, v: unknown) => Pair },
53
+ oldNode: unknown,
54
+ newValue: unknown,
55
+ ): unknown {
56
+ if (newValue === null || typeof newValue !== "object") {
57
+ const node = new ScalarCtor(newValue);
58
+ const old = oldNode as { comment?: string | null; commentBefore?: string | null } | undefined;
59
+ if (old) {
60
+ if (old.comment != null) node.comment = old.comment;
61
+ if (old.commentBefore != null) node.commentBefore = old.commentBefore;
62
+ }
63
+ return node;
64
+ }
65
+ if (Array.isArray(newValue)) {
66
+ const oldSeq = isYamlSeq(oldNode) ? (oldNode as YAMLSeq) : null;
67
+ const oldItemsByValue = new Map<string, unknown>();
68
+ if (oldSeq && oldSeq.items) {
69
+ for (const item of oldSeq.items) {
70
+ oldItemsByValue.set(seqItemValueKey(item), item);
71
+ }
72
+ }
73
+ const newSeq = schema.createNode([]) as YAMLSeq;
74
+ for (const el of newValue) {
75
+ const oldItem = oldItemsByValue.get(primitiveValueKey(el));
76
+ const itemNode = createValueWithComments(schema, oldItem, el);
77
+ newSeq.add(itemNode);
78
+ }
79
+ return newSeq;
80
+ }
81
+ // newValue is a plain object; preserve comments from old map if present
82
+ const oldMap = isYamlMap(oldNode) ? (oldNode as YAMLMap) : null;
83
+ const oldPairsByKey = new Map<string, Pair>();
84
+ if (oldMap) {
85
+ for (const pair of (oldMap.items || []) as Pair[]) {
86
+ const keyStr = getKeyString(pair.key);
87
+ if (keyStr !== undefined) oldPairsByKey.set(keyStr, pair);
88
+ }
89
+ }
90
+ const newMap = schema.createNode({}) as YAMLMap;
91
+ const obj = newValue as Record<string, unknown>;
92
+ for (const k of Object.keys(obj)) {
93
+ const oldPair = oldPairsByKey.get(k);
94
+ const childOldNode = oldPair ? oldPair.value : undefined;
95
+ const childNewValue = createValueWithComments(schema, childOldNode, obj[k]);
96
+ const newPair = schema.createPair(k, childNewValue);
97
+ if (oldPair) copyComments(oldPair, newPair);
98
+ newMap.add(newPair);
99
+ }
100
+ const result = newMap as { comment?: string | null; commentBefore?: string | null };
101
+ const oldVal = oldNode as { comment?: string | null; commentBefore?: string | null } | undefined;
102
+ if (oldVal && result) {
103
+ if (oldVal.comment != null) result.comment = oldVal.comment;
104
+ if (oldVal.commentBefore != null) result.commentBefore = oldVal.commentBefore;
105
+ }
106
+ return result;
107
+ }
108
+
109
+ function replaceContentsPreservingComments(
110
+ doc: {
111
+ contents: unknown;
112
+ schema: { createNode: (v: unknown) => unknown; createPair: (k: unknown, v: unknown) => Pair };
113
+ },
114
+ newContent: Record<string, unknown>,
115
+ ): void {
116
+ const oldRoot = doc.contents as YAMLMap | null | undefined;
117
+ if (!oldRoot || !Array.isArray((oldRoot as YAMLMap).items)) {
118
+ doc.contents = doc.schema.createNode(newContent) as typeof doc.contents;
119
+ return;
120
+ }
121
+
122
+ const schema = doc.schema;
123
+ const oldPairsByKey = new Map<string, Pair>();
124
+ for (const pair of (oldRoot as YAMLMap).items as Pair[]) {
125
+ const keyStr = getKeyString(pair.key);
126
+ if (keyStr !== undefined) oldPairsByKey.set(keyStr, pair);
127
+ }
128
+
129
+ const newMap = schema.createNode({}) as YAMLMap;
130
+ for (const key of Object.keys(newContent)) {
131
+ const oldPair = oldPairsByKey.get(key);
132
+ const valueNode = createValueWithComments(schema, oldPair?.value, newContent[key]);
133
+ const newPair = schema.createPair(key, valueNode);
134
+ if (oldPair) copyComments(oldPair, newPair);
135
+ newMap.add(newPair);
136
+ }
137
+
138
+ (doc as { contents: unknown }).contents = newMap;
139
+ }
140
+
141
+ export const ymlParser: CustomParser = {
142
+ extension: "yml",
143
+ parse: function <T>(content: string): T {
144
+ return parse(content) as T;
145
+ },
146
+ stringify: function (content: any, filePath?: string) {
147
+ if (!filePath || !fs.existsSync(filePath)) {
148
+ return stringify(content);
149
+ }
150
+
151
+ const fileContent = fs.readFileSync(filePath, "utf8");
152
+ if (!fileContent.trim()) {
153
+ return stringify(content);
154
+ }
155
+
156
+ // newObject is the final saved object; existing file is only for ordering/comments
157
+ if (content === null || typeof content !== "object" || Array.isArray(content)) {
158
+ throw new Error("Cannot set root document to a primitive value");
159
+ }
160
+
161
+ const doc = parseDocument(fileContent) as {
162
+ contents: unknown;
163
+ schema: { createNode: (v: unknown) => unknown; createPair: (k: unknown, v: unknown) => Pair };
164
+ };
165
+ replaceContentsPreservingComments(doc, content);
166
+ return doc.toString();
167
+ },
168
+ };
package/src/utils/git.ts CHANGED
@@ -2,7 +2,8 @@ import * as path from "path";
2
2
 
3
3
  import type { Commit, EntityDiff, EntityType } from "@featurevisor/types";
4
4
 
5
- import { CustomParser, ProjectConfig } from "../config";
5
+ import { ProjectConfig } from "../config";
6
+ import { CustomParser } from "../parsers";
6
7
 
7
8
  function parseGitCommitShowOutput(gitShowOutput: string) {
8
9
  const result = {
package/tsconfig.cjs.json CHANGED
@@ -2,7 +2,8 @@
2
2
  "extends": "../../tsconfig.cjs.json",
3
3
  "compilerOptions": {
4
4
  "target": "es2020",
5
- "outDir": "./lib"
5
+ "outDir": "./lib",
6
+ "skipLibCheck": true
6
7
  },
7
8
  "include": ["./src/**/*.ts"]
8
9
  }
@@ -1,196 +0,0 @@
1
-
2
- <!doctype html>
3
- <html lang="en">
4
-
5
- <head>
6
- <title>Code coverage report for lib/builder/allocator.js</title>
7
- <meta charset="utf-8" />
8
- <link rel="stylesheet" href="../../prettify.css" />
9
- <link rel="stylesheet" href="../../base.css" />
10
- <link rel="shortcut icon" type="image/x-icon" href="../../favicon.png" />
11
- <meta name="viewport" content="width=device-width, initial-scale=1" />
12
- <style type='text/css'>
13
- .coverage-summary .sorter {
14
- background-image: url(../../sort-arrow-sprite.png);
15
- }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <div class='wrapper'>
21
- <div class='pad1'>
22
- <h1><a href="../../index.html">All files</a> / <a href="index.html">lib/builder</a> allocator.js</h1>
23
- <div class='clearfix'>
24
-
25
- <div class='fl pad1y space-right2'>
26
- <span class="strong">100% </span>
27
- <span class="quiet">Statements</span>
28
- <span class='fraction'>28/28</span>
29
- </div>
30
-
31
-
32
- <div class='fl pad1y space-right2'>
33
- <span class="strong">100% </span>
34
- <span class="quiet">Branches</span>
35
- <span class='fraction'>8/8</span>
36
- </div>
37
-
38
-
39
- <div class='fl pad1y space-right2'>
40
- <span class="strong">100% </span>
41
- <span class="quiet">Functions</span>
42
- <span class='fraction'>2/2</span>
43
- </div>
44
-
45
-
46
- <div class='fl pad1y space-right2'>
47
- <span class="strong">100% </span>
48
- <span class="quiet">Lines</span>
49
- <span class='fraction'>28/28</span>
50
- </div>
51
-
52
-
53
- </div>
54
- <p class="quiet">
55
- Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
56
- </p>
57
- <template id="filterTemplate">
58
- <div class="quiet">
59
- Filter:
60
- <input oninput="onInput()" type="search" id="fileSearch">
61
- </div>
62
- </template>
63
- </div>
64
- <div class='status-line high'></div>
65
- <pre><table class="coverage">
66
- <tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
67
- <a name='L2'></a><a href='#L2'>2</a>
68
- <a name='L3'></a><a href='#L3'>3</a>
69
- <a name='L4'></a><a href='#L4'>4</a>
70
- <a name='L5'></a><a href='#L5'>5</a>
71
- <a name='L6'></a><a href='#L6'>6</a>
72
- <a name='L7'></a><a href='#L7'>7</a>
73
- <a name='L8'></a><a href='#L8'>8</a>
74
- <a name='L9'></a><a href='#L9'>9</a>
75
- <a name='L10'></a><a href='#L10'>10</a>
76
- <a name='L11'></a><a href='#L11'>11</a>
77
- <a name='L12'></a><a href='#L12'>12</a>
78
- <a name='L13'></a><a href='#L13'>13</a>
79
- <a name='L14'></a><a href='#L14'>14</a>
80
- <a name='L15'></a><a href='#L15'>15</a>
81
- <a name='L16'></a><a href='#L16'>16</a>
82
- <a name='L17'></a><a href='#L17'>17</a>
83
- <a name='L18'></a><a href='#L18'>18</a>
84
- <a name='L19'></a><a href='#L19'>19</a>
85
- <a name='L20'></a><a href='#L20'>20</a>
86
- <a name='L21'></a><a href='#L21'>21</a>
87
- <a name='L22'></a><a href='#L22'>22</a>
88
- <a name='L23'></a><a href='#L23'>23</a>
89
- <a name='L24'></a><a href='#L24'>24</a>
90
- <a name='L25'></a><a href='#L25'>25</a>
91
- <a name='L26'></a><a href='#L26'>26</a>
92
- <a name='L27'></a><a href='#L27'>27</a>
93
- <a name='L28'></a><a href='#L28'>28</a>
94
- <a name='L29'></a><a href='#L29'>29</a>
95
- <a name='L30'></a><a href='#L30'>30</a>
96
- <a name='L31'></a><a href='#L31'>31</a>
97
- <a name='L32'></a><a href='#L32'>32</a>
98
- <a name='L33'></a><a href='#L33'>33</a>
99
- <a name='L34'></a><a href='#L34'>34</a>
100
- <a name='L35'></a><a href='#L35'>35</a>
101
- <a name='L36'></a><a href='#L36'>36</a>
102
- <a name='L37'></a><a href='#L37'>37</a>
103
- <a name='L38'></a><a href='#L38'>38</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
104
- <span class="cline-any cline-yes">2x</span>
105
- <span class="cline-any cline-yes">2x</span>
106
- <span class="cline-any cline-yes">2x</span>
107
- <span class="cline-any cline-neutral">&nbsp;</span>
108
- <span class="cline-any cline-yes">37x</span>
109
- <span class="cline-any cline-yes">37x</span>
110
- <span class="cline-any cline-yes">37x</span>
111
- <span class="cline-any cline-yes">37x</span>
112
- <span class="cline-any cline-yes">39x</span>
113
- <span class="cline-any cline-yes">39x</span>
114
- <span class="cline-any cline-yes">39x</span>
115
- <span class="cline-any cline-yes">39x</span>
116
- <span class="cline-any cline-yes">39x</span>
117
- <span class="cline-any cline-yes">39x</span>
118
- <span class="cline-any cline-neutral">&nbsp;</span>
119
- <span class="cline-any cline-yes">37x</span>
120
- <span class="cline-any cline-neutral">&nbsp;</span>
121
- <span class="cline-any cline-neutral">&nbsp;</span>
122
- <span class="cline-any cline-yes">38x</span>
123
- <span class="cline-any cline-yes">4x</span>
124
- <span class="cline-any cline-neutral">&nbsp;</span>
125
- <span class="cline-any cline-yes">34x</span>
126
- <span class="cline-any cline-yes">34x</span>
127
- <span class="cline-any cline-yes">34x</span>
128
- <span class="cline-any cline-yes">34x</span>
129
- <span class="cline-any cline-yes">40x</span>
130
- <span class="cline-any cline-yes">40x</span>
131
- <span class="cline-any cline-yes">40x</span>
132
- <span class="cline-any cline-yes">40x</span>
133
- <span class="cline-any cline-yes">27x</span>
134
- <span class="cline-any cline-neutral">&nbsp;</span>
135
- <span class="cline-any cline-yes">40x</span>
136
- <span class="cline-any cline-yes">40x</span>
137
- <span class="cline-any cline-neutral">&nbsp;</span>
138
- <span class="cline-any cline-yes">34x</span>
139
- <span class="cline-any cline-neutral">&nbsp;</span>
140
- <span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">"use strict";
141
- Object.defineProperty(exports, "__esModule", { value: true });
142
- exports.getAllocation = getAllocation;
143
- exports.getUpdatedAvailableRangesAfterFilling = getUpdatedAvailableRangesAfterFilling;
144
- function getAllocation(availableRanges, fill) {
145
- const result = [];
146
- let remaining = fill;
147
- let i = 0;
148
- while (remaining &gt; 0 &amp;&amp; i &lt; availableRanges.length) {
149
- const range = availableRanges[i];
150
- const [start, end] = range;
151
- const rangeFill = Math.min(remaining, end - start);
152
- result.push([start, start + rangeFill]);
153
- remaining -= rangeFill;
154
- i++;
155
- }
156
- return result;
157
- }
158
- function getUpdatedAvailableRangesAfterFilling(availableRanges, fill) {
159
- if (fill === 0) {
160
- return availableRanges;
161
- }
162
- const result = [];
163
- let remaining = fill;
164
- let i = 0;
165
- while (remaining &gt; 0 &amp;&amp; i &lt; availableRanges.length) {
166
- const range = availableRanges[i];
167
- const [start, end] = range;
168
- const rangeFill = Math.min(remaining, end - start);
169
- if (rangeFill &lt; end - start) {
170
- result.push([start + rangeFill, end]);
171
- }
172
- remaining -= rangeFill;
173
- i++;
174
- }
175
- return result;
176
- }
177
- //# sourceMappingURL=allocator.js.map</pre></td></tr></table></pre>
178
-
179
- <div class='push'></div><!-- for sticky footer -->
180
- </div><!-- /wrapper -->
181
- <div class='footer quiet pad2 space-top1 center small'>
182
- Code coverage generated by
183
- <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
184
- at 2026-02-05T22:56:40.793Z
185
- </div>
186
- <script src="../../prettify.js"></script>
187
- <script>
188
- window.onload = function () {
189
- prettyPrint();
190
- };
191
- </script>
192
- <script src="../../sorter.js"></script>
193
- <script src="../../block-navigation.js"></script>
194
- </body>
195
- </html>
196
-