@zuzjs/core 0.1.2 → 0.1.3

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/dist/index.d.ts CHANGED
@@ -25,4 +25,22 @@ export declare const createElems: (list: ElementNode[]) => Node[];
25
25
  export declare const getPlatform: () => "MAC" | "WIN" | "UNKNOWN";
26
26
  export declare const findParent: (node: HTMLElement, classes: string[], depth?: number) => HTMLElement | null;
27
27
  export declare const ucfirst: (str: string) => string;
28
+ /**
29
+ * HTTP Requests
30
+ */
28
31
  export declare const withRest: (uri: string, data: object, timeout: number | undefined, fd: object, progress?: Function, bearer?: string) => Promise<unknown>;
32
+ /**
33
+ * Extends Object.prototype adding,
34
+ * @function isNull
35
+ * @function equals
36
+ * @function isString
37
+ * @function isNumber
38
+ * @function isObject
39
+ * @function isArray
40
+ * @function isEmpty
41
+ * @function isNotEmpty
42
+ * @function isEmail
43
+ * @function isUrl
44
+ *
45
+ */
46
+ export declare const extendGlobals: () => void;
package/dist/index.js CHANGED
@@ -83,6 +83,9 @@ const buildFormData = (data) => {
83
83
  [data['files']].map((f) => formData.append('files[]', f));
84
84
  return formData;
85
85
  };
86
+ /**
87
+ * HTTP Requests
88
+ */
86
89
  export const withRest = async (uri, data, timeout = 60, fd, progress, bearer = `__ha`) => {
87
90
  var Bearer = getCookie(bearer) || `${uuid(8)}^${uuid(8)}`;
88
91
  var isWindow = typeof window !== 'undefined';
@@ -143,3 +146,34 @@ export const withRest = async (uri, data, timeout = 60, fd, progress, bearer = `
143
146
  .catch(err => reject(err));
144
147
  });
145
148
  };
149
+ /**
150
+ * Extends Object.prototype adding,
151
+ * @function isNull
152
+ * @function equals
153
+ * @function isString
154
+ * @function isNumber
155
+ * @function isObject
156
+ * @function isArray
157
+ * @function isEmpty
158
+ * @function isNotEmpty
159
+ * @function isEmail
160
+ * @function isUrl
161
+ *
162
+ */
163
+ export const extendGlobals = () => {
164
+ Object.prototype.isNull = function () { return this === null; };
165
+ Object.prototype.equals = function (v) { return this === v; };
166
+ Object.prototype.isString = function () { return typeof this == `string`; };
167
+ Object.prototype.isNumber = function () { return /^[+-]?\d+(\.\d+)?$/.test(this); };
168
+ Object.prototype.isObject = function () { return typeof this == `object` && !Array.isArray(this) && this !== null; };
169
+ Object.prototype.isArray = function () { return Array.isArray(this); };
170
+ Object.prototype.isEmpty = function () {
171
+ if (Array.isArray(this))
172
+ return this.length === 0;
173
+ else if (`object` === typeof this)
174
+ return Object.keys(this).length == 0;
175
+ else
176
+ return this == "" || this.length == 0;
177
+ };
178
+ };
179
+ extendGlobals();
package/dist/types.d.ts CHANGED
@@ -2,5 +2,17 @@ declare global {
2
2
  interface Window {
3
3
  __restToken: any;
4
4
  }
5
+ interface Object {
6
+ isNull(): boolean;
7
+ equals(v: any): boolean;
8
+ isString(): boolean;
9
+ isNumber(): boolean;
10
+ isObject(): boolean;
11
+ isArray(): boolean;
12
+ isEmpty(): boolean;
13
+ isNotEmpty(v: any): boolean;
14
+ isEmail(v: any): boolean;
15
+ isUrl(v: any): boolean;
16
+ }
5
17
  }
6
18
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuzjs/core",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "keywords": [
5
5
  "react",
6
6
  "zuz",
@@ -18,16 +18,17 @@
18
18
  "dist"
19
19
  ],
20
20
  "scripts": {
21
- "dev": "tsc -d -w -p tsconfig.json"
21
+ "dev": "tsc -d -w -p tsconfig.json",
22
+ "build": "tsc -b tsconfig.json"
22
23
  },
23
24
  "engines": {
24
25
  "node": ">=18.17.0"
25
26
  },
26
27
  "dependencies": {
27
- "axios": "1.6.5",
28
+ "axios": "1.6.8",
28
29
  "hashids": "2.3.0",
29
30
  "js-cookie": "3.0.5",
30
- "nanoid": "5.0.4",
31
- "prettier": "3.2.4"
31
+ "nanoid": "5.0.7",
32
+ "prettier": "3.2.5"
32
33
  }
33
34
  }