@andrewcaires/utils.js 0.2.18 → 0.2.20

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.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @andrewcaires/utils.js v0.2.18
2
+ * @andrewcaires/utils.js v0.2.20
3
3
  * JavaScript utility library for web and nodejs development
4
4
  * (c) 2023 Andrew Caires
5
5
  * @license: MIT
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @andrewcaires/utils.js v0.2.18
2
+ * @andrewcaires/utils.js v0.2.20
3
3
  * JavaScript utility library for web and nodejs development
4
4
  * (c) 2023 Andrew Caires
5
5
  * @license: MIT
@@ -54,15 +54,15 @@ declare const debounce: (callback: TypeCallbackFunction, ms: number) => IDebounc
54
54
  declare const loop: (callback: TypeCallbackFunction, ms: number) => ILoopCallbacks;
55
55
 
56
56
  type EventCallback = (data?: any) => void;
57
- interface EventDisposable {
57
+ interface IEventDisposable {
58
58
  dispose: () => void;
59
59
  }
60
60
  type EventList = Array<EventCallback>;
61
61
  declare class EventEmitter {
62
62
  private events;
63
63
  constructor();
64
- on(event: string, callback: EventCallback): EventDisposable;
65
- once(event: string, callback: EventCallback): EventDisposable;
64
+ on(event: string, callback: EventCallback): IEventDisposable;
65
+ once(event: string, callback: EventCallback): IEventDisposable;
66
66
  off(event: string, callback?: EventCallback): void;
67
67
  emit(event: string, data?: any): void;
68
68
  }
@@ -76,11 +76,11 @@ declare const forLoop: (count: number, callback: LoopCallback, thisArg?: any) =>
76
76
  declare const map: <T>(object: TypeObject<T>, callback: TypeCallbackObject<T>, thisArg?: any) => TypeObject<T>;
77
77
  declare const noop: () => void;
78
78
 
79
- interface Hash {
79
+ interface IHash {
80
80
  generate: (str: string) => string;
81
81
  reverse: (hash: string) => string;
82
82
  }
83
- declare const hash: (key: string) => Hash;
83
+ declare const hash: (key: string) => IHash;
84
84
 
85
85
  declare const mask: (mask: string, text: string) => string;
86
86
  declare const maskMoney: (mask: string, text: string, decimal: number) => string;
@@ -128,12 +128,13 @@ declare const isNull: (test: any) => test is null;
128
128
  declare const isUndefined: (test: any) => test is undefined;
129
129
  declare const type: (test: any) => string;
130
130
 
131
- interface ValidationResult {
131
+ interface IValidationResult {
132
132
  break?: boolean;
133
133
  error?: string;
134
134
  value?: any;
135
135
  }
136
- type ValidationCallback = (value: any) => ValidationResult;
136
+ type ValidationCallback = (value: any) => IValidationResult;
137
+ type ValidationCallbackAsync = (value: any) => Promise<IValidationResult>;
137
138
  declare class ValidationBase<T = any> {
138
139
  name: string;
139
140
  private _value;
@@ -145,15 +146,15 @@ declare class ValidationBase<T = any> {
145
146
  empty(value?: T): this;
146
147
  error(value: string): this;
147
148
  filter(...values: Array<any>): this;
148
- protected invalid(name: string): ValidationResult;
149
+ protected invalid(name: string): IValidationResult;
149
150
  parse(): this;
150
151
  push(callback: ValidationCallback): this;
151
152
  required(): this;
152
153
  test(value?: any): boolean;
153
154
  testAsync(value?: any): Promise<boolean>;
154
155
  unshift(callback: ValidationCallback): this;
155
- validate(value?: any): ValidationResult;
156
- validateAsync(value?: any): Promise<ValidationResult>;
156
+ validate(value?: any): IValidationResult;
157
+ validateAsync(value?: any): Promise<IValidationResult>;
157
158
  }
158
159
  declare class ValidationArray extends ValidationBase<Array<any>> {
159
160
  private _length;
@@ -218,8 +219,8 @@ declare class Validation {
218
219
  static string(): ValidationString;
219
220
  test(value?: any, ...rules: Array<ValidationBase>): boolean;
220
221
  testAsync(value?: any, ...rules: Array<ValidationBase>): Promise<boolean>;
221
- static validate(value?: any, ...rules: Array<ValidationBase>): ValidationResult;
222
- static validateAsync(value?: any, ...rules: Array<ValidationBase>): Promise<ValidationResult>;
222
+ static validate(value?: any, ...rules: Array<ValidationBase>): IValidationResult;
223
+ static validateAsync(value?: any, ...rules: Array<ValidationBase>): Promise<IValidationResult>;
223
224
  }
224
225
 
225
- export { EventCallback, EventDisposable, EventEmitter, EventList, TypeArray, TypeArrayAny, TypeArrayFunction, TypeArrayNumber, TypeArrayString, TypeCallback, TypeCallbackArray, TypeCallbackFunction, TypeCallbackMap, TypeCallbackObject, TypeObject, TypeObjectAny, TypeObjectFunction, TypeObjectNumber, TypeObjectString, Validation, ValidationBase, allowedObject, cache, camelCase, chunkArray, clamp, cutText, dateFormat, debounce, decodeHTML, deniedObject, each, encodeHTML, forEachAsync, forEachIndex, forEachKey, forEachSeries, forLoop, hash, hexToRgb, isArray, isBoolean, isCharacter, isDef, isDigit, isFloat, isFunction, isInteger, isLetter, isNull, isNumber, isObject, isString, isSymbol, isUndefined, lerp, loop, lowerCamelCase, map, mask, maskMoney, maskReverse, maskTest, msToString, noop, parseMs, parseSize, rangeArray, rgbToHex, shadeColor, shuffleArray, simpleID, sleep, stringReverse, toArray, toBool, type, uniqueID, upperCamelCase, uuidv4 };
226
+ export { CacheCallback, EachCallback, EventCallback, EventEmitter, EventList, ForEachCallback, IDebounceCallbacks, IEventDisposable, IHash, ILoopCallbacks, IValidationResult, LoopCallback, TypeArray, TypeArrayAny, TypeArrayFunction, TypeArrayNumber, TypeArrayString, TypeCallback, TypeCallbackArray, TypeCallbackFunction, TypeCallbackMap, TypeCallbackObject, TypeObject, TypeObjectAny, TypeObjectFunction, TypeObjectNumber, TypeObjectString, Validation, ValidationBase, ValidationCallback, ValidationCallbackAsync, allowedObject, cache, camelCase, chunkArray, clamp, cutText, dateFormat, debounce, decodeHTML, deniedObject, each, encodeHTML, forEachAsync, forEachIndex, forEachKey, forEachSeries, forLoop, hash, hexToRgb, isArray, isBoolean, isCharacter, isDef, isDigit, isFloat, isFunction, isInteger, isLetter, isNull, isNumber, isObject, isString, isSymbol, isUndefined, lerp, loop, lowerCamelCase, map, mask, maskMoney, maskReverse, maskTest, msToString, noop, parseMs, parseSize, rangeArray, rgbToHex, shadeColor, shuffleArray, simpleID, sleep, stringReverse, toArray, toBool, type, uniqueID, upperCamelCase, uuidv4 };
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @andrewcaires/utils.js v0.2.18
2
+ * @andrewcaires/utils.js v0.2.20
3
3
  * JavaScript utility library for web and nodejs development
4
4
  * (c) 2023 Andrew Caires
5
5
  * @license: MIT
package/dist/index.min.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @andrewcaires/utils.js v0.2.18
2
+ * @andrewcaires/utils.js v0.2.20
3
3
  * JavaScript utility library for web and nodejs development
4
4
  * (c) 2023 Andrew Caires
5
5
  * @license: MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andrewcaires/utils.js",
3
- "version": "0.2.18",
3
+ "version": "0.2.20",
4
4
  "description": "JavaScript utility library for web and nodejs development",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "unpkg": "./dist/index.min.js",
@@ -20,8 +20,9 @@
20
20
  "dist"
21
21
  ],
22
22
  "scripts": {
23
- "build": "rollup --bundleConfigAsCjs -c rollup.config.js",
24
- "dev": "ts-node-dev --respawn --transpile-only ./src/index.ts"
23
+ "build": "rollup --bundleConfigAsCjs -c ./rollup.config.js",
24
+ "dev": "ts-node-dev --respawn --transpile-only ./src/index.ts",
25
+ "test": "jest --config ./jest.config.ts"
25
26
  },
26
27
  "repository": {
27
28
  "type": "git",
@@ -43,16 +44,20 @@
43
44
  },
44
45
  "homepage": "https://github.com/andrewcaires/npm/tree/main/utils.js#readme",
45
46
  "devDependencies": {
47
+ "@jest/globals": "^29.5.0",
46
48
  "@rollup/plugin-commonjs": "^25.0.1",
47
49
  "@rollup/plugin-terser": "^0.4.3",
48
50
  "@rollup/plugin-typescript": "^11.1.1",
51
+ "@types/jest": "^29.5.2",
49
52
  "@types/node": "^20.3.1",
50
53
  "@typescript-eslint/eslint-plugin": "^5.59.11",
51
54
  "@typescript-eslint/parser": "^5.59.11",
52
55
  "eslint": "^8.42.0",
56
+ "jest": "^29.5.0",
53
57
  "rollup": "^3.25.1",
54
58
  "rollup-plugin-dts": "^5.3.0",
59
+ "ts-jest": "^29.1.0",
55
60
  "ts-node-dev": "^2.0.0",
56
61
  "tslib": "^2.5.3"
57
62
  }
58
- }
63
+ }