deverything 3.2.0 → 3.3.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
@@ -17,6 +17,7 @@ Contributions always welcome!
17
17
  ### Validators
18
18
 
19
19
  - `isArray()`
20
+ - `isArrayIncluded()`
20
21
  - `isBoolean()`
21
22
  - `isBrowser()` to detect if you are on the browser
22
23
  - `isBuffer()` if it's a buffer
@@ -42,6 +43,7 @@ Contributions always welcome!
42
43
  - `isPositiveInt()`
43
44
  - `isNegativeInt()`
44
45
  - `isNumeric()` if string is representing a number
46
+ - `isNumericId()` if it's a valid numeric ID
45
47
  - ⭐ `isObject()` if it's a js plain Object
46
48
  - `isPromise()` if it's a promise
47
49
  - `isPWA()` to detect if you are on a PWA
@@ -50,18 +52,24 @@ Contributions always welcome!
50
52
  - ⭐ `isSame()` Compare if dates, functions, arrays, objects or anything else are the same
51
53
  - `isSequence()` if the array is a perfect sequence
52
54
  - `isServer()` if you are on the server
55
+ - `isSpacedString()` if string contains spaces
53
56
  - `isString()`
54
57
  - `isURL()`
55
58
  - `isUUID()` if it's a valid UUID
59
+ - `isValue()` if it's a defined value (not null, undefined, or empty string)
56
60
 
57
61
  ### Dates
58
62
 
63
+ - `getDateRangeSeries()` generate a series of dates within a range
59
64
  - `isOver18()`
65
+ - `startOfDay()` get the start of a specific day
60
66
  - `startOfNextMonth()`
61
67
  - `startOfNextWeek()`
62
68
  - `startOfThisWeek()`
63
69
  - `startOfToday()`
64
70
  - `startOfTomorrow()`
71
+ - `startOfUTCDay()` get the start of a specific day in UTC
72
+ - `startOfUTCTomorrow()` get the start of tomorrow in UTC
65
73
 
66
74
  ### Math
67
75
 
@@ -83,14 +91,22 @@ Contributions always welcome!
83
91
  - `arrayDiff()` get the difference of two arrays
84
92
  - `arrayIntersection()` get the intersection of two arrays
85
93
  - `capitalize()` word => Word
94
+ - `chunkArray()` split array into chunks
95
+ - `chunkedAll()` process all items in chunks
96
+ - `chunkedAsync()` process async operations in chunks
97
+ - `chunkedDynamic()` process with dynamic chunk sizes
86
98
  - `clamp()` clamp number in a range
87
99
  - `cleanSpaces()` trims and turns double spaces into single space
100
+ - `cyclicalItem()` get item from array with cyclical indexing
101
+ - `dir()` get directory listing
88
102
  - `enumKeys()` enum FRUIT { APPLE, PEAR } => ["APPLE", "PEAR"]
89
103
  - `enumValues()` enum FRUIT { APPLE = 1, PEAR = 3 } => [1, 3]
90
104
  - `filterAlphanumeric()` remove non-alphanumeric characters
91
105
  - `first()` get the first element of an array
92
106
  - `firstKey()` get the first key of an object
93
107
  - `firstValue()` get the first value of an object
108
+ - `getCookieByName()` get cookie value by name
109
+ - `getKeys()` get all keys from an object
94
110
  - `getUrlSearchParam()` get URL search param
95
111
  - `getUrlSearchParams()` get URL search params
96
112
  - `groupByKey()`
@@ -100,15 +116,21 @@ Contributions always welcome!
100
116
  - `lastIndex()` get the last index of an array
101
117
  - `mapByKey()`
102
118
  - ⭐ `merge()` deep merge objects
119
+ - `mergeArrays()` merge multiple arrays
103
120
  - `moveToFirst()` move array element to first
104
121
  - `moveToIndex()` move array element to desired index
105
122
  - `moveToLast()` move array element to last
106
123
  - `normalizeNumber()` normalizes between 0 and 1
107
124
  - `objectDiff()` get the difference between two objects
125
+ - `omit()` omit properties from object
108
126
  - ⭐ `parseDate()` pass anything Date-Like, and get a JS Date back
127
+ - `pickObjectKeys()` pick specific keys from object
128
+ - `pickObjectValues()` pick specific values from object
109
129
  - `pluck()` make array of value from object keys
110
130
  - `promiseWithTimeout()` takes a promise, a timeoutMs, and an option error as arguments. Returns a new Promise that either resolves with the value of the input promise or rejects with the provided error or a default error message if the input promise does not resolve or reject within the specified timeoutMs.
131
+ - `removeUndefinedValues()` remove undefined values from object
111
132
  - `scrambleText()` replace alpha chars with random chars
133
+ - `serialize()` serialize object to string
112
134
  - `seriesAsync()` executes promises in series, and returns all results
113
135
  - `setObjectPath()` set a value in an object by path
114
136
  - `setUrlSearchParams()` set URL search params
@@ -126,6 +148,7 @@ Contributions always welcome!
126
148
  - `formatNumber()` 1000 => "1,000" or "1K" or 0.112 => "11.2%"
127
149
  - `formatPercentage()` 0.11 => "11%"
128
150
  - `formatIndexProgress()` => "[2/10]"
151
+ - `formatProgress()` format progress as percentage
129
152
  - `stringToCSSUnicode()` "hello" => "\000068\000065\00006c\00006c\00006f" use this for CSS
130
153
  - `stringToUnicode()` "hello" => "\u0068\u0065\u006c\u006c\u006f"
131
154
 
@@ -151,6 +174,7 @@ These functions are optimized for low entropy random data generation useful for
151
174
  - `randomDateRange()` => { startDate, endDate }
152
175
  - `randomEmail()`
153
176
  - `randomEmoji()`
177
+ - `randomEmptyValue()` random empty value (null, undefined, empty string)
154
178
  - `randomEnumKey()` enum FRUIT { APPLE, PEAR } => APPLE
155
179
  - `randomEnumValue()` enum FRUIT { APPLE = 1, PEAR = 3 } => 3
156
180
  - `randomFile()`
@@ -190,29 +214,27 @@ These functions are optimized for low entropy random data generation useful for
190
214
  - `DateLike`
191
215
  - `Defined<T>`
192
216
  - `Dimensions`
217
+ - `Function`
193
218
  - `HashMap<>`
194
219
  - `BoolMap`
195
220
  - `NumberMap`
196
221
  - `StringMap`
197
222
  - `TrueMap`
198
223
  - `Key`
224
+ - `Matrix`
199
225
  - `Maybe<>`
200
226
  - `MaybePromise<>`
201
227
  - `MaybePromiseOrValue<>`
202
228
  - `MaybePromiseOrValueArray<>`
203
229
  - `NonUndefined`
204
- - `ObjectEntries<>`
205
- - `ObjectEntry<>`
206
- - `ObjectKey<>`
207
- - `ObjectKeys<>`
208
- - `ObjectValue<>`
209
- - `ObjectValues<>`
210
- - ⭐ `PlainObject` use this instead of `Record<,>` or `extends object`, also makes sure it's not an array
230
+ - `Object`
211
231
  - `PickDefined<T, K>`
212
232
  - `PickRequired<T, K>`
213
233
  - `PlainKey`
214
234
  - `Point`
215
- - `VoidFn`
235
+ - `PrismaSelect`
236
+ - `Serialized`
237
+ - `Tuple`
216
238
 
217
239
  ## Development
218
240
 
package/dist/index.d.ts CHANGED
@@ -25,10 +25,11 @@ type ISOYear = string;
25
25
  * @example "America/New_York"
26
26
  */
27
27
  type Timezone = string;
28
- type DateRange = {
29
- startDate: DateLike;
30
- endDate: DateLike;
28
+ type DateRange<T extends DateLike = DateLike> = {
29
+ startDate: T;
30
+ endDate: T;
31
31
  };
32
+ type DateSeries<T extends DateLike = DateLike> = T[];
32
33
 
33
34
  /**
34
35
  * Makes all keys required and removes undefined and null from the value types.
@@ -152,8 +153,22 @@ declare const getDateRangeSeries: (dateRange: DateRange, unit: "day" | "hour" |
152
153
  */
153
154
  declare const getDateSeries: (startDate: Date, endDate: Date, unit: "days" | "hours" | "minutes" | "seconds") => ISODate[];
154
155
 
156
+ /**
157
+ * @description Returns the smallest and biggest dates from an array of dates in DateRange format
158
+ * @param dates - Array of dates to find the range for
159
+ * @returns DateRange object with startDate (smallest) and endDate (biggest)
160
+ * @throws Error if the array is empty or contains invalid dates
161
+ */
162
+ declare const getDateSeriesRange: (dateSeries: DateSeries<DateLike>) => DateRange;
163
+
155
164
  declare const isOver18: (birthDate: DateLike) => boolean;
156
165
 
166
+ /**
167
+ * Note: This function does not use defaults, use startOfToday instead.
168
+ *
169
+ * @param day - The date to get the start of the day for.
170
+ * @returns A new Date object set to the start of the day.
171
+ */
157
172
  declare const startOfDay: (day: Date) => Date;
158
173
 
159
174
  declare const startOfNextMonth: () => Date;
@@ -168,6 +183,14 @@ declare const startOfTomorrow: () => Date;
168
183
 
169
184
  declare const startOfUTCDay: (date: Date) => Date;
170
185
 
186
+ /**
187
+ * Returns the start of tomorrow (00:00:00.000) in UTC time.
188
+ *
189
+ * @param date - The date to calculate tomorrow from. Defaults to current date if not provided.
190
+ * @returns A new Date object set to the start of tomorrow in UTC time.
191
+ */
192
+ declare const startOfUTCTomorrow: () => Date;
193
+
171
194
  declare const formatCamelCase: (str: string) => string;
172
195
 
173
196
  /**
@@ -848,4 +871,4 @@ declare const isUUID: (arg: string) => boolean;
848
871
 
849
872
  declare const isValue: <T>(arg?: Maybe<T>) => arg is T;
850
873
 
851
- export { BoolMap, Coords, DateLike, DateRange, Datey, Defined, Dimensions, HashMap, ISODate, ISODay, ISOMonth, ISOYear, JS_MAX_DIGITS, Key, Matrix, Maybe, MaybePromise, MaybePromiseOrValue, MaybePromiseOrValueArray, NonUndefined, NumberMap, ObjectEntries, ObjectEntry, ObjectKey, ObjectKeys, ObjectValue, ObjectValues, PickDefined, PickRequired, PlainKey, PlainObject, Point, PrismaSelect, Serialized, StringMap, Timezone, TrueMap, VoidFn, array, arrayDiff, arrayIntersection, average, capitalize, chunkArray, chunkedAll, chunkedAsync, chunkedDynamic, clamp, cleanSpaces, cyclicalItem, dir, enumKeys, enumValues, filterAlphanumeric, first, firstKey, firstValue, formatCamelCase, formatCookies, formatIndexProgress, formatNumber, formatPercentage, formatProgress, formatTrpcInputQueryString, getCookieByName, getDateRangeSeries, getDateSeries, getKeys, getUrlSearchParam, getUrlSearchParams, groupByKey, incrementalId, isArray, isArrayIncluded, isBetween, isBigInt, isBigIntString, 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, isOutsideInt4, isOver18, isPWA, isPastDate, isPositive, isPositiveInt, isPromise, isReactElement, isRegExp, isSame, isSequence, isServer, isSpacedString, isStrictlyBetween, isString, isStringDate, isURL, isUUID, isValue, keysLength, last, lastIndex, mapByKey, max, merge, mergeArrays, min, moveToFirst, moveToLast, multiply, noop, normaliseArray, normaliseNumber, normalizeNumber, objectDiff, omit, parseDate, percentageChange, pickObjectKeys, pickObjectValues, pluck, prismaDateRange, promiseWithTimeout, randomAddress, randomAlphaNumericCode, randomArray, randomArrayItem, randomBankAccount, randomBigInt, randomBool, randomChar, randomCompany, randomCoords, randomDate, randomDateRange, randomEmail, randomEmoji, randomEmptyValue, 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, randomObject, randomParagraph, randomPassword, randomPastDate, randomPath, randomPhoneNumber, randomPositiveInt, randomString, randomSymbol, randomUUID, randomValue, randomVerb, randomWord, removeUndefinedValues, scrambleText, serialize, seriesAsync, setObjectPath, setUrlSearchParams, shuffle, sleep, startOfDay, startOfNextMonth, startOfNextWeek, startOfThisWeek, startOfToday, startOfTomorrow, startOfUTCDay, stringToCSSUnicode, stringToUnicode, stringify, sum, toggleArray, toggleArrayValue, truncate, uniqueValues };
874
+ export { BoolMap, Coords, DateLike, DateRange, DateSeries, Datey, Defined, Dimensions, HashMap, ISODate, ISODay, ISOMonth, ISOYear, JS_MAX_DIGITS, Key, Matrix, Maybe, MaybePromise, MaybePromiseOrValue, MaybePromiseOrValueArray, NonUndefined, NumberMap, ObjectEntries, ObjectEntry, ObjectKey, ObjectKeys, ObjectValue, ObjectValues, PickDefined, PickRequired, PlainKey, PlainObject, Point, PrismaSelect, Serialized, StringMap, Timezone, TrueMap, VoidFn, array, arrayDiff, arrayIntersection, average, capitalize, chunkArray, chunkedAll, chunkedAsync, chunkedDynamic, clamp, cleanSpaces, cyclicalItem, dir, enumKeys, enumValues, filterAlphanumeric, first, firstKey, firstValue, formatCamelCase, formatCookies, formatIndexProgress, formatNumber, formatPercentage, formatProgress, formatTrpcInputQueryString, getCookieByName, getDateRangeSeries, getDateSeries, getDateSeriesRange, getKeys, getUrlSearchParam, getUrlSearchParams, groupByKey, incrementalId, isArray, isArrayIncluded, isBetween, isBigInt, isBigIntString, 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, isOutsideInt4, isOver18, isPWA, isPastDate, isPositive, isPositiveInt, isPromise, isReactElement, isRegExp, isSame, isSequence, isServer, isSpacedString, isStrictlyBetween, isString, isStringDate, isURL, isUUID, isValue, keysLength, last, lastIndex, mapByKey, max, merge, mergeArrays, min, moveToFirst, moveToLast, multiply, noop, normaliseArray, normaliseNumber, normalizeNumber, objectDiff, omit, parseDate, percentageChange, pickObjectKeys, pickObjectValues, pluck, prismaDateRange, promiseWithTimeout, randomAddress, randomAlphaNumericCode, randomArray, randomArrayItem, randomBankAccount, randomBigInt, randomBool, randomChar, randomCompany, randomCoords, randomDate, randomDateRange, randomEmail, randomEmoji, randomEmptyValue, 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, randomObject, randomParagraph, randomPassword, randomPastDate, randomPath, randomPhoneNumber, randomPositiveInt, randomString, randomSymbol, randomUUID, randomValue, randomVerb, randomWord, removeUndefinedValues, scrambleText, serialize, seriesAsync, setObjectPath, setUrlSearchParams, shuffle, sleep, startOfDay, startOfNextMonth, startOfNextWeek, startOfThisWeek, startOfToday, startOfTomorrow, startOfUTCDay, startOfUTCTomorrow, stringToCSSUnicode, stringToUnicode, stringify, sum, toggleArray, toggleArrayValue, truncate, uniqueValues };