assign-gingerly 0.0.20 → 0.0.22

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/assignGingerly.js CHANGED
@@ -1,22 +1,3 @@
1
- // Polyfill for Map.prototype.getOrInsert and WeakMap.prototype.getOrInsert
2
- if (typeof Map.prototype.getOrInsertComputed !== 'function') {
3
- Map.prototype.getOrInsertComputed = function (key, insert) {
4
- if (this.has(key))
5
- return this.get(key);
6
- const value = insert();
7
- this.set(key, value);
8
- return value;
9
- };
10
- }
11
- if (typeof WeakMap.prototype.getOrInsertComputed !== 'function') {
12
- WeakMap.prototype.getOrInsertComputed = function (key, insert) {
13
- if (this.has(key))
14
- return this.get(key);
15
- const value = insert();
16
- this.set(key, value);
17
- return value;
18
- };
19
- }
20
1
  /**
21
2
  * GUID for global instance map storage to ensure uniqueness across package versions
22
3
  */
@@ -36,33 +17,40 @@ export function getInstanceMap() {
36
17
  * Base registry class for managing enhancement configurations
37
18
  */
38
19
  export class EnhancementRegistry {
39
- #items = [];
20
+ #items = new Set();
40
21
  push(items) {
41
22
  if (Array.isArray(items)) {
42
- this.#items.push(...items);
23
+ items.forEach(item => this.#items.add(item));
43
24
  }
44
25
  else {
45
- this.#items.push(items);
26
+ this.#items.add(items);
46
27
  }
47
28
  }
48
29
  getItems() {
49
- return this.#items;
30
+ return Array.from(this.#items);
50
31
  }
51
32
  findBySymbol(symbol) {
52
- return this.#items.find(item => {
33
+ for (const item of this.#items) {
53
34
  const symlinks = item.symlinks;
54
35
  if (!symlinks)
55
- return false;
56
- return Object.keys(symlinks).some(key => {
36
+ continue;
37
+ const hasSymbol = Object.keys(symlinks).some(key => {
57
38
  if (typeof key === 'symbol' || (typeof symlinks[key] === 'symbol')) {
58
39
  return key === symbol || symlinks[key] === symbol;
59
40
  }
60
41
  return false;
61
42
  }) || Object.getOwnPropertySymbols(symlinks).some(sym => sym === symbol);
62
- });
43
+ if (hasSymbol)
44
+ return item;
45
+ }
46
+ return undefined;
63
47
  }
64
48
  findByEnhKey(enhKey) {
65
- return this.#items.find(item => item.enhKey === enhKey);
49
+ for (const item of this.#items) {
50
+ if (item.enhKey === enhKey)
51
+ return item;
52
+ }
53
+ return undefined;
66
54
  }
67
55
  }
68
56
  /**
package/assignGingerly.ts CHANGED
@@ -2,28 +2,21 @@
2
2
 
3
3
  import { EnhancementConfig } from "./types/assign-gingerly/types";
4
4
 
5
- // Polyfill for Map.prototype.getOrInsert and WeakMap.prototype.getOrInsert
6
- if (typeof Map.prototype.getOrInsertComputed !== 'function') {
7
- Map.prototype.getOrInsertComputed = function(key, insert) {
8
- if (this.has(key)) return this.get(key);
9
- const value = insert();
10
- this.set(key, value);
11
- return value;
12
- };
13
- }
14
- if (typeof WeakMap.prototype.getOrInsertComputed !== 'function') {
15
- WeakMap.prototype.getOrInsertComputed = function(key, insert) {
16
- if (this.has(key)) return this.get(key);
17
- const value = insert();
18
- this.set(key, value);
19
- return value;
20
- };
21
- }
22
-
23
- /**
24
- * @deprecated Use EnhancementConfig instead
25
- */
26
- export type IBaseRegistryItem<T = any> = EnhancementConfig<T>;
5
+ // Polyfill for WeakMap.prototype.getOrInsert
6
+
7
+ // if (typeof WeakMap.prototype.getOrInsertComputed !== 'function') {
8
+ // WeakMap.prototype.getOrInsertComputed = function(key, insert) {
9
+ // if (this.has(key)) return this.get(key);
10
+ // const value = insert();
11
+ // this.set(key, value);
12
+ // return value;
13
+ // };
14
+ // }
15
+
16
+ // /**
17
+ // * @deprecated Use EnhancementConfig instead
18
+ // */
19
+ // export type IBaseRegistryItem<T = any> = EnhancementConfig<T>;
27
20
 
28
21
  /**
29
22
  * Interface for the options passed to assignGingerly
@@ -53,38 +46,46 @@ export function getInstanceMap(): WeakMap<object, Map<EnhancementConfig, any>> {
53
46
  * Base registry class for managing enhancement configurations
54
47
  */
55
48
  export class EnhancementRegistry {
56
- #items: EnhancementConfig[] = [];
49
+ #items: Set<EnhancementConfig> = new Set();
57
50
 
58
51
  push(items: EnhancementConfig | EnhancementConfig[]): void {
59
52
  if (Array.isArray(items)) {
60
- this.#items.push(...items);
53
+ items.forEach(item => this.#items.add(item));
61
54
  } else {
62
- this.#items.push(items);
55
+ this.#items.add(items);
63
56
  }
64
57
  }
65
58
 
66
59
  getItems(): EnhancementConfig[] {
67
- return this.#items;
60
+ return Array.from(this.#items);
68
61
  }
69
62
 
70
63
  findBySymbol(symbol: symbol | string): EnhancementConfig | undefined {
71
- return this.#items.find(item => {
64
+ for (const item of this.#items) {
72
65
  const symlinks = item.symlinks;
73
- if (!symlinks) return false;
74
- return Object.keys(symlinks).some(key => {
66
+ if (!symlinks) continue;
67
+
68
+ const hasSymbol = Object.keys(symlinks).some(key => {
75
69
  if (typeof key === 'symbol' || (typeof symlinks[key as any] === 'symbol')) {
76
70
  return key === symbol || symlinks[key as any] === symbol;
77
71
  }
78
72
  return false;
79
73
  }) || Object.getOwnPropertySymbols(symlinks).some(sym => sym === symbol);
80
- });
74
+
75
+ if (hasSymbol) return item;
76
+ }
77
+ return undefined;
81
78
  }
82
79
 
83
80
  findByEnhKey(enhKey: string | symbol): EnhancementConfig | undefined {
84
- return this.#items.find(item => item.enhKey === enhKey);
81
+ for (const item of this.#items) {
82
+ if (item.enhKey === enhKey) return item;
83
+ }
84
+ return undefined;
85
85
  }
86
86
  }
87
87
 
88
+
88
89
  /**
89
90
  * Helper function to check if a string key represents a Symbol.for expression
90
91
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assign-gingerly",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "description": "This package provides a utility function for carefully merging one object into another.",
5
5
  "homepage": "https://github.com/bahrus/assign-gingerly#readme",
6
6
  "bugs": {
@@ -58,12 +58,14 @@
58
58
  "scripts": {
59
59
  "serve": "node ./node_modules/spa-ssi/serve.js",
60
60
  "test": "playwright test",
61
- "update": "ncu -u && npm install"
61
+ "update": "ncu -u && npm install",
62
+ "safari": "npx playwright wk http://localhost:8000",
63
+ "chrome": "npx playwright cr http://localhost:8000"
62
64
  },
63
65
  "devDependencies": {
64
- "@playwright/test": "^1.58.2",
66
+ "@playwright/test": "1.59.0-alpha-2026-02-28",
65
67
  "spa-ssi": "0.0.27",
66
- "@types/node": "^25.3.0",
68
+ "@types/node": "^25.3.3",
67
69
  "typescript": "^5.9.3"
68
70
  }
69
71
  }
@@ -0,0 +1,42 @@
1
+ import { defineConfig, devices } from '@playwright/test';
2
+
3
+ /**
4
+ * Playwright configuration for running tests in actual browser JavaScript engines.
5
+ * This configuration opens HTML test pages in real browsers instead of running
6
+ * tests in Node.js.
7
+ */
8
+ export default defineConfig({
9
+ testDir: './tests-browser',
10
+ fullyParallel: true,
11
+ forbidOnly: !!process.env.CI,
12
+ retries: process.env.CI ? 2 : 0,
13
+ workers: process.env.CI ? 1 : undefined,
14
+ reporter: 'html',
15
+
16
+ use: {
17
+ baseURL: 'http://localhost:8000',
18
+ trace: 'on-first-retry',
19
+ },
20
+
21
+ projects: [
22
+ {
23
+ name: 'chromium',
24
+ use: { ...devices['Desktop Chrome'] },
25
+ },
26
+ {
27
+ name: 'firefox',
28
+ use: { ...devices['Desktop Firefox'] },
29
+ },
30
+ {
31
+ name: 'webkit',
32
+ use: { ...devices['Desktop Safari'] },
33
+ },
34
+ ],
35
+
36
+ // Start local web server before running tests
37
+ webServer: {
38
+ command: 'npm run serve',
39
+ port: 8000,
40
+ reuseExistingServer: !process.env.CI,
41
+ },
42
+ });
@@ -24,7 +24,7 @@ export default defineConfig({
24
24
  /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
25
25
  use: {
26
26
  /* Base URL to use in actions like `await page.goto('/')`. */
27
- baseURL: 'http://localhost:5173',
27
+ baseURL: 'http://localhost:8000',
28
28
  },
29
29
 
30
30
  /* Configure projects for major browsers */
@@ -46,9 +46,9 @@ export default defineConfig({
46
46
  ],
47
47
 
48
48
  /* Run your local dev server before starting the tests */
49
- // webServer: {
50
- // command: 'npm run dev',
51
- // url: 'http://localhost:5173',
52
- // reuseExistingServer: !process.env.CI,
53
- // },
49
+ webServer: {
50
+ command: 'npm run serve',
51
+ port: 8000,
52
+ reuseExistingServer: !process.env.CI,
53
+ },
54
54
  });
@@ -1,4 +1,4 @@
1
- // Type declarations for Map.prototype.getOrInsert and WeakMap.prototype.getOrInsert
1
+ // Type declarations for Map.prototype.getOrInsertComputed and WeakMap.prototype.getOrInsertComputed
2
2
  // Feature is now supported in all modern browsers (Chrome 146+, Firefox 134+, Safari 18.2+)
3
3
  // See: https://web-platform-dx.github.io/web-features-explorer/features/getorinsert/
4
4