nhb-toolbox 2.8.1 → 2.8.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/array/basics.js +7 -15
- package/dist/array/sort.js +1 -4
- package/dist/array/transform.js +4 -9
- package/dist/array/types.js +1 -2
- package/dist/colors/Color.js +17 -21
- package/dist/colors/constants.js +2 -5
- package/dist/colors/convert.js +56 -73
- package/dist/colors/helpers.js +13 -29
- package/dist/colors/initials.d.ts +2 -2
- package/dist/colors/initials.d.ts.map +1 -1
- package/dist/colors/initials.js +13 -16
- package/dist/colors/random.js +7 -12
- package/dist/colors/types.js +1 -2
- package/dist/form/convert.js +4 -9
- package/dist/form/guards.js +4 -10
- package/dist/form/transform.js +9 -13
- package/dist/form/types.js +1 -2
- package/dist/guards/non-primitives.d.ts +10 -10
- package/dist/guards/non-primitives.js +27 -44
- package/dist/guards/primitives.d.ts +12 -12
- package/dist/guards/primitives.js +24 -38
- package/dist/guards/specials.d.ts +12 -12
- package/dist/guards/specials.js +35 -49
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -156
- package/dist/number/basics.js +11 -21
- package/dist/number/constants.js +4 -7
- package/dist/number/convert.js +5 -8
- package/dist/number/helpers.js +11 -18
- package/dist/number/prime.js +3 -8
- package/dist/number/range.js +12 -15
- package/dist/number/types.js +1 -2
- package/dist/object/basics.js +8 -16
- package/dist/object/convert.js +1 -4
- package/dist/object/objectify.js +22 -32
- package/dist/object/sanitize.js +8 -11
- package/dist/object/types.js +1 -2
- package/dist/string/anagram.js +1 -4
- package/dist/string/basics.js +4 -11
- package/dist/string/constants.js +1 -4
- package/dist/string/convert.js +4 -9
- package/dist/string/types.js +1 -2
- package/dist/types/index.js +1 -2
- package/dist/utils/index.js +8 -15
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,166 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeDuplicatesFromArray = exports.createOptionsArray = exports.sortAnArray = exports.shuffleArray = exports.isValidEmptyArray = exports.isInvalidOrEmptyArray = exports.getLastArrayElement = exports.flattenArray = exports.filterArrayOfObjects = exports.Colour = exports.Color = exports.convertRgbToRgba = exports.convertRgbToHsl = exports.convertRgbToHex = exports.convertRgbaToHsla = exports.convertRgbaToHex8 = exports.convertHslToRgb = exports.convertHslToHex = exports.convertHslaToRgba = exports.convertHslaToHex8 = exports.convertHexToRgb = exports.convertHexToHsl = exports.convertHex8ToRgba = exports.convertHex8ToHsla = exports.convertColorCode = exports.generateRandomHSLColor = exports.generateRandomColorInHexRGB = exports.getColorForInitial = exports.getNumbersInRange = exports.isPrime = exports.findPrimeNumbers = exports.numberToWords = exports.isOddNumber = exports.isOdd = exports.isMultiple = exports.isEvenNumber = exports.isEven = exports.getRandomNumber = exports.convertToDecimal = exports.calculateLCM = exports.calculateLCD = exports.calculateHCF = exports.calculateGCD = exports.replaceAllInString = exports.convertStringCase = exports.generateAnagrams = exports.truncateString = exports.trimString = exports.generateRandomID = exports.capitalizeString = void 0;
|
|
4
|
-
exports.isObjectWithKeys = exports.isObjectEmpty = exports.isMap = exports.isJSONObject = exports.isJSON = exports.isFunction = exports.isError = exports.isEmptyObjectGuard = exports.isDate = exports.isBigInt = exports.isArrayOfType = exports.isArray = exports.doesReturnPromise = exports.isUndefined = exports.isTruthy = exports.isSymbol = exports.isString = exports.isPrimitive = exports.isPositiveInteger = exports.isNumber = exports.isNull = exports.isNonEmptyString = exports.isInteger = exports.isFalsy = exports.isBoolean = exports.throttleAction = exports.isDeepEqual = exports.debounceAction = exports.convertArrayToString = exports.convertObjectValues = exports.sanitizeData = exports.mergeObjects = exports.mergeAndFlattenObjects = exports.flattenObjectKeyValue = exports.flattenObjectDotNotation = exports.extractUpdatedFields = exports.extractUpdatedAndNewFields = exports.extractNewFields = exports.isObject = exports.isEmptyObject = exports.generateQueryParams = exports.countObjectFields = exports.cloneObject = exports.isOriginFileObj = exports.isFileUpload = exports.isCustomFileArray = exports.isCustomFile = exports.createControlledFormData = exports.isEmptyFormData = exports.convertIntoFormData = void 0;
|
|
5
|
-
exports.isValidURL = exports.isValidEmail = exports.isUUID = exports.isURL = exports.isPhoneNumber = exports.isNumericString = exports.isNodeEnvironment = exports.isNodeENV = exports.isNode = exports.isIPAddress = exports.isExpectedNodeENV = exports.isEnvironment = exports.isEmailArray = exports.isEmail = exports.isDateString = exports.isBrowser = exports.isBase64 = exports.isValidSet = exports.isValidObject = exports.isValidMap = exports.isValidJSON = exports.isSet = exports.isReturningPromise = exports.isRegularExpression = exports.isRegExp = exports.isPromise = void 0;
|
|
6
1
|
// ! String Utilities
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Object.defineProperty(exports, "trimString", { enumerable: true, get: function () { return basics_1.trimString; } });
|
|
11
|
-
Object.defineProperty(exports, "truncateString", { enumerable: true, get: function () { return basics_1.truncateString; } });
|
|
12
|
-
var anagram_1 = require("./string/anagram");
|
|
13
|
-
Object.defineProperty(exports, "generateAnagrams", { enumerable: true, get: function () { return anagram_1.generateAnagrams; } });
|
|
14
|
-
var convert_1 = require("./string/convert");
|
|
15
|
-
Object.defineProperty(exports, "convertStringCase", { enumerable: true, get: function () { return convert_1.convertStringCase; } });
|
|
16
|
-
Object.defineProperty(exports, "replaceAllInString", { enumerable: true, get: function () { return convert_1.replaceAllInString; } });
|
|
2
|
+
export { capitalizeString, generateRandomID, trimString, truncateString, } from './string/basics';
|
|
3
|
+
export { generateAnagrams } from './string/anagram';
|
|
4
|
+
export { convertStringCase, replaceAllInString } from './string/convert';
|
|
17
5
|
// ! Number Utilities
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Object.defineProperty(exports, "calculateLCM", { enumerable: true, get: function () { return basics_2.calculateLCM; } });
|
|
23
|
-
Object.defineProperty(exports, "convertToDecimal", { enumerable: true, get: function () { return basics_2.convertToDecimal; } });
|
|
24
|
-
Object.defineProperty(exports, "getRandomNumber", { enumerable: true, get: function () { return basics_2.getRandomNumber; } });
|
|
25
|
-
Object.defineProperty(exports, "isEven", { enumerable: true, get: function () { return basics_2.isEven; } });
|
|
26
|
-
Object.defineProperty(exports, "isEvenNumber", { enumerable: true, get: function () { return basics_2.isEven; } });
|
|
27
|
-
Object.defineProperty(exports, "isMultiple", { enumerable: true, get: function () { return basics_2.isMultiple; } });
|
|
28
|
-
Object.defineProperty(exports, "isOdd", { enumerable: true, get: function () { return basics_2.isOdd; } });
|
|
29
|
-
Object.defineProperty(exports, "isOddNumber", { enumerable: true, get: function () { return basics_2.isOdd; } });
|
|
30
|
-
var convert_2 = require("./number/convert");
|
|
31
|
-
Object.defineProperty(exports, "numberToWords", { enumerable: true, get: function () { return convert_2.numberToWords; } });
|
|
32
|
-
var prime_1 = require("./number/prime");
|
|
33
|
-
Object.defineProperty(exports, "findPrimeNumbers", { enumerable: true, get: function () { return prime_1.findPrimeNumbers; } });
|
|
34
|
-
Object.defineProperty(exports, "isPrime", { enumerable: true, get: function () { return prime_1.isPrime; } });
|
|
35
|
-
var range_1 = require("./number/range");
|
|
36
|
-
Object.defineProperty(exports, "getNumbersInRange", { enumerable: true, get: function () { return range_1.getNumbersInRange; } });
|
|
6
|
+
export { calculateHCF as calculateGCD, calculateHCF, calculateLCM as calculateLCD, calculateLCM, convertToDecimal, getRandomNumber, isEven, isEven as isEvenNumber, isMultiple, isOdd, isOdd as isOddNumber, } from './number/basics';
|
|
7
|
+
export { numberToWords } from './number/convert';
|
|
8
|
+
export { findPrimeNumbers, isPrime, isPrime as isPrimeNumber, } from './number/prime';
|
|
9
|
+
export { getNumbersInRange } from './number/range';
|
|
37
10
|
// ! Color Utilities
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
Object.defineProperty(exports, "generateRandomHSLColor", { enumerable: true, get: function () { return random_1.generateRandomHSLColor; } });
|
|
43
|
-
var convert_3 = require("./colors/convert");
|
|
44
|
-
Object.defineProperty(exports, "convertColorCode", { enumerable: true, get: function () { return convert_3.convertColorCode; } });
|
|
45
|
-
Object.defineProperty(exports, "convertHex8ToHsla", { enumerable: true, get: function () { return convert_3.convertHex8ToHsla; } });
|
|
46
|
-
Object.defineProperty(exports, "convertHex8ToRgba", { enumerable: true, get: function () { return convert_3.convertHex8ToRgba; } });
|
|
47
|
-
Object.defineProperty(exports, "convertHexToHsl", { enumerable: true, get: function () { return convert_3.convertHexToHsl; } });
|
|
48
|
-
Object.defineProperty(exports, "convertHexToRgb", { enumerable: true, get: function () { return convert_3.convertHexToRgb; } });
|
|
49
|
-
Object.defineProperty(exports, "convertHslaToHex8", { enumerable: true, get: function () { return convert_3.convertHslaToHex8; } });
|
|
50
|
-
Object.defineProperty(exports, "convertHslaToRgba", { enumerable: true, get: function () { return convert_3.convertHslaToRgba; } });
|
|
51
|
-
Object.defineProperty(exports, "convertHslToHex", { enumerable: true, get: function () { return convert_3.convertHslToHex; } });
|
|
52
|
-
Object.defineProperty(exports, "convertHslToRgb", { enumerable: true, get: function () { return convert_3.convertHslToRgb; } });
|
|
53
|
-
Object.defineProperty(exports, "convertRgbaToHex8", { enumerable: true, get: function () { return convert_3.convertRgbaToHex8; } });
|
|
54
|
-
Object.defineProperty(exports, "convertRgbaToHsla", { enumerable: true, get: function () { return convert_3.convertRgbaToHsla; } });
|
|
55
|
-
Object.defineProperty(exports, "convertRgbToHex", { enumerable: true, get: function () { return convert_3.convertRgbToHex; } });
|
|
56
|
-
Object.defineProperty(exports, "convertRgbToHsl", { enumerable: true, get: function () { return convert_3.convertRgbToHsl; } });
|
|
57
|
-
Object.defineProperty(exports, "convertRgbToRgba", { enumerable: true, get: function () { return convert_3.convertRgbToRgba; } });
|
|
58
|
-
var Color_1 = require("./colors/Color");
|
|
59
|
-
Object.defineProperty(exports, "Color", { enumerable: true, get: function () { return Color_1.Color; } });
|
|
60
|
-
Object.defineProperty(exports, "Colour", { enumerable: true, get: function () { return Color_1.Color; } });
|
|
11
|
+
export { getColorForInitial } from './colors/initials';
|
|
12
|
+
export { generateRandomColorInHexRGB, generateRandomHSLColor, } from './colors/random';
|
|
13
|
+
export { convertColorCode, convertHex8ToHsla, convertHex8ToRgba, convertHexToHsl, convertHexToRgb, convertHslaToHex8, convertHslaToRgba, convertHslToHex, convertHslToRgb, convertRgbaToHex8, convertRgbaToHsla, convertRgbToHex, convertRgbToHsl, convertRgbToRgba, } from './colors/convert';
|
|
14
|
+
export { Color, Color as Colour } from './colors/Color';
|
|
61
15
|
// ! Array Utilities
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
Object.defineProperty(exports, "getLastArrayElement", { enumerable: true, get: function () { return basics_3.getLastArrayElement; } });
|
|
66
|
-
Object.defineProperty(exports, "isInvalidOrEmptyArray", { enumerable: true, get: function () { return basics_3.isInvalidOrEmptyArray; } });
|
|
67
|
-
Object.defineProperty(exports, "isValidEmptyArray", { enumerable: true, get: function () { return basics_3.isInvalidOrEmptyArray; } });
|
|
68
|
-
Object.defineProperty(exports, "shuffleArray", { enumerable: true, get: function () { return basics_3.shuffleArray; } });
|
|
69
|
-
var sort_1 = require("./array/sort");
|
|
70
|
-
Object.defineProperty(exports, "sortAnArray", { enumerable: true, get: function () { return sort_1.sortAnArray; } });
|
|
71
|
-
var transform_1 = require("./array/transform");
|
|
72
|
-
Object.defineProperty(exports, "createOptionsArray", { enumerable: true, get: function () { return transform_1.createOptionsArray; } });
|
|
73
|
-
Object.defineProperty(exports, "removeDuplicatesFromArray", { enumerable: true, get: function () { return transform_1.removeDuplicatesFromArray; } });
|
|
16
|
+
export { filterArrayOfObjects, flattenArray, getLastArrayElement, isInvalidOrEmptyArray, isInvalidOrEmptyArray as isValidEmptyArray, shuffleArray, } from './array/basics';
|
|
17
|
+
export { sortAnArray } from './array/sort';
|
|
18
|
+
export { createOptionsArray, removeDuplicatesFromArray, } from './array/transform';
|
|
74
19
|
// ! Form Utilities
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
var transform_2 = require("./form/transform");
|
|
79
|
-
Object.defineProperty(exports, "createControlledFormData", { enumerable: true, get: function () { return transform_2.createControlledFormData; } });
|
|
80
|
-
var guards_1 = require("./form/guards");
|
|
81
|
-
Object.defineProperty(exports, "isCustomFile", { enumerable: true, get: function () { return guards_1.isCustomFile; } });
|
|
82
|
-
Object.defineProperty(exports, "isCustomFileArray", { enumerable: true, get: function () { return guards_1.isCustomFileArray; } });
|
|
83
|
-
Object.defineProperty(exports, "isFileUpload", { enumerable: true, get: function () { return guards_1.isFileUpload; } });
|
|
84
|
-
Object.defineProperty(exports, "isOriginFileObj", { enumerable: true, get: function () { return guards_1.isOriginFileObj; } });
|
|
20
|
+
export { convertIntoFormData, isEmptyFormData } from './form/convert';
|
|
21
|
+
export { createControlledFormData } from './form/transform';
|
|
22
|
+
export { isCustomFile, isCustomFileArray, isFileUpload, isOriginFileObj, } from './form/guards';
|
|
85
23
|
// ! Object Utilities
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
Object.defineProperty(exports, "isEmptyObject", { enumerable: true, get: function () { return basics_4.isEmptyObject; } });
|
|
91
|
-
Object.defineProperty(exports, "isObject", { enumerable: true, get: function () { return basics_4.isObject; } });
|
|
92
|
-
var objectify_1 = require("./object/objectify");
|
|
93
|
-
Object.defineProperty(exports, "extractNewFields", { enumerable: true, get: function () { return objectify_1.extractNewFields; } });
|
|
94
|
-
Object.defineProperty(exports, "extractUpdatedAndNewFields", { enumerable: true, get: function () { return objectify_1.extractUpdatedAndNewFields; } });
|
|
95
|
-
Object.defineProperty(exports, "extractUpdatedFields", { enumerable: true, get: function () { return objectify_1.extractUpdatedFields; } });
|
|
96
|
-
Object.defineProperty(exports, "flattenObjectDotNotation", { enumerable: true, get: function () { return objectify_1.flattenObjectDotNotation; } });
|
|
97
|
-
Object.defineProperty(exports, "flattenObjectKeyValue", { enumerable: true, get: function () { return objectify_1.flattenObjectKeyValue; } });
|
|
98
|
-
Object.defineProperty(exports, "mergeAndFlattenObjects", { enumerable: true, get: function () { return objectify_1.mergeAndFlattenObjects; } });
|
|
99
|
-
Object.defineProperty(exports, "mergeObjects", { enumerable: true, get: function () { return objectify_1.mergeObjects; } });
|
|
100
|
-
var sanitize_1 = require("./object/sanitize");
|
|
101
|
-
Object.defineProperty(exports, "sanitizeData", { enumerable: true, get: function () { return sanitize_1.sanitizeData; } });
|
|
102
|
-
var convert_5 = require("./object/convert");
|
|
103
|
-
Object.defineProperty(exports, "convertObjectValues", { enumerable: true, get: function () { return convert_5.convertObjectValues; } });
|
|
24
|
+
export { cloneObject, countObjectFields, generateQueryParams, isEmptyObject, isObject, } from './object/basics';
|
|
25
|
+
export { extractNewFields, extractUpdatedAndNewFields, extractUpdatedFields, flattenObjectDotNotation, flattenObjectKeyValue, mergeAndFlattenObjects, mergeObjects, } from './object/objectify';
|
|
26
|
+
export { sanitizeData } from './object/sanitize';
|
|
27
|
+
export { convertObjectValues } from './object/convert';
|
|
104
28
|
// ! Other Utilities
|
|
105
|
-
|
|
106
|
-
Object.defineProperty(exports, "convertArrayToString", { enumerable: true, get: function () { return utils_1.convertArrayToString; } });
|
|
107
|
-
Object.defineProperty(exports, "debounceAction", { enumerable: true, get: function () { return utils_1.debounceAction; } });
|
|
108
|
-
Object.defineProperty(exports, "isDeepEqual", { enumerable: true, get: function () { return utils_1.isDeepEqual; } });
|
|
109
|
-
Object.defineProperty(exports, "throttleAction", { enumerable: true, get: function () { return utils_1.throttleAction; } });
|
|
29
|
+
export { convertArrayToString, debounceAction, isDeepEqual, throttleAction, } from './utils';
|
|
110
30
|
// ! Primitive Type Guards
|
|
111
|
-
|
|
112
|
-
Object.defineProperty(exports, "isBoolean", { enumerable: true, get: function () { return primitives_1.isBoolean; } });
|
|
113
|
-
Object.defineProperty(exports, "isFalsy", { enumerable: true, get: function () { return primitives_1.isFalsy; } });
|
|
114
|
-
Object.defineProperty(exports, "isInteger", { enumerable: true, get: function () { return primitives_1.isInteger; } });
|
|
115
|
-
Object.defineProperty(exports, "isNonEmptyString", { enumerable: true, get: function () { return primitives_1.isNonEmptyString; } });
|
|
116
|
-
Object.defineProperty(exports, "isNull", { enumerable: true, get: function () { return primitives_1.isNull; } });
|
|
117
|
-
Object.defineProperty(exports, "isNumber", { enumerable: true, get: function () { return primitives_1.isNumber; } });
|
|
118
|
-
Object.defineProperty(exports, "isPositiveInteger", { enumerable: true, get: function () { return primitives_1.isPositiveInteger; } });
|
|
119
|
-
Object.defineProperty(exports, "isPrimitive", { enumerable: true, get: function () { return primitives_1.isPrimitive; } });
|
|
120
|
-
Object.defineProperty(exports, "isString", { enumerable: true, get: function () { return primitives_1.isString; } });
|
|
121
|
-
Object.defineProperty(exports, "isSymbol", { enumerable: true, get: function () { return primitives_1.isSymbol; } });
|
|
122
|
-
Object.defineProperty(exports, "isTruthy", { enumerable: true, get: function () { return primitives_1.isTruthy; } });
|
|
123
|
-
Object.defineProperty(exports, "isUndefined", { enumerable: true, get: function () { return primitives_1.isUndefined; } });
|
|
31
|
+
export { isBoolean, isFalsy, isInteger, isNonEmptyString, isNull, isNumber, isPositiveInteger, isPrimitive, isString, isSymbol, isTruthy, isUndefined, } from './guards/primitives';
|
|
124
32
|
// ! Non-Primitive Type Guards
|
|
125
|
-
|
|
126
|
-
Object.defineProperty(exports, "doesReturnPromise", { enumerable: true, get: function () { return non_primitives_1.isReturningPromise; } });
|
|
127
|
-
Object.defineProperty(exports, "isArray", { enumerable: true, get: function () { return non_primitives_1.isArray; } });
|
|
128
|
-
Object.defineProperty(exports, "isArrayOfType", { enumerable: true, get: function () { return non_primitives_1.isArrayOfType; } });
|
|
129
|
-
Object.defineProperty(exports, "isBigInt", { enumerable: true, get: function () { return non_primitives_1.isBigInt; } });
|
|
130
|
-
Object.defineProperty(exports, "isDate", { enumerable: true, get: function () { return non_primitives_1.isDate; } });
|
|
131
|
-
Object.defineProperty(exports, "isEmptyObjectGuard", { enumerable: true, get: function () { return non_primitives_1.isEmptyObject; } });
|
|
132
|
-
Object.defineProperty(exports, "isError", { enumerable: true, get: function () { return non_primitives_1.isError; } });
|
|
133
|
-
Object.defineProperty(exports, "isFunction", { enumerable: true, get: function () { return non_primitives_1.isFunction; } });
|
|
134
|
-
Object.defineProperty(exports, "isJSON", { enumerable: true, get: function () { return non_primitives_1.isJSON; } });
|
|
135
|
-
Object.defineProperty(exports, "isJSONObject", { enumerable: true, get: function () { return non_primitives_1.isJSON; } });
|
|
136
|
-
Object.defineProperty(exports, "isMap", { enumerable: true, get: function () { return non_primitives_1.isMap; } });
|
|
137
|
-
Object.defineProperty(exports, "isObjectEmpty", { enumerable: true, get: function () { return non_primitives_1.isEmptyObject; } });
|
|
138
|
-
Object.defineProperty(exports, "isObjectWithKeys", { enumerable: true, get: function () { return non_primitives_1.isObjectWithKeys; } });
|
|
139
|
-
Object.defineProperty(exports, "isPromise", { enumerable: true, get: function () { return non_primitives_1.isPromise; } });
|
|
140
|
-
Object.defineProperty(exports, "isRegExp", { enumerable: true, get: function () { return non_primitives_1.isRegExp; } });
|
|
141
|
-
Object.defineProperty(exports, "isRegularExpression", { enumerable: true, get: function () { return non_primitives_1.isRegExp; } });
|
|
142
|
-
Object.defineProperty(exports, "isReturningPromise", { enumerable: true, get: function () { return non_primitives_1.isReturningPromise; } });
|
|
143
|
-
Object.defineProperty(exports, "isSet", { enumerable: true, get: function () { return non_primitives_1.isSet; } });
|
|
144
|
-
Object.defineProperty(exports, "isValidJSON", { enumerable: true, get: function () { return non_primitives_1.isJSON; } });
|
|
145
|
-
Object.defineProperty(exports, "isValidMap", { enumerable: true, get: function () { return non_primitives_1.isMap; } });
|
|
146
|
-
Object.defineProperty(exports, "isValidObject", { enumerable: true, get: function () { return non_primitives_1.isObject; } });
|
|
147
|
-
Object.defineProperty(exports, "isValidSet", { enumerable: true, get: function () { return non_primitives_1.isSet; } });
|
|
33
|
+
export { isReturningPromise as doesReturnPromise, isArray, isArrayOfType, isBigInt, isDate, isEmptyObject as isEmptyObjectGuard, isError, isFunction, isJSON, isJSON as isJSONObject, isMap, isEmptyObject as isObjectEmpty, isObjectWithKeys, isPromise, isRegExp, isRegExp as isRegularExpression, isReturningPromise, isSet, isJSON as isValidJSON, isMap as isValidMap, isObject as isValidObject, isSet as isValidSet, } from './guards/non-primitives';
|
|
148
34
|
// ! Special Type Guards
|
|
149
|
-
|
|
150
|
-
Object.defineProperty(exports, "isBase64", { enumerable: true, get: function () { return specials_1.isBase64; } });
|
|
151
|
-
Object.defineProperty(exports, "isBrowser", { enumerable: true, get: function () { return specials_1.isBrowser; } });
|
|
152
|
-
Object.defineProperty(exports, "isDateString", { enumerable: true, get: function () { return specials_1.isDateString; } });
|
|
153
|
-
Object.defineProperty(exports, "isEmail", { enumerable: true, get: function () { return specials_1.isEmail; } });
|
|
154
|
-
Object.defineProperty(exports, "isEmailArray", { enumerable: true, get: function () { return specials_1.isEmailArray; } });
|
|
155
|
-
Object.defineProperty(exports, "isEnvironment", { enumerable: true, get: function () { return specials_1.isEnvironment; } });
|
|
156
|
-
Object.defineProperty(exports, "isExpectedNodeENV", { enumerable: true, get: function () { return specials_1.isEnvironment; } });
|
|
157
|
-
Object.defineProperty(exports, "isIPAddress", { enumerable: true, get: function () { return specials_1.isIPAddress; } });
|
|
158
|
-
Object.defineProperty(exports, "isNode", { enumerable: true, get: function () { return specials_1.isNode; } });
|
|
159
|
-
Object.defineProperty(exports, "isNodeENV", { enumerable: true, get: function () { return specials_1.isEnvironment; } });
|
|
160
|
-
Object.defineProperty(exports, "isNodeEnvironment", { enumerable: true, get: function () { return specials_1.isEnvironment; } });
|
|
161
|
-
Object.defineProperty(exports, "isNumericString", { enumerable: true, get: function () { return specials_1.isNumericString; } });
|
|
162
|
-
Object.defineProperty(exports, "isPhoneNumber", { enumerable: true, get: function () { return specials_1.isPhoneNumber; } });
|
|
163
|
-
Object.defineProperty(exports, "isURL", { enumerable: true, get: function () { return specials_1.isURL; } });
|
|
164
|
-
Object.defineProperty(exports, "isUUID", { enumerable: true, get: function () { return specials_1.isUUID; } });
|
|
165
|
-
Object.defineProperty(exports, "isValidEmail", { enumerable: true, get: function () { return specials_1.isEmail; } });
|
|
166
|
-
Object.defineProperty(exports, "isValidURL", { enumerable: true, get: function () { return specials_1.isURL; } });
|
|
35
|
+
export { isBase64, isBrowser, isDateString, isEmail, isEmailArray, isEnvironment, isEnvironment as isExpectedNodeENV, isIPAddress, isNode, isEnvironment as isNodeENV, isEnvironment as isNodeEnvironment, isNumericString, isPhoneNumber, isURL, isUUID, isEmail as isValidEmail, isURL as isValidURL, } from './guards/specials';
|
package/dist/number/basics.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isMultiple = exports.isOdd = exports.isEven = exports.calculateLCM = exports.calculateHCF = exports.convertToDecimal = exports.getRandomNumber = void 0;
|
|
4
|
-
const helpers_1 = require("./helpers");
|
|
1
|
+
import { _find2NumbersHCF, _find2NumbersLCM } from './helpers';
|
|
5
2
|
/**
|
|
6
3
|
* * Utility to generate a random number between a given range.
|
|
7
4
|
* * If no options are provided, it will generate a random number between `0` and `100` (inclusive).
|
|
@@ -10,12 +7,12 @@ const helpers_1 = require("./helpers");
|
|
|
10
7
|
* @param options - Options for configuring random number generator.
|
|
11
8
|
* @returns Random number.
|
|
12
9
|
*/
|
|
13
|
-
const getRandomNumber = (options) => {
|
|
10
|
+
export const getRandomNumber = (options) => {
|
|
14
11
|
const { min = 0, max = 100, includeMin = true, includeMax = true, } = options || {};
|
|
15
12
|
let minimum = min, maximum = max;
|
|
16
13
|
if (min > max) {
|
|
17
14
|
[minimum, maximum] = [max, min];
|
|
18
|
-
return
|
|
15
|
+
return getRandomNumber({
|
|
19
16
|
min: minimum,
|
|
20
17
|
max: maximum,
|
|
21
18
|
includeMin,
|
|
@@ -43,7 +40,6 @@ const getRandomNumber = (options) => {
|
|
|
43
40
|
}
|
|
44
41
|
return 0;
|
|
45
42
|
};
|
|
46
|
-
exports.getRandomNumber = getRandomNumber;
|
|
47
43
|
/**
|
|
48
44
|
* * Utility to round a number to given decimal places.
|
|
49
45
|
*
|
|
@@ -51,7 +47,7 @@ exports.getRandomNumber = getRandomNumber;
|
|
|
51
47
|
* @param options - Options for rounding behavior, including decimal places and return type.
|
|
52
48
|
* @returns Converted number as `number` (default) or `string` (if `isString` is `true`).
|
|
53
49
|
*/
|
|
54
|
-
const convertToDecimal = (input, options) => {
|
|
50
|
+
export const convertToDecimal = (input, options) => {
|
|
55
51
|
const { decimalPlaces = 2, isString = false } = options || {};
|
|
56
52
|
let number;
|
|
57
53
|
if (typeof input === 'number') {
|
|
@@ -64,55 +60,50 @@ const convertToDecimal = (input, options) => {
|
|
|
64
60
|
number.toFixed(decimalPlaces)
|
|
65
61
|
: Number(number.toFixed(decimalPlaces));
|
|
66
62
|
};
|
|
67
|
-
exports.convertToDecimal = convertToDecimal;
|
|
68
63
|
/**
|
|
69
64
|
* * Calculates the HCF/GCD of multiple numbers.
|
|
70
65
|
*
|
|
71
66
|
* @param numbers - List of numbers to find the HCF/GCD for.
|
|
72
67
|
* @returns The HCF/GCD of all the provided numbers.
|
|
73
68
|
*/
|
|
74
|
-
const calculateHCF = (...numbers) => {
|
|
69
|
+
export const calculateHCF = (...numbers) => {
|
|
75
70
|
let hcf = numbers[0];
|
|
76
71
|
for (let i = 1; i < numbers.length; i++) {
|
|
77
|
-
hcf =
|
|
72
|
+
hcf = _find2NumbersHCF(hcf, numbers[i]);
|
|
78
73
|
}
|
|
79
74
|
return hcf;
|
|
80
75
|
};
|
|
81
|
-
exports.calculateHCF = calculateHCF;
|
|
82
76
|
/**
|
|
83
77
|
* * Calculates the LCM/LCD of multiple numbers.
|
|
84
78
|
*
|
|
85
79
|
* @param numbers - List of numbers to find the LCM/LCD for.
|
|
86
80
|
* @returns The LCM/LCD of all the provided numbers.
|
|
87
81
|
*/
|
|
88
|
-
const calculateLCM = (...numbers) => {
|
|
82
|
+
export const calculateLCM = (...numbers) => {
|
|
89
83
|
let lcm = numbers[0];
|
|
90
84
|
for (let i = 1; i < numbers.length; i++) {
|
|
91
|
-
lcm =
|
|
85
|
+
lcm = _find2NumbersLCM(lcm, numbers[i]);
|
|
92
86
|
}
|
|
93
87
|
return lcm;
|
|
94
88
|
};
|
|
95
|
-
exports.calculateLCM = calculateLCM;
|
|
96
89
|
/**
|
|
97
90
|
* * Check if a number is even or not.
|
|
98
91
|
*
|
|
99
92
|
* @param input The number to check.
|
|
100
93
|
* @returns Boolean: `true` if even and `false` if not even.
|
|
101
94
|
*/
|
|
102
|
-
const isEven = (input) => {
|
|
95
|
+
export const isEven = (input) => {
|
|
103
96
|
return input % 2 === 0;
|
|
104
97
|
};
|
|
105
|
-
exports.isEven = isEven;
|
|
106
98
|
/**
|
|
107
99
|
* * Checks if a number is odd or not.
|
|
108
100
|
*
|
|
109
101
|
* @param input The number to check.
|
|
110
102
|
* @returns Boolean: `true` if odd and `false` if not odd.
|
|
111
103
|
*/
|
|
112
|
-
const isOdd = (input) => {
|
|
104
|
+
export const isOdd = (input) => {
|
|
113
105
|
return input % 2 !== 0;
|
|
114
106
|
};
|
|
115
|
-
exports.isOdd = isOdd;
|
|
116
107
|
/**
|
|
117
108
|
* * Checks if a number is a multiple of another number.
|
|
118
109
|
*
|
|
@@ -120,7 +111,6 @@ exports.isOdd = isOdd;
|
|
|
120
111
|
* @param multipleOf - The number to check against.
|
|
121
112
|
* @returns `true` if `input` is a multiple of `multipleOf`, otherwise `false`.
|
|
122
113
|
*/
|
|
123
|
-
const isMultiple = (input, multipleOf) => {
|
|
114
|
+
export const isMultiple = (input, multipleOf) => {
|
|
124
115
|
return input % multipleOf === 0;
|
|
125
116
|
};
|
|
126
|
-
exports.isMultiple = isMultiple;
|
package/dist/number/constants.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.thousands = exports.tens = exports.teens = exports.ones = void 0;
|
|
4
|
-
exports.ones = [
|
|
1
|
+
export const ones = [
|
|
5
2
|
'',
|
|
6
3
|
'one',
|
|
7
4
|
'two',
|
|
@@ -13,7 +10,7 @@ exports.ones = [
|
|
|
13
10
|
'eight',
|
|
14
11
|
'nine',
|
|
15
12
|
];
|
|
16
|
-
|
|
13
|
+
export const teens = [
|
|
17
14
|
'',
|
|
18
15
|
'eleven',
|
|
19
16
|
'twelve',
|
|
@@ -25,7 +22,7 @@ exports.teens = [
|
|
|
25
22
|
'eighteen',
|
|
26
23
|
'nineteen',
|
|
27
24
|
];
|
|
28
|
-
|
|
25
|
+
export const tens = [
|
|
29
26
|
'',
|
|
30
27
|
'ten',
|
|
31
28
|
'twenty',
|
|
@@ -37,7 +34,7 @@ exports.tens = [
|
|
|
37
34
|
'eighty',
|
|
38
35
|
'ninety',
|
|
39
36
|
];
|
|
40
|
-
|
|
37
|
+
export const thousands = [
|
|
41
38
|
'',
|
|
42
39
|
'thousand',
|
|
43
40
|
'million',
|
package/dist/number/convert.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.numberToWords = numberToWords;
|
|
4
|
-
const constants_1 = require("./constants");
|
|
5
|
-
const helpers_1 = require("./helpers");
|
|
1
|
+
import { thousands } from './constants';
|
|
2
|
+
import { _convertLessThanThousand } from './helpers';
|
|
6
3
|
/**
|
|
7
4
|
* * Converts a number to words
|
|
8
5
|
* @param number - The number to convert into words.
|
|
9
6
|
* @returns The number converted in words.
|
|
10
7
|
*/
|
|
11
|
-
function numberToWords(number) {
|
|
8
|
+
export function numberToWords(number) {
|
|
12
9
|
const isNegative = number < 0;
|
|
13
10
|
if (number === 0)
|
|
14
11
|
return 'zero';
|
|
@@ -18,8 +15,8 @@ function numberToWords(number) {
|
|
|
18
15
|
while (number > 0) {
|
|
19
16
|
if (number % 1000 !== 0) {
|
|
20
17
|
const isLastGroup = i === 0 && number % 100 < 100;
|
|
21
|
-
const prefix =
|
|
22
|
-
result = `${prefix} ${
|
|
18
|
+
const prefix = _convertLessThanThousand(number % 1000, isLastGroup);
|
|
19
|
+
result = `${prefix} ${thousands[i]} ${result}`;
|
|
23
20
|
}
|
|
24
21
|
number = Math.floor(number / 1000);
|
|
25
22
|
i++;
|
package/dist/number/helpers.js
CHANGED
|
@@ -1,37 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._find2NumbersLCM = exports._find2NumbersHCF = exports._applyMultiples = void 0;
|
|
4
|
-
exports._convertLessThanThousand = _convertLessThanThousand;
|
|
5
|
-
const constants_1 = require("./constants");
|
|
1
|
+
import { ones, teens, tens } from './constants';
|
|
6
2
|
/**
|
|
7
3
|
* Apply multiples of a number if there is any.
|
|
8
4
|
* @param array Array of numbers to apply the condition on.
|
|
9
5
|
* @param multiples The multiples of which number.
|
|
10
6
|
* @returns Array of multiples of the desired number
|
|
11
7
|
*/
|
|
12
|
-
const _applyMultiples = (array, multiples) => {
|
|
8
|
+
export const _applyMultiples = (array, multiples) => {
|
|
13
9
|
if (!multiples)
|
|
14
10
|
return array;
|
|
15
11
|
return array.filter((n) => n % multiples === 0);
|
|
16
12
|
};
|
|
17
|
-
exports._applyMultiples = _applyMultiples;
|
|
18
13
|
/**
|
|
19
14
|
* - Converts a number less than 1000 to words.
|
|
20
15
|
* @param num - The number to convert (less than 1000).
|
|
21
16
|
* @param isLast - Whether this is the last group (thousands, millions, etc.).
|
|
22
17
|
* @returns Numbers less than 1000 in words.
|
|
23
18
|
*/
|
|
24
|
-
function _convertLessThanThousand(num, isLast) {
|
|
19
|
+
export function _convertLessThanThousand(num, isLast) {
|
|
25
20
|
if (num < 10)
|
|
26
|
-
return
|
|
21
|
+
return ones[num];
|
|
27
22
|
if (num < 20)
|
|
28
|
-
return
|
|
29
|
-
let result =
|
|
23
|
+
return teens[num - 10];
|
|
24
|
+
let result = tens[Math.floor(num / 10)];
|
|
30
25
|
const remainder = num % 10;
|
|
31
26
|
if (remainder > 0)
|
|
32
|
-
result += `-${
|
|
27
|
+
result += `-${ones[remainder]}`;
|
|
33
28
|
if (num >= 100) {
|
|
34
|
-
const hundredsPart = `${
|
|
29
|
+
const hundredsPart = `${ones[Math.floor(num / 100)]} hundred`;
|
|
35
30
|
return num % 100 === 0 ?
|
|
36
31
|
hundredsPart
|
|
37
32
|
: `${hundredsPart} ${isLast ? 'and' : ''} ${_convertLessThanThousand(num % 100, false)}`;
|
|
@@ -45,7 +40,7 @@ function _convertLessThanThousand(num, isLast) {
|
|
|
45
40
|
* @param b - Second number.
|
|
46
41
|
* @returns The HCF of the two numbers.
|
|
47
42
|
*/
|
|
48
|
-
const _find2NumbersHCF = (a, b) => {
|
|
43
|
+
export const _find2NumbersHCF = (a, b) => {
|
|
49
44
|
let x = Math.abs(a);
|
|
50
45
|
let y = Math.abs(b);
|
|
51
46
|
while (y !== 0) {
|
|
@@ -55,7 +50,6 @@ const _find2NumbersHCF = (a, b) => {
|
|
|
55
50
|
}
|
|
56
51
|
return x;
|
|
57
52
|
};
|
|
58
|
-
exports._find2NumbersHCF = _find2NumbersHCF;
|
|
59
53
|
/**
|
|
60
54
|
* * Calculate the LCM (Least Common Multiple) of two numbers using the Euclidean algorithm.
|
|
61
55
|
*
|
|
@@ -63,9 +57,8 @@ exports._find2NumbersHCF = _find2NumbersHCF;
|
|
|
63
57
|
* @param b - Second number.
|
|
64
58
|
* @returns The LCM of the two numbers.
|
|
65
59
|
*/
|
|
66
|
-
const _find2NumbersLCM = (a, b) => {
|
|
60
|
+
export const _find2NumbersLCM = (a, b) => {
|
|
67
61
|
const x = Math.abs(a);
|
|
68
62
|
const y = Math.abs(b);
|
|
69
|
-
return (x * y) /
|
|
63
|
+
return (x * y) / _find2NumbersHCF(x, y);
|
|
70
64
|
};
|
|
71
|
-
exports._find2NumbersLCM = _find2NumbersLCM;
|
package/dist/number/prime.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findPrimeNumbers = exports.isPrime = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* * Checks if a number is prime.
|
|
6
3
|
*
|
|
7
4
|
* @param number The number to check.
|
|
8
5
|
* @returns Boolean: `true` if the number is prime, otherwise `false`.
|
|
9
6
|
*/
|
|
10
|
-
const isPrime = (number) => {
|
|
7
|
+
export const isPrime = (number) => {
|
|
11
8
|
if (number < 2)
|
|
12
9
|
return false;
|
|
13
10
|
if (number === 2 || number === 3)
|
|
@@ -20,7 +17,6 @@ const isPrime = (number) => {
|
|
|
20
17
|
}
|
|
21
18
|
return true;
|
|
22
19
|
};
|
|
23
|
-
exports.isPrime = isPrime;
|
|
24
20
|
/**
|
|
25
21
|
* * Find prime numbers in a given range.
|
|
26
22
|
*
|
|
@@ -28,11 +24,10 @@ exports.isPrime = isPrime;
|
|
|
28
24
|
* @param end The ending number of the range. Default is `1000`.
|
|
29
25
|
* @returns An array of prime numbers within the range (inclusive).
|
|
30
26
|
*/
|
|
31
|
-
const findPrimeNumbers = (start = 1, end = 1000) => {
|
|
27
|
+
export const findPrimeNumbers = (start = 1, end = 1000) => {
|
|
32
28
|
let startNumber = start, endNumber = end;
|
|
33
29
|
if (start > end) {
|
|
34
30
|
[startNumber, endNumber] = [end, start];
|
|
35
31
|
}
|
|
36
|
-
return Array.from({ length: endNumber - startNumber + 1 }, (_, i) => startNumber + i).filter(
|
|
32
|
+
return Array.from({ length: endNumber - startNumber + 1 }, (_, i) => startNumber + i).filter(isPrime);
|
|
37
33
|
};
|
|
38
|
-
exports.findPrimeNumbers = findPrimeNumbers;
|
package/dist/number/range.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const basics_2 = require("./basics");
|
|
7
|
-
const helpers_1 = require("./helpers");
|
|
8
|
-
const prime_1 = require("./prime");
|
|
1
|
+
import { shuffleArray } from '../array/basics';
|
|
2
|
+
import { convertArrayToString } from '../utils';
|
|
3
|
+
import { getRandomNumber, isEven, isOdd } from './basics';
|
|
4
|
+
import { _applyMultiples } from './helpers';
|
|
5
|
+
import { isPrime } from './prime';
|
|
9
6
|
/**
|
|
10
7
|
* * Function to get numbers within a range based on the provided `NumberType` and options.
|
|
11
8
|
* * Returns either a string or an array of numbers based on the `getAs` property in options.
|
|
@@ -14,7 +11,7 @@ const prime_1 = require("./prime");
|
|
|
14
11
|
* @param options - Options to configure number generation, including range and formatting.
|
|
15
12
|
* @returns Either a string or an array of numbers.
|
|
16
13
|
*/
|
|
17
|
-
function getNumbersInRange(type = 'any', options) {
|
|
14
|
+
export function getNumbersInRange(type = 'any', options) {
|
|
18
15
|
const { getAs = 'array', min = 0, max = 100, includeMin = true, includeMax = true, separator = ',', multiples, } = options || {};
|
|
19
16
|
let output = [];
|
|
20
17
|
/**
|
|
@@ -46,7 +43,7 @@ function getNumbersInRange(type = 'any', options) {
|
|
|
46
43
|
}
|
|
47
44
|
switch (type) {
|
|
48
45
|
case 'random':
|
|
49
|
-
output =
|
|
46
|
+
output = shuffleArray(_applyRangeOptions(min, max).map((n) => getRandomNumber({
|
|
50
47
|
min: n,
|
|
51
48
|
max: n,
|
|
52
49
|
includeMin,
|
|
@@ -54,13 +51,13 @@ function getNumbersInRange(type = 'any', options) {
|
|
|
54
51
|
})));
|
|
55
52
|
break;
|
|
56
53
|
case 'prime':
|
|
57
|
-
output = _applyRangeOptions(min, max).filter(
|
|
54
|
+
output = _applyRangeOptions(min, max).filter(isPrime);
|
|
58
55
|
break;
|
|
59
56
|
case 'odd':
|
|
60
|
-
output = _applyRangeOptions(min, max).filter(
|
|
57
|
+
output = _applyRangeOptions(min, max).filter(isOdd);
|
|
61
58
|
break;
|
|
62
59
|
case 'even':
|
|
63
|
-
output = _applyRangeOptions(min, max).filter(
|
|
60
|
+
output = _applyRangeOptions(min, max).filter(isEven);
|
|
64
61
|
break;
|
|
65
62
|
case 'natural':
|
|
66
63
|
output = _applyRangeOptions(Math.max(min, 1), max);
|
|
@@ -70,9 +67,9 @@ function getNumbersInRange(type = 'any', options) {
|
|
|
70
67
|
break;
|
|
71
68
|
}
|
|
72
69
|
if (type !== 'prime') {
|
|
73
|
-
output =
|
|
70
|
+
output = _applyMultiples(output, multiples);
|
|
74
71
|
}
|
|
75
72
|
return getAs === 'string' ?
|
|
76
|
-
|
|
73
|
+
convertArrayToString(output, separator)
|
|
77
74
|
: output;
|
|
78
75
|
}
|
package/dist/number/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/object/basics.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isObject = exports.countObjectFields = exports.isEmptyObject = exports.cloneObject = exports.generateQueryParams = void 0;
|
|
4
|
-
const objectify_1 = require("./objectify");
|
|
1
|
+
import { flattenObjectKeyValue } from './objectify';
|
|
5
2
|
/**
|
|
6
3
|
* * Utility to generate query parameters from an object.
|
|
7
4
|
*
|
|
@@ -16,9 +13,9 @@ const objectify_1 = require("./objectify");
|
|
|
16
13
|
* generateQueryParams({ key1: true, key2: false }); // "?key1=true&key2=false"
|
|
17
14
|
* generateQueryParams({ filters: { category: 'laptop', price: 1000 } }); // "?category=laptop&price=1000"
|
|
18
15
|
*/
|
|
19
|
-
const generateQueryParams = (params = {}) => {
|
|
16
|
+
export const generateQueryParams = (params = {}) => {
|
|
20
17
|
// Flatten the nested object into key-value pairs
|
|
21
|
-
const flattenedParams =
|
|
18
|
+
const flattenedParams = flattenObjectKeyValue(params);
|
|
22
19
|
// Generate the query string
|
|
23
20
|
const queryParams = Object.entries(flattenedParams)
|
|
24
21
|
.filter(([_, value]) => value !== undefined &&
|
|
@@ -34,48 +31,43 @@ const generateQueryParams = (params = {}) => {
|
|
|
34
31
|
.join('&');
|
|
35
32
|
return queryParams ? `?${queryParams}` : '';
|
|
36
33
|
};
|
|
37
|
-
exports.generateQueryParams = generateQueryParams;
|
|
38
34
|
/**
|
|
39
35
|
* * Deep clone an object.
|
|
40
36
|
*
|
|
41
37
|
* @param obj Object to clone.
|
|
42
38
|
* @returns Deep cloned object.
|
|
43
39
|
*/
|
|
44
|
-
const cloneObject = (obj) => {
|
|
40
|
+
export const cloneObject = (obj) => {
|
|
45
41
|
return JSON.parse(JSON.stringify(obj));
|
|
46
42
|
};
|
|
47
|
-
exports.cloneObject = cloneObject;
|
|
48
43
|
/**
|
|
49
44
|
* * Check if an object is empty.
|
|
50
45
|
*
|
|
51
46
|
* @param obj Object to check.
|
|
52
47
|
* @returns Whether the object is empty.
|
|
53
48
|
*/
|
|
54
|
-
const isEmptyObject = (obj) => {
|
|
49
|
+
export const isEmptyObject = (obj) => {
|
|
55
50
|
if (obj != null)
|
|
56
|
-
return
|
|
51
|
+
return countObjectFields(obj) === 0;
|
|
57
52
|
return false;
|
|
58
53
|
};
|
|
59
|
-
exports.isEmptyObject = isEmptyObject;
|
|
60
54
|
/**
|
|
61
55
|
* * Count the number of fields in an object.
|
|
62
56
|
*
|
|
63
57
|
* @param obj Object to check.
|
|
64
58
|
* @returns Number of fields in the object.
|
|
65
59
|
*/
|
|
66
|
-
const countObjectFields = (obj) => {
|
|
60
|
+
export const countObjectFields = (obj) => {
|
|
67
61
|
if (obj != null)
|
|
68
62
|
return Object.keys(obj).length;
|
|
69
63
|
return 0;
|
|
70
64
|
};
|
|
71
|
-
exports.countObjectFields = countObjectFields;
|
|
72
65
|
/**
|
|
73
66
|
* * Check whether data is object and not array.
|
|
74
67
|
*
|
|
75
68
|
* @param data Data to check if its an object and not array.
|
|
76
69
|
* @returns Boolean: `true` if it's an object, `false` if not.
|
|
77
70
|
*/
|
|
78
|
-
const isObject = (data) => {
|
|
71
|
+
export const isObject = (data) => {
|
|
79
72
|
return typeof data === 'object' && !Array.isArray(data);
|
|
80
73
|
};
|
|
81
|
-
exports.isObject = isObject;
|