browser-extension-utils 0.1.15 → 0.1.16

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/lib/index.d.ts CHANGED
@@ -138,7 +138,7 @@ export function getOffsetPosition(
138
138
  }
139
139
 
140
140
  // eslint-disable-next-line @typescript-eslint/ban-types
141
- export function runOnce(key: string, func: Function): any
141
+ export async function runOnce(key: string, func: Function): Promise<any>
142
142
 
143
143
  // eslint-disable-next-line @typescript-eslint/ban-types
144
144
  export function runWhenHeadExists(func: Function): void
package/lib/index.js CHANGED
@@ -323,17 +323,17 @@ export const getOffsetPosition = (element, referElement) => {
323
323
  }
324
324
 
325
325
  const runOnceCache = {}
326
- export const runOnce = (key, func) => {
327
- if (!key) {
328
- return func()
329
- }
330
-
326
+ export const runOnce = async (key, func) => {
331
327
  if (Object.hasOwn(runOnceCache, key)) {
332
328
  return runOnceCache[key]
333
329
  }
334
330
 
335
- const result = func()
336
- runOnceCache[key] = result
331
+ const result = await func()
332
+
333
+ if (key) {
334
+ runOnceCache[key] = result
335
+ }
336
+
337
337
  return result
338
338
  }
339
339
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-extension-utils",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "description": "Utilities for developing browser extensions and userscripts",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "repository": {
17
17
  "type": "git",
18
- "url": "git+https://github.com/PipecraftNet/browser-extension-utils.git"
18
+ "url": "git+https://github.com/utags/browser-extension-utils.git"
19
19
  },
20
20
  "keywords": [
21
21
  "extensions",
@@ -25,9 +25,9 @@
25
25
  "author": "Pipecraft",
26
26
  "license": "MIT",
27
27
  "bugs": {
28
- "url": "https://github.com/PipecraftNet/browser-extension-utils/issues"
28
+ "url": "https://github.com/utags/browser-extension-utils/issues"
29
29
  },
30
- "homepage": "https://github.com/PipecraftNet/browser-extension-utils#readme",
30
+ "homepage": "https://github.com/utags/browser-extension-utils#readme",
31
31
  "devDependencies": {
32
32
  "prettier": "^2.8.8",
33
33
  "xo": "^0.55.0"