@deot/vc-shared 1.0.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.
package/README.md ADDED
File without changes
package/dist/index.cjs ADDED
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const autoCatch = async (impl, options = {}) => {
6
+ const { onError = console.error } = options;
7
+ let target = impl;
8
+ typeof target === "function" && (target = target());
9
+ try {
10
+ const e = await target;
11
+ return e;
12
+ } catch (e) {
13
+ onError(e);
14
+ }
15
+ };
16
+ const eleInRegExp = (el, exceptions) => {
17
+ for (const i in exceptions) {
18
+ if (exceptions[i].test(el[i])) {
19
+ return true;
20
+ }
21
+ }
22
+ return false;
23
+ };
24
+ const toOptions = (args, orders, original) => {
25
+ let result = original || {};
26
+ args.map((item, index) => {
27
+ if (typeof item === "object" && args.length === index + 1) {
28
+ result = {
29
+ ...result,
30
+ ...item
31
+ };
32
+ } else {
33
+ result[orders[index]] = item;
34
+ }
35
+ return true;
36
+ });
37
+ return result;
38
+ };
39
+
40
+ const utils = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
41
+ __proto__: null,
42
+ autoCatch,
43
+ eleInRegExp,
44
+ toOptions
45
+ }, Symbol.toStringTag, { value: 'Module' }));
46
+
47
+ const IS_SERVER = typeof window === "undefined";
48
+
49
+ exports.IS_SERVER = IS_SERVER;
50
+ exports.Utils = utils;
@@ -0,0 +1,24 @@
1
+ declare const autoCatch: (impl: any, options?: Record<string, any>) => Promise<any>;
2
+
3
+ declare const eleInRegExp: (el: HTMLElement, exceptions: Exceptions) => boolean;
4
+
5
+ declare interface Exceptions {
6
+ id?: RegExp;
7
+ className?: RegExp;
8
+ tagName?: RegExp;
9
+ }
10
+
11
+ export declare const IS_SERVER: boolean;
12
+
13
+ declare const toOptions: <T>(args: any[], orders: Array<keyof T>, original?: T) => T;
14
+
15
+ declare namespace Utils {
16
+ export {
17
+ autoCatch,
18
+ eleInRegExp,
19
+ toOptions
20
+ }
21
+ }
22
+ export { Utils }
23
+
24
+ export { }
@@ -0,0 +1,55 @@
1
+ var VcShared = (function (exports) {
2
+ 'use strict';
3
+
4
+ const autoCatch = async (impl, options = {}) => {
5
+ const { onError = console.error } = options;
6
+ let target = impl;
7
+ typeof target === "function" && (target = target());
8
+ try {
9
+ const e = await target;
10
+ return e;
11
+ } catch (e) {
12
+ onError(e);
13
+ }
14
+ };
15
+ const eleInRegExp = (el, exceptions) => {
16
+ for (const i in exceptions) {
17
+ if (exceptions[i].test(el[i])) {
18
+ return true;
19
+ }
20
+ }
21
+ return false;
22
+ };
23
+ const toOptions = (args, orders, original) => {
24
+ let result = original || {};
25
+ args.map((item, index) => {
26
+ if (typeof item === "object" && args.length === index + 1) {
27
+ result = {
28
+ ...result,
29
+ ...item
30
+ };
31
+ } else {
32
+ result[orders[index]] = item;
33
+ }
34
+ return true;
35
+ });
36
+ return result;
37
+ };
38
+
39
+ const utils = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
40
+ __proto__: null,
41
+ autoCatch,
42
+ eleInRegExp,
43
+ toOptions
44
+ }, Symbol.toStringTag, { value: 'Module' }));
45
+
46
+ const IS_SERVER = typeof window === "undefined";
47
+
48
+ exports.IS_SERVER = IS_SERVER;
49
+ exports.Utils = utils;
50
+
51
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
52
+
53
+ return exports;
54
+
55
+ })({});
package/dist/index.js ADDED
@@ -0,0 +1,45 @@
1
+ const autoCatch = async (impl, options = {}) => {
2
+ const { onError = console.error } = options;
3
+ let target = impl;
4
+ typeof target === "function" && (target = target());
5
+ try {
6
+ const e = await target;
7
+ return e;
8
+ } catch (e) {
9
+ onError(e);
10
+ }
11
+ };
12
+ const eleInRegExp = (el, exceptions) => {
13
+ for (const i in exceptions) {
14
+ if (exceptions[i].test(el[i])) {
15
+ return true;
16
+ }
17
+ }
18
+ return false;
19
+ };
20
+ const toOptions = (args, orders, original) => {
21
+ let result = original || {};
22
+ args.map((item, index) => {
23
+ if (typeof item === "object" && args.length === index + 1) {
24
+ result = {
25
+ ...result,
26
+ ...item
27
+ };
28
+ } else {
29
+ result[orders[index]] = item;
30
+ }
31
+ return true;
32
+ });
33
+ return result;
34
+ };
35
+
36
+ const utils = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
37
+ __proto__: null,
38
+ autoCatch,
39
+ eleInRegExp,
40
+ toOptions
41
+ }, Symbol.toStringTag, { value: 'Module' }));
42
+
43
+ const IS_SERVER = typeof window === "undefined";
44
+
45
+ export { IS_SERVER, utils as Utils };
@@ -0,0 +1,56 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.VcShared = {}));
5
+ })(this, (function (exports) { 'use strict';
6
+
7
+ const autoCatch = async (impl, options = {}) => {
8
+ const { onError = console.error } = options;
9
+ let target = impl;
10
+ typeof target === "function" && (target = target());
11
+ try {
12
+ const e = await target;
13
+ return e;
14
+ } catch (e) {
15
+ onError(e);
16
+ }
17
+ };
18
+ const eleInRegExp = (el, exceptions) => {
19
+ for (const i in exceptions) {
20
+ if (exceptions[i].test(el[i])) {
21
+ return true;
22
+ }
23
+ }
24
+ return false;
25
+ };
26
+ const toOptions = (args, orders, original) => {
27
+ let result = original || {};
28
+ args.map((item, index) => {
29
+ if (typeof item === "object" && args.length === index + 1) {
30
+ result = {
31
+ ...result,
32
+ ...item
33
+ };
34
+ } else {
35
+ result[orders[index]] = item;
36
+ }
37
+ return true;
38
+ });
39
+ return result;
40
+ };
41
+
42
+ const utils = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
43
+ __proto__: null,
44
+ autoCatch,
45
+ eleInRegExp,
46
+ toOptions
47
+ }, Symbol.toStringTag, { value: 'Module' }));
48
+
49
+ const IS_SERVER = typeof window === "undefined";
50
+
51
+ exports.IS_SERVER = IS_SERVER;
52
+ exports.Utils = utils;
53
+
54
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
55
+
56
+ }));
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@deot/vc-shared",
3
+ "version": "1.0.1",
4
+ "type": "module",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "require": "./dist/index.cjs",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "license": "MIT",
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "dependencies": {}
22
+ }