mainnet-js 2.6.7 → 2.7.1

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 (98) hide show
  1. package/dist/index.html +1 -1
  2. package/dist/{mainnet-2.6.7.js → mainnet-2.7.1.js} +446 -156
  3. package/dist/module/cli.js +0 -4
  4. package/dist/module/cli.js.map +1 -1
  5. package/dist/module/index.d.ts +1 -3
  6. package/dist/module/index.d.ts.map +1 -1
  7. package/dist/module/index.js +1 -3
  8. package/dist/module/index.js.map +1 -1
  9. package/dist/module/network/ElectrumNetworkProvider.d.ts +21 -27
  10. package/dist/module/network/ElectrumNetworkProvider.d.ts.map +1 -1
  11. package/dist/module/network/ElectrumNetworkProvider.js +92 -102
  12. package/dist/module/network/ElectrumNetworkProvider.js.map +1 -1
  13. package/dist/module/network/NetworkProvider.d.ts +9 -22
  14. package/dist/module/network/NetworkProvider.d.ts.map +1 -1
  15. package/dist/module/network/constant.d.ts +0 -21
  16. package/dist/module/network/constant.d.ts.map +1 -1
  17. package/dist/module/network/constant.js +0 -21
  18. package/dist/module/network/constant.js.map +1 -1
  19. package/dist/module/network/default.d.ts +2 -2
  20. package/dist/module/network/default.d.ts.map +1 -1
  21. package/dist/module/network/default.js +15 -45
  22. package/dist/module/network/default.js.map +1 -1
  23. package/dist/module/network/interface.d.ts +2 -8
  24. package/dist/module/network/interface.d.ts.map +1 -1
  25. package/dist/module/network/util.d.ts.map +1 -1
  26. package/dist/module/network/util.js +4 -5
  27. package/dist/module/network/util.js.map +1 -1
  28. package/dist/module/rate/ExchangeRate.js +2 -1
  29. package/dist/module/rate/ExchangeRate.js.map +1 -1
  30. package/dist/module/transaction/Wif.d.ts.map +1 -1
  31. package/dist/module/transaction/Wif.js +1 -1
  32. package/dist/module/transaction/Wif.js.map +1 -1
  33. package/dist/module/wallet/Base.d.ts +282 -88
  34. package/dist/module/wallet/Base.d.ts.map +1 -1
  35. package/dist/module/wallet/Base.js +1058 -215
  36. package/dist/module/wallet/Base.js.map +1 -1
  37. package/dist/module/wallet/Util.d.ts +7 -54
  38. package/dist/module/wallet/Util.d.ts.map +1 -1
  39. package/dist/module/wallet/Util.js +12 -79
  40. package/dist/module/wallet/Util.js.map +1 -1
  41. package/dist/module/wallet/Wif.d.ts +46 -251
  42. package/dist/module/wallet/Wif.d.ts.map +1 -1
  43. package/dist/module/wallet/Wif.js +126 -1026
  44. package/dist/module/wallet/Wif.js.map +1 -1
  45. package/dist/module/wallet/createWallet.d.ts +2 -1
  46. package/dist/module/wallet/createWallet.d.ts.map +1 -1
  47. package/dist/module/wallet/createWallet.js +2 -3
  48. package/dist/module/wallet/createWallet.js.map +1 -1
  49. package/dist/module/wallet/interface.d.ts +2 -4
  50. package/dist/module/wallet/interface.d.ts.map +1 -1
  51. package/dist/tsconfig.tsbuildinfo +1 -1
  52. package/package.json +6 -12
  53. package/src/cli.ts +0 -4
  54. package/src/index.ts +1 -5
  55. package/src/network/ElectrumNetworkProvider.ts +133 -188
  56. package/src/network/NetworkProvider.ts +9 -30
  57. package/src/network/Rpc.test.ts +14 -5
  58. package/src/network/constant.ts +0 -23
  59. package/src/network/default.ts +26 -66
  60. package/src/network/electrum.test.ts +2 -4
  61. package/src/network/interface.ts +2 -9
  62. package/src/network/util.ts +6 -7
  63. package/src/rate/ExchangeRate.test.ts +1 -1
  64. package/src/rate/ExchangeRate.ts +2 -1
  65. package/{polyfill/json.js → src/test/json.test.ts} +7 -1
  66. package/src/transaction/Wif.ts +2 -1
  67. package/src/wallet/Base.ts +1520 -273
  68. package/src/wallet/Cashtokens.test.headless.js +1 -1
  69. package/src/wallet/Cashtokens.test.ts +7 -8
  70. package/src/wallet/Util.ts +20 -102
  71. package/src/wallet/Wif.bip39.test.ts +3 -3
  72. package/src/wallet/Wif.test.ts +31 -25
  73. package/src/wallet/Wif.ts +174 -1493
  74. package/src/wallet/Wif.watchOnly.test.ts +5 -5
  75. package/src/wallet/createWallet.ts +11 -10
  76. package/src/wallet/interface.ts +3 -4
  77. package/webpack.config.cjs +4 -55
  78. package/dist/module/qr/Qr.d.ts +0 -9
  79. package/dist/module/qr/Qr.d.ts.map +0 -1
  80. package/dist/module/qr/Qr.js +0 -22
  81. package/dist/module/qr/Qr.js.map +0 -1
  82. package/dist/module/qr/interface.d.ts +0 -6
  83. package/dist/module/qr/interface.d.ts.map +0 -1
  84. package/dist/module/qr/interface.js +0 -2
  85. package/dist/module/qr/interface.js.map +0 -1
  86. package/dist/module/util/eventsource.d.ts +0 -3
  87. package/dist/module/util/eventsource.d.ts.map +0 -1
  88. package/dist/module/util/eventsource.js +0 -11
  89. package/dist/module/util/eventsource.js.map +0 -1
  90. package/polyfill/README.md +0 -1
  91. package/polyfill/eventsource.js +0 -6
  92. package/polyfill/support/types.js +0 -286
  93. package/polyfill/util.cjs +0 -249
  94. package/src/network/default.test.ts +0 -37
  95. package/src/qr/Qr.test.ts +0 -14
  96. package/src/qr/Qr.ts +0 -24
  97. package/src/qr/interface.ts +0 -5
  98. package/src/util/eventsource.ts +0 -12
@@ -18,17 +18,17 @@ describe(`Test creation of wallet from walletId`, () => {
18
18
  );
19
19
 
20
20
  expect(w.cashaddr!.startsWith("bchreg:")).toBeTruthy();
21
- expect(w.address!).toBe(ADDRESS);
21
+ expect(w.cashaddr!).toBe(ADDRESS);
22
22
  expect(w.cashaddr!).toBe(ADDRESS);
23
23
  expect(w.tokenaddr!).toBe(ADDRESS_TOKEN);
24
24
  let w2 = await RegTestWallet.watchOnly(w.cashaddr!);
25
25
 
26
- expect(w2.address!).toBe(ADDRESS);
26
+ expect(w2.cashaddr!).toBe(ADDRESS);
27
27
  expect(w2.cashaddr!).toBe(ADDRESS);
28
28
  expect(w2.tokenaddr!).toBe(ADDRESS_TOKEN);
29
29
 
30
30
  let w3 = await RegTestWallet.watchOnly(ADDRESS_TOKEN);
31
- expect(w3.address!).toBe(ADDRESS);
31
+ expect(w3.cashaddr!).toBe(ADDRESS);
32
32
  expect(w3.cashaddr!).toBe(ADDRESS);
33
33
  expect(w3.tokenaddr!).toBe(ADDRESS_TOKEN);
34
34
  });
@@ -42,7 +42,7 @@ describe(`Test creation of wallet from walletId`, () => {
42
42
  );
43
43
 
44
44
  expect(w.cashaddr!.startsWith("bitcoincash:")).toBeTruthy();
45
- expect(w.address!).toBe(ADDRESS);
45
+ expect(w.cashaddr!).toBe(ADDRESS);
46
46
  });
47
47
 
48
48
  test("Get create a p2sh watch address", async () => {
@@ -53,6 +53,6 @@ describe(`Test creation of wallet from walletId`, () => {
53
53
  );
54
54
 
55
55
  expect(w.cashaddr!.startsWith("bitcoincash:")).toBeTruthy();
56
- expect(w.address!).toBe(ADDRESS);
56
+ expect(w.cashaddr!).toBe(ADDRESS);
57
57
  });
58
58
  });
@@ -1,17 +1,19 @@
1
+ import { prefixFromNetworkMap } from "../enum.js";
2
+ import {
3
+ getNamedWalletId,
4
+ RegTestWatchWallet,
5
+ TestNetWatchWallet,
6
+ WatchWallet,
7
+ } from "./Base.js";
1
8
  import {
2
- Wallet,
3
- TestNetWallet,
4
9
  RegTestWallet,
5
- WifWallet,
6
- TestNetWifWallet,
7
10
  RegTestWifWallet,
8
- WatchWallet,
9
- TestNetWatchWallet,
10
- RegTestWatchWallet,
11
+ TestNetWallet,
12
+ TestNetWifWallet,
13
+ Wallet,
14
+ WifWallet,
11
15
  } from "./Wif.js";
12
- import { getNamedWalletId } from "./Base.js";
13
16
  import { WalletRequestI, WalletResponseI } from "./interface.js";
14
- import { prefixFromNetworkMap } from "../enum.js";
15
17
 
16
18
  // Convenience map to access classes by types and network
17
19
  export const walletClassMap = {
@@ -199,7 +201,6 @@ function asJsonResponse(wallet: Wallet): WalletResponseI {
199
201
  name: wallet.name,
200
202
  cashaddr: wallet.cashaddr as string,
201
203
  walletId: wallet.toString(),
202
- wif: wallet.privateKeyWif,
203
204
  network: wallet.network as any,
204
205
  };
205
206
  }
@@ -1,6 +1,5 @@
1
1
  import { WalletTypeEnum, FeePaidByEnum } from "./enum.js";
2
2
  import { NetworkEnum } from "../enum.js";
3
- import { ImageI } from "../qr/interface.js";
4
3
  import { ElectrumRawTransaction } from "../network/interface.js";
5
4
  import { BalanceResponse } from "../util/balanceObjectFromSatoshi.js";
6
5
  import { UtxoI } from "../interface.js";
@@ -66,8 +65,8 @@ export interface MnemonicI {
66
65
  export interface WalletI {
67
66
  // Accessors
68
67
  getDepositAddress(): string;
69
- getDepositQr(): ImageI;
70
- getSeed(): MnemonicI;
68
+ getTokenDepositAddress(): string;
69
+ // getSeed(): MnemonicI;
71
70
  // getNetworkProvider(network: NetworkType): any;
72
71
  // generate(): Promise<this>;
73
72
 
@@ -101,4 +100,4 @@ export interface WaitForTransactionResponse {
101
100
  balance?: BalanceResponse;
102
101
  }
103
102
 
104
- export type CancelWatchFn = () => Promise<void>;
103
+ export type CancelFn = () => Promise<void>;
@@ -2,8 +2,6 @@ const { merge } = require("webpack-merge");
2
2
  const packageJson = require("./package.json");
3
3
  const HtmlWebpackPlugin = require("html-webpack-plugin");
4
4
  const InjectBodyPlugin = require("inject-body-webpack-plugin").default;
5
- const BundleAnalyzerPlugin =
6
- require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
7
5
  const CircularDependencyPlugin = require("circular-dependency-plugin");
8
6
  const __basedir = require("path").resolve(__dirname, "../../");
9
7
 
@@ -89,37 +87,10 @@ const browserConfig = {
89
87
  ],
90
88
  resolve: {
91
89
  alias: {
92
- bufferutil: false,
93
- child_process: false,
94
90
  crypto: false,
95
- dns: false,
96
- events: require.resolve("events/"),
97
- eventsource: false,
98
- fs: false,
99
- http: false,
100
- https: false,
101
- libpq: false,
102
- module: false,
103
- net: false,
104
- os: false,
105
- "parse-database-url": false,
106
- path: false,
107
- pg: false,
108
- "pg-format": false,
109
- "pg-native": false,
110
- tls: false,
111
- url: false,
112
- zlib: false,
113
- [path.resolve(__dirname, "./src/webhook/index.ts")]: false,
114
- [path.resolve(__dirname, "./src/webhook/interface.ts")]: false,
115
- [path.resolve(__dirname, "./src/webhook/Webhook.ts")]: false,
116
- [path.resolve(__dirname, "./src/webhook/WebhookBch.ts")]: false,
117
- [path.resolve(__dirname, "./src/webhook/WebhookWorker.ts")]: false,
118
- [path.resolve(__dirname, "./src/db/SqlProvider.ts")]: false,
119
- },
120
- fallback: {
121
- stream: require.resolve("stream-browserify"),
91
+ child_process: false,
122
92
  },
93
+ fallback: {},
123
94
  },
124
95
  };
125
96
 
@@ -132,32 +103,10 @@ const webWorkerConfig = {
132
103
  },
133
104
  resolve: {
134
105
  alias: {
135
- bufferutil: false,
136
- child_process: false,
137
106
  crypto: false,
138
- dns: false,
139
- events: require.resolve("events/"),
140
- eventsource: false,
141
- fs: false,
142
- http: false,
143
- https: false,
144
- libpq: false,
145
- module: false,
146
- net: false,
147
- os: false,
148
- "parse-database-url": false,
149
- path: false,
150
- pg: false,
151
- "pg-format": false,
152
- "pg-native": false,
153
- solc: false,
154
- tls: false,
155
- url: false,
156
- zlib: false,
157
- },
158
- fallback: {
159
- stream: require.resolve("stream-browserify"),
107
+ child_process: false,
160
108
  },
109
+ fallback: {},
161
110
  },
162
111
  };
163
112
 
@@ -1,9 +0,0 @@
1
- import { ImageI } from "./interface.js";
2
- /**
3
- * qrAddress returns a qr code for a given cashaddress as raw utf-8 svg
4
- * @param {string} address
5
- * @param {} size=256 The width and height of the returned image
6
- * @returns Image
7
- */
8
- export declare function qrAddress(address: string, size?: number): ImageI;
9
- //# sourceMappingURL=Qr.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Qr.d.ts","sourceRoot":"","sources":["../../../src/qr/Qr.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,SAAM,GAAG,MAAM,CAa7D"}
@@ -1,22 +0,0 @@
1
- import QRCode from "qrcode-svg";
2
- import { btoa } from "../util/base64.js";
3
- /**
4
- * qrAddress returns a qr code for a given cashaddress as raw utf-8 svg
5
- * @param {string} address
6
- * @param {} size=256 The width and height of the returned image
7
- * @returns Image
8
- */
9
- export function qrAddress(address, size = 256) {
10
- let svg = new QRCode({
11
- content: address,
12
- width: size,
13
- height: size,
14
- }).svg();
15
- let svgB64 = btoa(svg);
16
- return {
17
- src: `data:image/svg+xml;base64,${svgB64}`,
18
- title: address,
19
- alt: "a Bitcoin Cash address QR Code",
20
- };
21
- }
22
- //# sourceMappingURL=Qr.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Qr.js","sourceRoot":"","sources":["../../../src/qr/Qr.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,YAAY,CAAC;AAEhC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,OAAe,EAAE,IAAI,GAAG,GAAG;IACnD,IAAI,GAAG,GAAG,IAAI,MAAM,CAAC;QACnB,OAAO,EAAE,OAAO;QAChB,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,IAAI;KACb,CAAC,CAAC,GAAG,EAAE,CAAC;IAET,IAAI,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACvB,OAAO;QACL,GAAG,EAAE,6BAA6B,MAAM,EAAE;QAC1C,KAAK,EAAE,OAAO;QACd,GAAG,EAAE,gCAAgC;KACtC,CAAC;AACJ,CAAC"}
@@ -1,6 +0,0 @@
1
- export interface ImageI {
2
- src: string;
3
- title: string;
4
- alt: string;
5
- }
6
- //# sourceMappingURL=interface.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/qr/interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=interface.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../src/qr/interface.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- declare let EventSource: any;
2
- export default EventSource;
3
- //# sourceMappingURL=eventsource.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"eventsource.d.ts","sourceRoot":"","sources":["../../../src/util/eventsource.ts"],"names":[],"mappings":"AAIA,QAAA,IAAI,WAAW,KAAA,CAAC;AAOhB,eAAe,WAAW,CAAC"}
@@ -1,11 +0,0 @@
1
- import { getRuntimePlatform } from "./getRuntimePlatform.js";
2
- import { default as ES } from "eventsource";
3
- let EventSource;
4
- if (getRuntimePlatform() != "node") {
5
- EventSource = globalThis.EventSource;
6
- }
7
- else {
8
- EventSource = ES;
9
- }
10
- export default EventSource;
11
- //# sourceMappingURL=eventsource.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"eventsource.js","sourceRoot":"","sources":["../../../src/util/eventsource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,aAAa,CAAC;AAE5C,IAAI,WAAW,CAAC;AAChB,IAAI,kBAAkB,EAAE,IAAI,MAAM,EAAE,CAAC;IACnC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC;AACvC,CAAC;KAAM,CAAC;IACN,WAAW,GAAG,EAAE,CAAC;AACnB,CAAC;AAED,eAAe,WAAW,CAAC"}
@@ -1 +0,0 @@
1
- This directory contains polyfills for core dependencies, primarily cashscript.
@@ -1,6 +0,0 @@
1
- if (typeof window === "object") {
2
- module.exports = window.EventSource;
3
- } else {
4
- var EventSource = require("eventsource/");
5
- module.exports = EventSource;
6
- }
@@ -1,286 +0,0 @@
1
- // Currently in sync with Node.js lib/internal/util/types.js
2
- // https://github.com/nodejs/node/commit/112cc7c27551254aa2b17098fb774867f05ed0d9
3
-
4
- "use strict";
5
-
6
- var isArgumentsObject = require("is-arguments");
7
- var isGeneratorFunction = require("is-generator-function");
8
- var whichTypedArray = require("which-typed-array");
9
- var isTypedArray = require("is-typed-array");
10
-
11
- function uncurryThis(f) {
12
- return f.call.bind(f);
13
- }
14
-
15
- var BigIntSupported = typeof BigInt !== "undefined";
16
- var SymbolSupported = typeof Symbol !== "undefined";
17
-
18
- var ObjectToString = uncurryThis(Object.prototype.toString);
19
-
20
- var numberValue = uncurryThis(Number.prototype.valueOf);
21
- var stringValue = uncurryThis(String.prototype.valueOf);
22
- var booleanValue = uncurryThis(Boolean.prototype.valueOf);
23
-
24
- if (BigIntSupported) {
25
- var bigIntValue = uncurryThis(BigInt.prototype.valueOf);
26
- }
27
-
28
- if (SymbolSupported) {
29
- var symbolValue = uncurryThis(Symbol.prototype.valueOf);
30
- }
31
-
32
- function checkBoxedPrimitive(value, prototypeValueOf) {
33
- if (typeof value !== "object") {
34
- return false;
35
- }
36
- try {
37
- prototypeValueOf(value);
38
- return true;
39
- } catch (e) {
40
- return false;
41
- }
42
- }
43
-
44
- exports.isArgumentsObject = isArgumentsObject;
45
- exports.isGeneratorFunction = isGeneratorFunction;
46
- exports.isTypedArray = isTypedArray;
47
-
48
- // Taken from here and modified for better browser support
49
- // https://github.com/sindresorhus/p-is-promise/blob/cda35a513bda03f977ad5cde3a079d237e82d7ef/index.js
50
- function isPromise(input) {
51
- return (
52
- (typeof Promise !== "undefined" && input instanceof Promise) ||
53
- (input !== null &&
54
- typeof input === "object" &&
55
- typeof input.then === "function" &&
56
- typeof input.catch === "function")
57
- );
58
- }
59
- exports.isPromise = isPromise;
60
-
61
- function isArrayBufferView(value) {
62
- if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
63
- return ArrayBuffer.isView(value);
64
- }
65
-
66
- return isTypedArray(value) || isDataView(value);
67
- }
68
- exports.isArrayBufferView = isArrayBufferView;
69
-
70
- function isUint8Array(value) {
71
- return whichTypedArray(value) === "Uint8Array";
72
- }
73
- exports.isUint8Array = isUint8Array;
74
-
75
- function isUint8ClampedArray(value) {
76
- return whichTypedArray(value) === "Uint8ClampedArray";
77
- }
78
- exports.isUint8ClampedArray = isUint8ClampedArray;
79
-
80
- function isUint16Array(value) {
81
- return whichTypedArray(value) === "Uint16Array";
82
- }
83
- exports.isUint16Array = isUint16Array;
84
-
85
- function isUint32Array(value) {
86
- return whichTypedArray(value) === "Uint32Array";
87
- }
88
- exports.isUint32Array = isUint32Array;
89
-
90
- function isInt8Array(value) {
91
- return whichTypedArray(value) === "Int8Array";
92
- }
93
- exports.isInt8Array = isInt8Array;
94
-
95
- function isInt16Array(value) {
96
- return whichTypedArray(value) === "Int16Array";
97
- }
98
- exports.isInt16Array = isInt16Array;
99
-
100
- function isInt32Array(value) {
101
- return whichTypedArray(value) === "Int32Array";
102
- }
103
- exports.isInt32Array = isInt32Array;
104
-
105
- function isFloat32Array(value) {
106
- return whichTypedArray(value) === "Float32Array";
107
- }
108
- exports.isFloat32Array = isFloat32Array;
109
-
110
- function isFloat64Array(value) {
111
- return whichTypedArray(value) === "Float64Array";
112
- }
113
- exports.isFloat64Array = isFloat64Array;
114
-
115
- function isBigInt64Array(value) {
116
- return whichTypedArray(value) === "BigInt64Array";
117
- }
118
- exports.isBigInt64Array = isBigInt64Array;
119
-
120
- function isBigUint64Array(value) {
121
- return whichTypedArray(value) === "BigUint64Array";
122
- }
123
- exports.isBigUint64Array = isBigUint64Array;
124
-
125
- function isMapToString(value) {
126
- return ObjectToString(value) === "[object Map]";
127
- }
128
- isMapToString.working = typeof Map !== "undefined" && isMapToString(new Map());
129
-
130
- function isMap(value) {
131
- if (typeof Map === "undefined") {
132
- return false;
133
- }
134
-
135
- return isMapToString.working ? isMapToString(value) : value instanceof Map;
136
- }
137
- exports.isMap = isMap;
138
-
139
- function isSetToString(value) {
140
- return ObjectToString(value) === "[object Set]";
141
- }
142
- isSetToString.working = typeof Set !== "undefined" && isSetToString(new Set());
143
- function isSet(value) {
144
- if (typeof Set === "undefined") {
145
- return false;
146
- }
147
-
148
- return isSetToString.working ? isSetToString(value) : value instanceof Set;
149
- }
150
- exports.isSet = isSet;
151
-
152
- function isWeakMapToString(value) {
153
- return ObjectToString(value) === "[object WeakMap]";
154
- }
155
- isWeakMapToString.working =
156
- typeof WeakMap !== "undefined" && isWeakMapToString(new WeakMap());
157
- function isWeakMap(value) {
158
- if (typeof WeakMap === "undefined") {
159
- return false;
160
- }
161
-
162
- return isWeakMapToString.working
163
- ? isWeakMapToString(value)
164
- : value instanceof WeakMap;
165
- }
166
- exports.isWeakMap = isWeakMap;
167
-
168
- function isWeakSetToString(value) {
169
- return ObjectToString(value) === "[object WeakSet]";
170
- }
171
- isWeakSetToString.working =
172
- typeof WeakSet !== "undefined" && isWeakSetToString(new WeakSet());
173
- function isWeakSet(value) {
174
- return isWeakSetToString(value);
175
- }
176
- exports.isWeakSet = isWeakSet;
177
-
178
- function isArrayBufferToString(value) {
179
- return ObjectToString(value) === "[object ArrayBuffer]";
180
- }
181
- isArrayBufferToString.working =
182
- typeof ArrayBuffer !== "undefined" &&
183
- isArrayBufferToString(new ArrayBuffer());
184
- function isArrayBuffer(value) {
185
- if (typeof ArrayBuffer === "undefined") {
186
- return false;
187
- }
188
-
189
- return isArrayBufferToString.working
190
- ? isArrayBufferToString(value)
191
- : value instanceof ArrayBuffer;
192
- }
193
- exports.isArrayBuffer = isArrayBuffer;
194
-
195
- function isDataViewToString(value) {
196
- return ObjectToString(value) === "[object DataView]";
197
- }
198
- isDataViewToString.working =
199
- typeof ArrayBuffer !== "undefined" &&
200
- typeof DataView !== "undefined" &&
201
- isDataViewToString(new DataView(new ArrayBuffer(1), 0, 1));
202
- function isDataView(value) {
203
- if (typeof DataView === "undefined") {
204
- return false;
205
- }
206
-
207
- return isDataViewToString.working
208
- ? isDataViewToString(value)
209
- : value instanceof DataView;
210
- }
211
- exports.isDataView = isDataView;
212
-
213
- function isAsyncFunction(value) {
214
- return ObjectToString(value) === "[object AsyncFunction]";
215
- }
216
- exports.isAsyncFunction = isAsyncFunction;
217
-
218
- function isMapIterator(value) {
219
- return ObjectToString(value) === "[object Map Iterator]";
220
- }
221
- exports.isMapIterator = isMapIterator;
222
-
223
- function isSetIterator(value) {
224
- return ObjectToString(value) === "[object Set Iterator]";
225
- }
226
- exports.isSetIterator = isSetIterator;
227
-
228
- function isGeneratorObject(value) {
229
- return ObjectToString(value) === "[object Generator]";
230
- }
231
- exports.isGeneratorObject = isGeneratorObject;
232
-
233
- function isWebAssemblyCompiledModule(value) {
234
- return ObjectToString(value) === "[object WebAssembly.Module]";
235
- }
236
- exports.isWebAssemblyCompiledModule = isWebAssemblyCompiledModule;
237
-
238
- function isNumberObject(value) {
239
- return checkBoxedPrimitive(value, numberValue);
240
- }
241
- exports.isNumberObject = isNumberObject;
242
-
243
- function isStringObject(value) {
244
- return checkBoxedPrimitive(value, stringValue);
245
- }
246
- exports.isStringObject = isStringObject;
247
-
248
- function isBooleanObject(value) {
249
- return checkBoxedPrimitive(value, booleanValue);
250
- }
251
- exports.isBooleanObject = isBooleanObject;
252
-
253
- function isBigIntObject(value) {
254
- return BigIntSupported && checkBoxedPrimitive(value, bigIntValue);
255
- }
256
- exports.isBigIntObject = isBigIntObject;
257
-
258
- function isSymbolObject(value) {
259
- return SymbolSupported && checkBoxedPrimitive(value, symbolValue);
260
- }
261
- exports.isSymbolObject = isSymbolObject;
262
-
263
- function isBoxedPrimitive(value) {
264
- return (
265
- isNumberObject(value) ||
266
- isStringObject(value) ||
267
- isBooleanObject(value) ||
268
- isBigIntObject(value) ||
269
- isSymbolObject(value)
270
- );
271
- }
272
- exports.isBoxedPrimitive = isBoxedPrimitive;
273
-
274
- function isAnyArrayBuffer(value) {
275
- return typeof Uint8Array !== "undefined" && isArrayBuffer(value);
276
- }
277
- exports.isAnyArrayBuffer = isAnyArrayBuffer;
278
-
279
- ["isProxy", "isExternal", "isModuleNamespaceObject"].forEach(function (method) {
280
- Object.defineProperty(exports, method, {
281
- enumerable: false,
282
- value: function () {
283
- throw new Error(method + " is not supported in userland");
284
- },
285
- });
286
- });