deverything 0.48.1 → 0.50.0

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 CHANGED
@@ -15,8 +15,8 @@ Contributions always welcome!
15
15
 
16
16
  ### Validators
17
17
 
18
- - `isArray()`
19
- - `isBoolean()`
18
+ - `isArray()`
19
+ - `isBoolean()`
20
20
  - `isBrowser()` to detect if you are on the browser
21
21
  - `isBuffer()` if it's a buffer
22
22
  - `isClient()` same as isBrowser
@@ -26,20 +26,20 @@ Contributions always welcome!
26
26
  - `isEmptyArray()` checks if the array has no items
27
27
  - `isEmptyObject()` checks if the object has no keys
28
28
  - `isFile()` if it's a file
29
- - `isFunction()`
29
+ - `isFunction()`
30
30
  - `isJsDate()` if it's a **valid** javascript's Date
31
- - `isFutureDate()`
32
- - `isPastDate()`
31
+ - `isFutureDate()`
32
+ - `isPastDate()`
33
33
  - `isStringDate()` also checks if the string passed is a **valid** date
34
34
  - `isKey()` is a real key of an object
35
35
  - `isLastIndex()` is the index is the last item of array
36
36
  - `isNotEmptyString()` must have some text, checks for spaces-only
37
37
  - `isNumber()` if the arg is number, and also usable (no infinity)
38
38
  - `isInt()` if it's an integer
39
- - `isEven()`
40
- - `isOdd()`
41
- - `isPositiveInt()`
42
- - `isNegativeInt()`
39
+ - `isEven()`
40
+ - `isOdd()`
41
+ - `isPositiveInt()`
42
+ - `isNegativeInt()`
43
43
  - `isNumeric()` if string is representing a number
44
44
  - ⭐ `isObject()` if it's a js plain Object
45
45
  - `isPromise()` if it's a promise
@@ -49,12 +49,24 @@ Contributions always welcome!
49
49
  - ⭐ `isSame()` Compare if dates, functions, arrays, objects or anything else are the same
50
50
  - `isServer()` if you are on the server
51
51
  - `isString()`
52
- - `isURL()`
52
+ - `isURL()`
53
53
  - `isUUID()` if it's a valid UUID
54
54
 
55
+ ### Dates
56
+
57
+ - `isOver18()`
58
+ - `startOfNextMonth()`
59
+ - `startOfNextWeek()`
60
+ - `startOfThisWeek()`
61
+ - `startOfToday()`
62
+ - `startOfTomorrow()`
63
+
55
64
  ### Math
56
65
 
57
66
  - `average()`
67
+ - `isBetween()`
68
+ - `isOutside()`
69
+ - `isStrictlyBetween()`
58
70
  - `max()`
59
71
  - `min()`
60
72
  - `multiply()`
@@ -112,7 +124,7 @@ Contributions always welcome!
112
124
 
113
125
  These functions are optimized for low entropy random data generation useful for Unit Testing, Storybook, Pass real validations, Reverse hacking, Penetration testing...
114
126
 
115
- - `randomAddress()`
127
+ - `randomAddress()`
116
128
  - `randomAlphaNumericCode()`
117
129
  - ⭐ `randomArrayItem()` now supporting non-uniform distribution
118
130
  - `randomBankAccount()`
package/dist/index.d.ts CHANGED
@@ -38,6 +38,84 @@ type Config = {
38
38
  */
39
39
  declare const checkEnvVars: (envVarsMap: Record<string, SimpleValidationRule | EnvValidation | WithEnvValidation>, config?: Config) => void;
40
40
 
41
+ type Coords = {
42
+ lat: number;
43
+ lng: number;
44
+ };
45
+
46
+ type DateLike = Date | string | number;
47
+ type Datey = Date | string;
48
+ type ISODate = string;
49
+ type DateRange = {
50
+ startDate: DateLike;
51
+ endDate: DateLike;
52
+ };
53
+
54
+ type Dimensions = {
55
+ width: number;
56
+ height: number;
57
+ };
58
+
59
+ type Key = string | number | symbol;
60
+ type PlainKey = string | number;
61
+ type ObjectKey<T> = keyof T;
62
+ type ObjectKeys<T> = ObjectKey<T>[];
63
+ type ObjectValue<T> = T[keyof T];
64
+ type ObjectValues<T> = ObjectValue<T>[];
65
+ type ObjectEntry<T> = {
66
+ [K in keyof T]: [K, T[K]];
67
+ }[keyof T];
68
+ type ObjectEntries<T> = ObjectEntry<T>[];
69
+ /**
70
+ * A plain object is an object that is not an array, does not have a length property, and is not a function.
71
+ * Would have been nice to call it just Object, but that's already taken by the built-in type.
72
+ */
73
+ type PlainObject<T = any> = Record<PlainKey, T> & {
74
+ length?: never;
75
+ };
76
+
77
+ type HashMap<T = any> = Record<PlainKey, T>;
78
+ type NumberMap = Record<PlainKey, number>;
79
+ type StringMap = Record<PlainKey, string>;
80
+ type BoolMap = Record<PlainKey, boolean>;
81
+ type TrueMap = Record<PlainKey, true>;
82
+
83
+ type Matrix<T> = T[][];
84
+
85
+ type Maybe<T> = T | null | undefined;
86
+ type MaybePromise<T> = Maybe<Promise<T>>;
87
+ type MaybePromiseOrValue<T> = MaybePromise<T> | T;
88
+ type MaybePromiseOrValueArray<T> = MaybePromiseOrValue<T>[];
89
+
90
+ type NonUndefined<T> = T extends undefined ? never : T;
91
+
92
+ type Point = {
93
+ x: number;
94
+ y: number;
95
+ };
96
+
97
+ type PrismaSelect<T> = Record<keyof T, true>;
98
+
99
+ type Serialized<T> = T extends Date ? string : T extends Array<infer R> ? Array<Serialized<R>> : T extends object ? {
100
+ [K in keyof T]: Serialized<T[K]>;
101
+ } : T;
102
+
103
+ type WithDatey<T> = T extends Date ? Datey : T extends Array<infer R> ? Array<WithDatey<R>> : T extends object ? {
104
+ [K in keyof T]: WithDatey<T[K]>;
105
+ } : T;
106
+
107
+ declare const isOver18: (birthDate: DateLike) => boolean;
108
+
109
+ declare const startOfNextMonth: () => Date;
110
+
111
+ declare const startOfNextWeek: () => Date;
112
+
113
+ declare const startOfThisWeek: () => Date;
114
+
115
+ declare const startOfToday: () => Date;
116
+
117
+ declare const startOfTomorrow: () => Date;
118
+
41
119
  declare const formatCamelCase: (str: string) => string;
42
120
 
43
121
  /**
@@ -116,77 +194,12 @@ declare const cyclicalItem: <T>(array: T[], index: number) => T;
116
194
  */
117
195
  declare const dir: (arg: any, depth?: number) => void;
118
196
 
119
- type Key = string | number | symbol;
120
- type PlainKey = string | number;
121
- type ObjectKey<T> = keyof T;
122
- type ObjectKeys<T> = ObjectKey<T>[];
123
- type ObjectValue<T> = T[keyof T];
124
- type ObjectValues<T> = ObjectValue<T>[];
125
- type ObjectEntry<T> = {
126
- [K in keyof T]: [K, T[K]];
127
- }[keyof T];
128
- type ObjectEntries<T> = ObjectEntry<T>[];
129
- /**
130
- * A plain object is an object that is not an array, does not have a length property, and is not a function.
131
- * Would have been nice to call it just Object, but that's already taken by the built-in type.
132
- */
133
- type PlainObject<T = any> = Record<PlainKey, T> & {
134
- length?: never;
135
- };
136
-
137
197
  declare const enumKeys: <T extends object>(arg: T) => ObjectKeys<T>;
138
198
 
139
199
  declare const enumValues: <T extends object>(enumObject: T) => ObjectValues<T>;
140
200
 
141
201
  declare const first: <T>(arr?: T[] | undefined) => T | undefined;
142
202
 
143
- type Coords = {
144
- lat: number;
145
- lng: number;
146
- };
147
-
148
- type DateLike = Date | string | number;
149
- type Datey = Date | string;
150
- type DateRange = {
151
- startDate: DateLike;
152
- endDate: DateLike;
153
- };
154
-
155
- type Dimensions = {
156
- width: number;
157
- height: number;
158
- };
159
-
160
- type HashMap<T> = Record<PlainKey, T>;
161
- type NumberMap = Record<PlainKey, number>;
162
- type StringMap = Record<PlainKey, string>;
163
- type BoolMap = Record<PlainKey, boolean>;
164
- type TrueMap = Record<PlainKey, true>;
165
-
166
- type Matrix<T> = T[][];
167
-
168
- type Maybe<T> = T | null | undefined;
169
- type MaybePromise<T> = Maybe<Promise<T>>;
170
- type MaybePromiseOrValue<T> = MaybePromise<T> | T;
171
- type MaybePromiseOrValueArray<T> = MaybePromiseOrValue<T>[];
172
-
173
- type NonUndefined<T> = T extends undefined ? never : T;
174
-
175
- type Point = {
176
- x: number;
177
- y: number;
178
- };
179
-
180
- type PrismaSelect<T> = Record<keyof T, true>;
181
-
182
- type Serialized<T> = T extends Date ? string : T extends Array<infer R> ? Array<Serialized<R>> : T extends object ? {
183
- [K in keyof T]: Serialized<T[K]>;
184
- } : T;
185
-
186
- type WithDatey<T> = T extends Date ? Datey : T extends Array<infer R> ? Array<WithDatey<R>> : T extends object ? {
187
- [K in keyof T]: WithDatey<T[K]>;
188
- } : T;
189
-
190
203
  declare const firstKey: <T extends PlainObject<any>>(arg: T) => keyof T;
191
204
 
192
205
  declare const firstValue: <T extends PlainObject<any>>(arg: T) => ObjectValue<T>;
@@ -317,14 +330,16 @@ declare const average: (numbers: number[]) => number;
317
330
 
318
331
  declare const isBetween: (value: number, min: number, max: number) => boolean;
319
332
 
333
+ declare const isOutside: (value: number, min: number, max: number) => boolean;
334
+
335
+ declare const isStrictlyBetween: (value: number, min: number, max: number) => boolean;
336
+
320
337
  declare const max: (values: number[]) => number;
321
338
 
322
339
  declare const min: (values: number[]) => number;
323
340
 
324
341
  declare const multiply: (numbers: number[]) => number;
325
342
 
326
- declare const isOutside: (value: number, min: number, max: number) => boolean;
327
-
328
343
  declare const percentageChange: ({ previous, current, }: {
329
344
  previous: number;
330
345
  current: number;
@@ -616,4 +631,4 @@ declare const isUUID: (arg: string) => boolean;
616
631
 
617
632
  declare const isValue: (arg?: Maybe<any>) => boolean;
618
633
 
619
- export { BoolMap, Coords, DateLike, DateRange, Datey, Dimensions, HashMap, JS_MAX_DIGITS, Key, Matrix, Maybe, MaybePromise, MaybePromiseOrValue, MaybePromiseOrValueArray, NonUndefined, NumberMap, ObjectEntries, ObjectEntry, ObjectKey, ObjectKeys, ObjectValue, ObjectValues, PlainKey, PlainObject, Point, PrismaSelect, Serialized, StringMap, TrueMap, WithDatey, array, arrayDiff, arrayIntersection, average, capitalize, checkEnvVars, chunkArray, chunkedAll, chunkedAsync, clamp, cleanSpaces, cyclicalItem, dir, enumKeys, enumValues, first, firstKey, firstValue, formatCamelCase, formatNumber, formatPercentage, formatProgress, formatTrpcInputQueryString, getCookieByName, getEnumerableOwnPropertySymbols, getKeys, getUrlSearchParam, getUrlSearchParams, incrementalId, isArray, isArrayIncluded, isBetween, isBoolean, isBrowser, isBuffer, isClient, isEmail, isEmpty, isEmptyArray, isEmptyObject, isEmptyString, isEven, isFile, isFunction, isFutureDate, isInt, isJsDate, isKey, isLastIndex, isNegative, isNegativeInt, isNotEmptyString, isNumber, isNumeric, isNumericId, isObject, isOdd, isOutside, isPWA, isPastDate, isPositive, isPositiveInt, isPromise, isReactElement, isRegExp, isSame, isServer, isSpacedString, isString, isStringDate, isURL, isUUID, isValue, keysLength, last, lastIndex, max, merge, mergeArrays, min, moveToFirst, moveToLast, multiply, normalizeNumber, objectDiff, omit, parseDate, percentageChange, pickObjectKeys, pickObjectValues, pretty, prismaDateRange, promiseWithTimeout, randomAddress, randomAlphaNumericCode, randomArrayItem, randomBankAccount, randomBool, randomChar, randomCompany, randomCoords, randomDate, randomDateRange, randomEmail, randomEmoji, randomEnumKey, randomEnumValue, randomFile, randomFirstName, randomFloat, randomFormattedPercentage, randomFullName, randomFutureDate, randomHandle, randomHexColor, randomHexValue, randomHtmlColorName, randomIBAN, randomIP, randomInt, randomLastName, randomLat, randomLng, randomMaxDate, randomMaxInt, randomMaxSafeInt, randomName, randomNegativeInt, randomNoun, randomNumericCode, randomNumericId, randomParagraph, randomPassword, randomPastDate, randomPath, randomPercentage, randomPhoneNumber, randomPositiveInt, randomPositivePercentage, randomString, randomUUID, randomVerb, randomWord, scrambleText, serialize, seriesAll, setObjectPath, setUrlSearchParams, shuffle, sleep, stringToCSSUnicode, stringToUnicode, sum, toggleArray, toggleArrayValue, truncate, uniqueValues };
634
+ export { BoolMap, Coords, DateLike, DateRange, Datey, Dimensions, HashMap, ISODate, JS_MAX_DIGITS, Key, Matrix, Maybe, MaybePromise, MaybePromiseOrValue, MaybePromiseOrValueArray, NonUndefined, NumberMap, ObjectEntries, ObjectEntry, ObjectKey, ObjectKeys, ObjectValue, ObjectValues, PlainKey, PlainObject, Point, PrismaSelect, Serialized, StringMap, TrueMap, WithDatey, array, arrayDiff, arrayIntersection, average, capitalize, checkEnvVars, chunkArray, chunkedAll, chunkedAsync, clamp, cleanSpaces, cyclicalItem, dir, enumKeys, enumValues, first, firstKey, firstValue, formatCamelCase, formatNumber, formatPercentage, formatProgress, formatTrpcInputQueryString, getCookieByName, getEnumerableOwnPropertySymbols, getKeys, getUrlSearchParam, getUrlSearchParams, incrementalId, isArray, isArrayIncluded, isBetween, isBoolean, isBrowser, isBuffer, isClient, isEmail, isEmpty, isEmptyArray, isEmptyObject, isEmptyString, isEven, isFile, isFunction, isFutureDate, isInt, isJsDate, isKey, isLastIndex, isNegative, isNegativeInt, isNotEmptyString, isNumber, isNumeric, isNumericId, isObject, isOdd, isOutside, isOver18, isPWA, isPastDate, isPositive, isPositiveInt, isPromise, isReactElement, isRegExp, isSame, isServer, isSpacedString, isStrictlyBetween, isString, isStringDate, isURL, isUUID, isValue, keysLength, last, lastIndex, max, merge, mergeArrays, min, moveToFirst, moveToLast, multiply, normalizeNumber, objectDiff, omit, parseDate, percentageChange, pickObjectKeys, pickObjectValues, pretty, prismaDateRange, promiseWithTimeout, randomAddress, randomAlphaNumericCode, randomArrayItem, randomBankAccount, randomBool, randomChar, randomCompany, randomCoords, randomDate, randomDateRange, randomEmail, randomEmoji, randomEnumKey, randomEnumValue, randomFile, randomFirstName, randomFloat, randomFormattedPercentage, randomFullName, randomFutureDate, randomHandle, randomHexColor, randomHexValue, randomHtmlColorName, randomIBAN, randomIP, randomInt, randomLastName, randomLat, randomLng, randomMaxDate, randomMaxInt, randomMaxSafeInt, randomName, randomNegativeInt, randomNoun, randomNumericCode, randomNumericId, randomParagraph, randomPassword, randomPastDate, randomPath, randomPercentage, randomPhoneNumber, randomPositiveInt, randomPositivePercentage, randomString, randomUUID, randomVerb, randomWord, scrambleText, serialize, seriesAll, setObjectPath, setUrlSearchParams, shuffle, sleep, startOfNextMonth, startOfNextWeek, startOfThisWeek, startOfToday, startOfTomorrow, stringToCSSUnicode, stringToUnicode, sum, toggleArray, toggleArrayValue, truncate, uniqueValues };