browser-extension-utils 0.1.13 → 0.1.14

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 (2) hide show
  1. package/lib/index.js +8 -0
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -4,6 +4,13 @@ export const win = window
4
4
 
5
5
  export const uniq = (array) => [...new Set(array)]
6
6
 
7
+ // Polyfill for String.prototype.replaceAll()
8
+ // eslint-disable-next-line no-use-extend-native/no-use-extend-native
9
+ if (typeof String.prototype.replaceAll !== "function") {
10
+ // eslint-disable-next-line no-use-extend-native/no-use-extend-native, no-extend-native
11
+ String.prototype.replaceAll = String.prototype.replace
12
+ }
13
+
7
14
  export const toCamelCase = function (text) {
8
15
  return text.replaceAll(/^([A-Z])|[\s-_](\w)/g, function (match, p1, p2) {
9
16
  if (p2) return p2.toUpperCase()
@@ -251,6 +258,7 @@ export const throttle = (func, interval) => {
251
258
  return handler
252
259
  }
253
260
 
261
+ // Polyfill for Object.hasOwn()
254
262
  if (typeof Object.hasOwn !== "function") {
255
263
  Object.hasOwn = (instance, prop) =>
256
264
  Object.prototype.hasOwnProperty.call(instance, prop)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-extension-utils",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "Utilities for developing browser extensions and userscripts",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",