@github/browser-support 1.0.4 → 1.1.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.
- package/README.md +1 -1
- package/lib/element-replacechildren.d.ts +5 -0
- package/lib/element-replacechildren.d.ts.map +1 -0
- package/lib/element-replacechildren.js +29 -0
- package/lib/element-replacechildren.js.map +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +27 -30
- package/lib/index.js.map +1 -1
- package/lib/promise-allsettled.d.ts +7 -0
- package/lib/promise-allsettled.d.ts.map +1 -0
- package/lib/promise-allsettled.js +19 -0
- package/lib/promise-allsettled.js.map +1 -0
- package/lib/string-replaceall.d.ts +5 -0
- package/lib/string-replaceall.d.ts.map +1 -0
- package/lib/string-replaceall.js +33 -0
- package/lib/string-replaceall.js.map +1 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ Please do not add any polyfills for ECMA features that are Stage 3 or below. We
|
|
|
42
42
|
|
|
43
43
|
### Removing polyfills
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
Polyfills should only be removed after consulting with the `@github/web-systems` who will determine if a polyfill can be removed. This code is designed to be kept lightweight, we do not want to ship dozens of kb of polyfills.
|
|
46
46
|
|
|
47
47
|
As a polyfill is removed, it may be worth adding feature detection to the `baseSupport` const, to ensure that our baseline moves with our browser support matrix.
|
|
48
48
|
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function replaceChildren(this: Element | Document | DocumentFragment, ...children: Node[]): void;
|
|
2
|
+
export declare function isSupported(): boolean;
|
|
3
|
+
export declare function isPolyfilled(): boolean;
|
|
4
|
+
export declare function apply(): void;
|
|
5
|
+
//# sourceMappingURL=element-replacechildren.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-replacechildren.d.ts","sourceRoot":"","sources":["../src/element-replacechildren.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,gBAAgB,EAAE,GAAG,QAAQ,EAAE,IAAI,EAAE,QAG/F;AAGD,wBAAgB,WAAW,IAAI,OAAO,CASrC;AAGD,wBAAgB,YAAY,IAAI,OAAO,CAMtC;AAED,wBAAgB,KAAK,IAAI,IAAI,CAO5B"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function replaceChildren(...children) {
|
|
2
|
+
while (this.firstChild)
|
|
3
|
+
this.removeChild(this.firstChild);
|
|
4
|
+
this.append(...children);
|
|
5
|
+
}
|
|
6
|
+
/*#__PURE__*/
|
|
7
|
+
export function isSupported() {
|
|
8
|
+
return ('replaceChildren' in Element.prototype &&
|
|
9
|
+
typeof Element.prototype.replaceChildren === 'function' &&
|
|
10
|
+
'replaceChildren' in Document.prototype &&
|
|
11
|
+
typeof Document.prototype.replaceChildren === 'function' &&
|
|
12
|
+
'replaceChildren' in DocumentFragment.prototype &&
|
|
13
|
+
typeof DocumentFragment.prototype.replaceChildren === 'function');
|
|
14
|
+
}
|
|
15
|
+
/*#__PURE__*/
|
|
16
|
+
export function isPolyfilled() {
|
|
17
|
+
return (Element.prototype.replaceChildren === replaceChildren &&
|
|
18
|
+
Document.prototype.replaceChildren === replaceChildren &&
|
|
19
|
+
DocumentFragment.prototype.replaceChildren === replaceChildren);
|
|
20
|
+
}
|
|
21
|
+
export function apply() {
|
|
22
|
+
if (!isSupported()) {
|
|
23
|
+
Element.prototype.replaceChildren =
|
|
24
|
+
Document.prototype.replaceChildren =
|
|
25
|
+
DocumentFragment.prototype.replaceChildren =
|
|
26
|
+
replaceChildren;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=element-replacechildren.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-replacechildren.js","sourceRoot":"","sources":["../src/element-replacechildren.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,eAAe,CAA8C,GAAG,QAAgB;IAC9F,OAAO,IAAI,CAAC,UAAU;QAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACzD,IAAI,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAA;AAC1B,CAAC;AAED,aAAa;AACb,MAAM,UAAU,WAAW;IACzB,OAAO,CACL,iBAAiB,IAAI,OAAO,CAAC,SAAS;QACtC,OAAO,OAAO,CAAC,SAAS,CAAC,eAAe,KAAK,UAAU;QACvD,iBAAiB,IAAI,QAAQ,CAAC,SAAS;QACvC,OAAO,QAAQ,CAAC,SAAS,CAAC,eAAe,KAAK,UAAU;QACxD,iBAAiB,IAAI,gBAAgB,CAAC,SAAS;QAC/C,OAAO,gBAAgB,CAAC,SAAS,CAAC,eAAe,KAAK,UAAU,CACjE,CAAA;AACH,CAAC;AAED,aAAa;AACb,MAAM,UAAU,YAAY;IAC1B,OAAO,CACL,OAAO,CAAC,SAAS,CAAC,eAAe,KAAK,eAAe;QACrD,QAAQ,CAAC,SAAS,CAAC,eAAe,KAAK,eAAe;QACtD,gBAAgB,CAAC,SAAS,CAAC,eAAe,KAAK,eAAe,CAC/D,CAAA;AACH,CAAC;AAED,MAAM,UAAU,KAAK;IACnB,IAAI,CAAC,WAAW,EAAE,EAAE;QAClB,OAAO,CAAC,SAAS,CAAC,eAAe;YAC/B,QAAQ,CAAC,SAAS,CAAC,eAAe;gBAClC,gBAAgB,CAAC,SAAS,CAAC,eAAe;oBACxC,eAAe,CAAA;KACpB;AACH,CAAC"}
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA2DA,wBAAgB,WAAW,YAO1B;AAED,wBAAgB,YAAY,YAI3B;AAED,wBAAgB,KAAK,SAIpB"}
|
package/lib/index.js
CHANGED
|
@@ -3,8 +3,10 @@ import * as abortSignalTimeout from './abortsignal-timeout.js';
|
|
|
3
3
|
import * as aggregateError from './aggregateerror.js';
|
|
4
4
|
import * as arrayAt from './arraylike-at.js';
|
|
5
5
|
import * as cryptoRandomUUID from './crypto-randomuuid.js';
|
|
6
|
+
import * as elementReplaceChildren from './element-replacechildren.js';
|
|
6
7
|
import * as eventAbortSignal from './event-abortsignal.js';
|
|
7
8
|
import * as objectHasOwn from './object-hasown.js';
|
|
9
|
+
import * as promiseAllSettled from './promise-allsettled.js';
|
|
8
10
|
import * as promiseAny from './promise-any.js';
|
|
9
11
|
import * as requestIdleCallback from './requestidlecallback.js';
|
|
10
12
|
const baseSupport = typeof Blob === 'function' &&
|
|
@@ -21,55 +23,50 @@ const baseSupport = typeof Blob === 'function' &&
|
|
|
21
23
|
typeof HTMLDetailsElement === 'function' &&
|
|
22
24
|
typeof AbortController === 'function' &&
|
|
23
25
|
typeof AbortSignal === 'function' &&
|
|
26
|
+
typeof globalThis === 'object' &&
|
|
24
27
|
'entries' in FormData.prototype &&
|
|
25
28
|
'toggleAttribute' in Element.prototype &&
|
|
26
|
-
'replaceChildren' in Element.prototype &&
|
|
27
29
|
// ES2019
|
|
28
30
|
'fromEntries' in Object &&
|
|
29
31
|
'flatMap' in Array.prototype &&
|
|
30
32
|
'trimEnd' in String.prototype &&
|
|
31
33
|
// ES2020
|
|
32
|
-
'allSettled' in Promise &&
|
|
34
|
+
//'allSettled' in Promise && // Polyfilled
|
|
33
35
|
'matchAll' in String.prototype &&
|
|
34
36
|
// ES2021
|
|
35
|
-
'replaceAll' in String.prototype &&
|
|
37
|
+
//'replaceAll' in String.prototype && // Polyfilled
|
|
36
38
|
// 'any' in Promise && // Polyfilled
|
|
37
39
|
// ES2022
|
|
38
40
|
// 'at' in String.prototype && // Polyfilled
|
|
39
41
|
// 'at' in Array.prototype && // Polyfilled
|
|
40
42
|
true;
|
|
43
|
+
const polyfills = [
|
|
44
|
+
abortSignalAbort,
|
|
45
|
+
abortSignalTimeout,
|
|
46
|
+
aggregateError,
|
|
47
|
+
arrayAt,
|
|
48
|
+
cryptoRandomUUID,
|
|
49
|
+
elementReplaceChildren,
|
|
50
|
+
eventAbortSignal,
|
|
51
|
+
objectHasOwn,
|
|
52
|
+
promiseAllSettled,
|
|
53
|
+
promiseAny,
|
|
54
|
+
requestIdleCallback
|
|
55
|
+
];
|
|
41
56
|
export function isSupported() {
|
|
42
57
|
return (baseSupport &&
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
arrayAt.isSupported() &&
|
|
47
|
-
cryptoRandomUUID.isSupported() &&
|
|
48
|
-
eventAbortSignal.isSupported() &&
|
|
49
|
-
objectHasOwn.isSupported() &&
|
|
50
|
-
promiseAny.isSupported() &&
|
|
51
|
-
requestIdleCallback.isSupported());
|
|
58
|
+
polyfills.every(polyfill => {
|
|
59
|
+
polyfill.isSupported();
|
|
60
|
+
}));
|
|
52
61
|
}
|
|
53
62
|
export function isPolyfilled() {
|
|
54
|
-
return
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
arrayAt.isPolyfilled() &&
|
|
58
|
-
cryptoRandomUUID.isPolyfilled() &&
|
|
59
|
-
eventAbortSignal.isPolyfilled() &&
|
|
60
|
-
objectHasOwn.isPolyfilled() &&
|
|
61
|
-
promiseAny.isPolyfilled() &&
|
|
62
|
-
requestIdleCallback.isPolyfilled());
|
|
63
|
+
return polyfills.every(polyfill => {
|
|
64
|
+
polyfill.isPolyfilled();
|
|
65
|
+
});
|
|
63
66
|
}
|
|
64
67
|
export function apply() {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
arrayAt.apply();
|
|
69
|
-
cryptoRandomUUID.apply();
|
|
70
|
-
eventAbortSignal.apply();
|
|
71
|
-
objectHasOwn.apply();
|
|
72
|
-
promiseAny.apply();
|
|
73
|
-
requestIdleCallback.apply();
|
|
68
|
+
for (const polyfill of polyfills) {
|
|
69
|
+
polyfill.apply();
|
|
70
|
+
}
|
|
74
71
|
}
|
|
75
72
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,gBAAgB,MAAM,wBAAwB,CAAA;AAC1D,OAAO,KAAK,kBAAkB,MAAM,0BAA0B,CAAA;AAC9D,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AACrD,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,gBAAgB,MAAM,wBAAwB,CAAA;AAC1D,OAAO,KAAK,gBAAgB,MAAM,wBAAwB,CAAA;AAC1D,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,mBAAmB,MAAM,0BAA0B,CAAA;AAE/D,MAAM,WAAW,GACf,OAAO,IAAI,KAAK,UAAU;IAC1B,OAAO,mBAAmB,KAAK,UAAU;IACzC,OAAO,IAAI,KAAK,QAAQ;IACxB,OAAO,gBAAgB,KAAK,UAAU;IACtC,OAAO,eAAe,KAAK,UAAU;IACrC,OAAO,SAAS,KAAK,UAAU;IAC/B,OAAO,oBAAoB,KAAK,UAAU;IAC1C,OAAO,cAAc,KAAK,UAAU;IACpC,OAAO,WAAW,KAAK,UAAU;IACjC,OAAO,WAAW,KAAK,UAAU;IACjC,OAAO,cAAc,KAAK,QAAQ;IAClC,OAAO,kBAAkB,KAAK,UAAU;IACxC,OAAO,eAAe,KAAK,UAAU;IACrC,OAAO,WAAW,KAAK,UAAU;IACjC,SAAS,IAAI,QAAQ,CAAC,SAAS;IAC/B,iBAAiB,IAAI,OAAO,CAAC,SAAS;IACtC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,gBAAgB,MAAM,wBAAwB,CAAA;AAC1D,OAAO,KAAK,kBAAkB,MAAM,0BAA0B,CAAA;AAC9D,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AACrD,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,gBAAgB,MAAM,wBAAwB,CAAA;AAC1D,OAAO,KAAK,sBAAsB,MAAM,8BAA8B,CAAA;AACtE,OAAO,KAAK,gBAAgB,MAAM,wBAAwB,CAAA;AAC1D,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,iBAAiB,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,mBAAmB,MAAM,0BAA0B,CAAA;AAE/D,MAAM,WAAW,GACf,OAAO,IAAI,KAAK,UAAU;IAC1B,OAAO,mBAAmB,KAAK,UAAU;IACzC,OAAO,IAAI,KAAK,QAAQ;IACxB,OAAO,gBAAgB,KAAK,UAAU;IACtC,OAAO,eAAe,KAAK,UAAU;IACrC,OAAO,SAAS,KAAK,UAAU;IAC/B,OAAO,oBAAoB,KAAK,UAAU;IAC1C,OAAO,cAAc,KAAK,UAAU;IACpC,OAAO,WAAW,KAAK,UAAU;IACjC,OAAO,WAAW,KAAK,UAAU;IACjC,OAAO,cAAc,KAAK,QAAQ;IAClC,OAAO,kBAAkB,KAAK,UAAU;IACxC,OAAO,eAAe,KAAK,UAAU;IACrC,OAAO,WAAW,KAAK,UAAU;IACjC,OAAO,UAAU,KAAK,QAAQ;IAC9B,SAAS,IAAI,QAAQ,CAAC,SAAS;IAC/B,iBAAiB,IAAI,OAAO,CAAC,SAAS;IACtC,SAAS;IACT,aAAa,IAAI,MAAM;IACvB,SAAS,IAAI,KAAK,CAAC,SAAS;IAC5B,SAAS,IAAI,MAAM,CAAC,SAAS;IAC7B,SAAS;IACT,0CAA0C;IAC1C,UAAU,IAAI,MAAM,CAAC,SAAS;IAC9B,SAAS;IACT,mDAAmD;IACnD,oCAAoC;IACpC,SAAS;IACT,4CAA4C;IAC5C,2CAA2C;IAC3C,IAAI,CAAA;AAEN,MAAM,SAAS,GAAG;IAChB,gBAAgB;IAChB,kBAAkB;IAClB,cAAc;IACd,OAAO;IACP,gBAAgB;IAChB,sBAAsB;IACtB,gBAAgB;IAChB,YAAY;IACZ,iBAAiB;IACjB,UAAU;IACV,mBAAmB;CACpB,CAAA;AAED,MAAM,UAAU,WAAW;IACzB,OAAO,CACL,WAAW;QACX,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE;YACzB,QAAQ,CAAC,WAAW,EAAE,CAAA;QACxB,CAAC,CAAC,CACH,CAAA;AACH,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE;QAChC,QAAQ,CAAC,YAAY,EAAE,CAAA;IACzB,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,UAAU,KAAK;IACnB,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;QAChC,QAAQ,CAAC,KAAK,EAAE,CAAA;KACjB;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function promiseAllSettled<T extends readonly unknown[] | []>(values: T): Promise<{
|
|
2
|
+
-readonly [P in keyof T]: PromiseSettledResult<Awaited<T[P]>>;
|
|
3
|
+
}>;
|
|
4
|
+
export declare function isSupported(): boolean;
|
|
5
|
+
export declare function isPolyfilled(): boolean;
|
|
6
|
+
export declare function apply(): void;
|
|
7
|
+
//# sourceMappingURL=promise-allsettled.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise-allsettled.d.ts","sourceRoot":"","sources":["../src/promise-allsettled.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,GAAG,EAAE,EACjE,MAAM,EAAE,CAAC,GACR,OAAO,CAAC;IAAC,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAC,CAAC,CAU1E;AAGD,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAGD,wBAAgB,YAAY,IAAI,OAAO,CAEtC;AAED,wBAAgB,KAAK,IAAI,IAAI,CAI5B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function promiseAllSettled(values) {
|
|
2
|
+
return Promise.all(values.map(p =>
|
|
3
|
+
// eslint-disable-next-line github/no-then
|
|
4
|
+
Promise.resolve(p).then((value) => ({ status: 'fulfilled', value }), (reason) => ({ status: 'rejected', reason }))));
|
|
5
|
+
}
|
|
6
|
+
/*#__PURE__*/
|
|
7
|
+
export function isSupported() {
|
|
8
|
+
return 'allSettled' in Promise && typeof Promise.allSettled === 'function';
|
|
9
|
+
}
|
|
10
|
+
/*#__PURE__*/
|
|
11
|
+
export function isPolyfilled() {
|
|
12
|
+
return Promise.all === promiseAllSettled;
|
|
13
|
+
}
|
|
14
|
+
export function apply() {
|
|
15
|
+
if (!isSupported()) {
|
|
16
|
+
Promise.allSettled = promiseAllSettled;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=promise-allsettled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise-allsettled.js","sourceRoot":"","sources":["../src/promise-allsettled.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,iBAAiB,CAC/B,MAAS;IAET,OAAO,OAAO,CAAC,GAAG,CAChB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;IACb,0CAA0C;IAC1C,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CACrB,CAAC,KAAc,EAAE,EAAE,CAAC,CAAC,EAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAC,CAAC,EAClD,CAAC,MAAe,EAAE,EAAE,CAAC,CAAC,EAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAC,CAAC,CACpD,CACF,CACqF,CAAA;AAC1F,CAAC;AAED,aAAa;AACb,MAAM,UAAU,WAAW;IACzB,OAAO,YAAY,IAAI,OAAO,IAAI,OAAO,OAAO,CAAC,UAAU,KAAK,UAAU,CAAA;AAC5E,CAAC;AAED,aAAa;AACb,MAAM,UAAU,YAAY;IAC1B,OAAO,OAAO,CAAC,GAAG,KAAK,iBAAiB,CAAA;AAC1C,CAAC;AAED,MAAM,UAAU,KAAK;IACnB,IAAI,CAAC,WAAW,EAAE,EAAE;QAClB,OAAO,CAAC,UAAU,GAAG,iBAAiB,CAAA;KACvC;AACH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function stringReplaceAll(this: string, searchValue: RegExp | string, replaceValue: ((substring: string, ...args: unknown[]) => string) | string): string;
|
|
2
|
+
export declare function isSupported(): boolean;
|
|
3
|
+
export declare function isPolyfilled(): boolean;
|
|
4
|
+
export declare function apply(): void;
|
|
5
|
+
//# sourceMappingURL=string-replaceall.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string-replaceall.d.ts","sourceRoot":"","sources":["../src/string-replaceall.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,YAAY,EAAE,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,MAAM,CAAC,GAAG,MAAM,GACzE,MAAM,CAiBR;AAGD,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAGD,wBAAgB,YAAY,IAAI,OAAO,CAEtC;AAED,wBAAgB,KAAK,IAAI,IAAI,CAI5B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export function stringReplaceAll(searchValue, replaceValue) {
|
|
2
|
+
if (searchValue instanceof RegExp)
|
|
3
|
+
return this.replace(searchValue, replaceValue);
|
|
4
|
+
let pos = -1;
|
|
5
|
+
let endOfLastMatch = 0;
|
|
6
|
+
let result = '';
|
|
7
|
+
if (typeof replaceValue === 'function') {
|
|
8
|
+
const unwrapped = replaceValue;
|
|
9
|
+
replaceValue = () => unwrapped(searchValue, pos, this);
|
|
10
|
+
}
|
|
11
|
+
pos = this.indexOf(searchValue, pos + 1);
|
|
12
|
+
while (pos !== -1) {
|
|
13
|
+
result += this.substring(endOfLastMatch, pos);
|
|
14
|
+
result += searchValue.replace(searchValue, replaceValue);
|
|
15
|
+
endOfLastMatch = pos + searchValue.length;
|
|
16
|
+
pos = this.indexOf(searchValue, pos + 1);
|
|
17
|
+
}
|
|
18
|
+
return result + this.substring(endOfLastMatch);
|
|
19
|
+
}
|
|
20
|
+
/*#__PURE__*/
|
|
21
|
+
export function isSupported() {
|
|
22
|
+
return 'replaceAll' in String.prototype && typeof String.prototype.replaceAll === 'function';
|
|
23
|
+
}
|
|
24
|
+
/*#__PURE__*/
|
|
25
|
+
export function isPolyfilled() {
|
|
26
|
+
return String.prototype.replaceAll === stringReplaceAll;
|
|
27
|
+
}
|
|
28
|
+
export function apply() {
|
|
29
|
+
if (!isSupported()) {
|
|
30
|
+
String.prototype.replaceAll = stringReplaceAll;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=string-replaceall.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string-replaceall.js","sourceRoot":"","sources":["../src/string-replaceall.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,gBAAgB,CAE9B,WAA4B,EAC5B,YAA0E;IAE1E,IAAI,WAAW,YAAY,MAAM;QAAE,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,YAAiC,CAAC,CAAA;IACtG,IAAI,GAAG,GAAG,CAAC,CAAC,CAAA;IACZ,IAAI,cAAc,GAAG,CAAC,CAAA;IACtB,IAAI,MAAM,GAAG,EAAE,CAAA;IACf,IAAI,OAAO,YAAY,KAAK,UAAU,EAAE;QACtC,MAAM,SAAS,GAAG,YAAY,CAAA;QAC9B,YAAY,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC,WAAW,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;KACvD;IACD,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,CAAC,CAAA;IACxC,OAAO,GAAG,KAAK,CAAC,CAAC,EAAE;QACjB,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,GAAG,CAAC,CAAA;QAC7C,MAAM,IAAI,WAAW,CAAC,OAAO,CAAC,WAAW,EAAE,YAAsB,CAAC,CAAA;QAClE,cAAc,GAAG,GAAG,GAAG,WAAW,CAAC,MAAM,CAAA;QACzC,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,CAAC,CAAA;KACzC;IACD,OAAO,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAA;AAChD,CAAC;AAED,aAAa;AACb,MAAM,UAAU,WAAW;IACzB,OAAO,YAAY,IAAI,MAAM,CAAC,SAAS,IAAI,OAAO,MAAM,CAAC,SAAS,CAAC,UAAU,KAAK,UAAU,CAAA;AAC9F,CAAC;AAED,aAAa;AACb,MAAM,UAAU,YAAY;IAC1B,OAAO,MAAM,CAAC,SAAS,CAAC,UAAU,KAAK,gBAAgB,CAAA;AACzD,CAAC;AAED,MAAM,UAAU,KAAK;IACnB,IAAI,CAAC,WAAW,EAAE,EAAE;QAClB,MAAM,CAAC,SAAS,CAAC,UAAU,GAAG,gBAAgB,CAAA;KAC/C;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@github/browser-support",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Polyfills and Capable Browser detection",
|
|
5
5
|
"homepage": "https://github.github.io/browser-support",
|
|
6
6
|
"bugs": {
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"lint": "eslint . --ignore-path .gitignore",
|
|
28
28
|
"pretest": "npm run build",
|
|
29
29
|
"test": "npm run lint && karma start test/karma.config.cjs",
|
|
30
|
+
"prepublish": "npm run build",
|
|
30
31
|
"postpublish": "npm publish --ignore-scripts --@github:registry='https://npm.pkg.github.com'"
|
|
31
32
|
},
|
|
32
33
|
"prettier": "@github/prettier-config",
|