@awesomeness-js/utils 1.1.23 → 1.2.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.
Files changed (67) hide show
  1. package/index.js +179 -147
  2. package/package.json +1 -1
  3. package/schemas/schema1.js +1 -8
  4. package/schemas/schema2.js +1 -8
  5. package/src/random/array.js +46 -0
  6. package/src/random/arrayValue.js +5 -0
  7. package/src/random/boolean.js +5 -0
  8. package/src/random/integer.js +8 -0
  9. package/src/random/number.js +17 -0
  10. package/src/random/object.js +46 -0
  11. package/src/random/string.js +10 -0
  12. package/src/random/timestamp.js +15 -0
  13. package/src/random/uuid.js +7 -0
  14. package/test/js/abc.test.js +1 -3
  15. package/tests/clean/array.test.js +1 -3
  16. package/tests/clean/boolean.test.js +1 -3
  17. package/tests/clean/integer.test.js +1 -3
  18. package/tests/clean/number.test.js +1 -3
  19. package/tests/clean/object.test.js +1 -3
  20. package/tests/clean/string.test.js +1 -3
  21. package/tests/clean/timestamp.test.js +1 -3
  22. package/tests/clean/uuid.test.js +1 -3
  23. package/tests/collectImports.test.js +1 -3
  24. package/tests/combineFiles.test.js +1 -3
  25. package/tests/convertBytes.test.js +1 -3
  26. package/tests/env.test.js +1 -3
  27. package/tests/example.test.js +1 -3
  28. package/tests/fileList.test.js +1 -3
  29. package/tests/hash-and-encrypt.test.js +1 -3
  30. package/tests/md5.test.js +1 -3
  31. package/tests/namedExports.test.js +1 -3
  32. package/tests/random.test.js +110 -0
  33. package/tests/uuid.test.js +1 -3
  34. package/tests/validateSchema.test.js +1 -3
  35. package/types/build.d.ts +10 -10
  36. package/types/clean/boolean.d.ts +3 -3
  37. package/types/clean/integer.d.ts +6 -6
  38. package/types/clean/number.d.ts +8 -8
  39. package/types/clean/timestamp.d.ts +5 -5
  40. package/types/clean/uuid.d.ts +3 -3
  41. package/types/collectImports.d.ts +6 -6
  42. package/types/combineFiles.d.ts +8 -8
  43. package/types/convertBytes.d.ts +8 -8
  44. package/types/decrypt.d.ts +1 -1
  45. package/types/each.d.ts +10 -10
  46. package/types/eachAsync.d.ts +1 -1
  47. package/types/encrypt.d.ts +5 -5
  48. package/types/getAllFiles.d.ts +6 -6
  49. package/types/isUUID.d.ts +1 -1
  50. package/types/md5.d.ts +2 -2
  51. package/types/password/check.d.ts +1 -1
  52. package/types/password/hash.d.ts +1 -1
  53. package/types/setLocalEnvs.d.ts +2 -2
  54. package/types/shouldIgnore.d.ts +1 -1
  55. package/types/thingType.d.ts +2 -2
  56. package/types/toPennies.d.ts +1 -1
  57. package/types/utils/buildExportsTree.d.ts +4 -4
  58. package/types/utils/buildFileDataList.d.ts +12 -12
  59. package/types/utils/extractJSDocComment.d.ts +1 -1
  60. package/types/utils/generateFile.d.ts +8 -8
  61. package/types/utils/generateFlatExportLines.d.ts +7 -7
  62. package/types/utils/generateImportStatements.d.ts +5 -5
  63. package/types/utils/generateNamedExports.d.ts +7 -7
  64. package/types/utils/generateNamespaceCode.d.ts +7 -7
  65. package/types/utils/generateNamespaceExportLines.d.ts +6 -6
  66. package/types/uuid.d.ts +2 -2
  67. package/types/validateSchema.d.ts +2 -2
package/index.js CHANGED
@@ -1,101 +1,122 @@
1
- /**
2
- * This file is auto-generated by the build script.
3
- * It consolidates API functions for use in the application.
4
- * Do not edit manually.
5
- */
6
- import _build from './src/build.js';
7
- import _clean_array from './src/clean/array.js';
8
- import _clean_boolean from './src/clean/boolean.js';
9
- import _clean_buffer from './src/clean/buffer.js';
10
- import _clean_custom from './src/clean/custom.js';
11
- import _clean_integer from './src/clean/integer.js';
12
- import _clean_number from './src/clean/number.js';
13
- import _clean_object from './src/clean/object.js';
14
- import _clean_string from './src/clean/string.js';
15
- import _clean_timestamp from './src/clean/timestamp.js';
16
- import _clean_uuid from './src/clean/uuid.js';
17
- import _collectImports from './src/collectImports.js';
18
- import _combineFiles from './src/combineFiles.js';
19
- import _convertBytes from './src/convertBytes.js';
20
- import _decrypt from './src/decrypt.js';
21
- import _each from './src/each.js';
22
- import _eachAsync from './src/eachAsync.js';
23
- import _encrypt from './src/encrypt.js';
24
- import _getAllFiles from './src/getAllFiles.js';
25
- import _isUUID from './src/isUUID.js';
26
- import _md5 from './src/md5.js';
27
- import _password_check from './src/password/check.js';
28
- import _password_hash from './src/password/hash.js';
29
- import _setLocalEnvs from './src/setLocalEnvs.js';
30
- import _shouldIgnore from './src/shouldIgnore.js';
31
- import _thingType from './src/thingType.js';
32
- import _toPennies from './src/toPennies.js';
33
- import _utils_buildExportsTree from './src/utils/buildExportsTree.js';
34
- import _utils_buildFileDataList from './src/utils/buildFileDataList.js';
35
- import _utils_clean from './src/utils/clean.js';
36
- import _utils_extractJSDocComment from './src/utils/extractJSDocComment.js';
37
- import _utils_generateFile from './src/utils/generateFile.js';
38
- import _utils_generateFlatExportLines from './src/utils/generateFlatExportLines.js';
39
- import _utils_generateImportStatements from './src/utils/generateImportStatements.js';
40
- import _utils_generateNamedExports from './src/utils/generateNamedExports.js';
41
- import _utils_generateNamespaceCode from './src/utils/generateNamespaceCode.js';
42
- import _utils_generateNamespaceExportLines from './src/utils/generateNamespaceExportLines.js';
43
- import _uuid from './src/uuid.js';
44
- import _validateSchema from './src/validateSchema.js';
45
- import _wait from './src/wait.js';
46
-
47
- export { _build as build };
48
- export { _collectImports as collectImports };
49
- export { _combineFiles as combineFiles };
50
- export { _convertBytes as convertBytes };
51
- export { _decrypt as decrypt };
52
- export { _each as each };
53
- export { _eachAsync as eachAsync };
54
- export { _encrypt as encrypt };
55
- export { _getAllFiles as getAllFiles };
56
- export { _isUUID as isUUID };
57
- export { _md5 as md5 };
58
- export { _setLocalEnvs as setLocalEnvs };
59
- export { _shouldIgnore as shouldIgnore };
60
- export { _thingType as thingType };
61
- export { _toPennies as toPennies };
62
- export { _uuid as uuid };
63
- export { _validateSchema as validateSchema };
64
- export { _wait as wait };
65
-
66
- export const clean = {
67
- array: _clean_array,
68
- boolean: _clean_boolean,
69
- buffer: _clean_buffer,
70
- custom: _clean_custom,
71
- integer: _clean_integer,
72
- number: _clean_number,
73
- object: _clean_object,
74
- string: _clean_string,
75
- timestamp: _clean_timestamp,
76
- uuid: _clean_uuid
77
- };
78
-
79
- export const password = {
80
- check: _password_check,
81
- hash: _password_hash
82
- };
83
-
84
- export const utils = {
85
- buildExportsTree: _utils_buildExportsTree,
86
- buildFileDataList: _utils_buildFileDataList,
87
- clean: _utils_clean,
88
- extractJSDocComment: _utils_extractJSDocComment,
89
- generateFile: _utils_generateFile,
90
- generateFlatExportLines: _utils_generateFlatExportLines,
91
- generateImportStatements: _utils_generateImportStatements,
92
- generateNamedExports: _utils_generateNamedExports,
93
- generateNamespaceCode: _utils_generateNamespaceCode,
94
- generateNamespaceExportLines: _utils_generateNamespaceExportLines
95
- };
96
-
97
-
98
- export default {
1
+ /**
2
+ * This file is auto-generated by the build script.
3
+ * It consolidates API functions for use in the application.
4
+ * Do not edit manually.
5
+ */
6
+ import _build from './src/build.js';
7
+ import _clean_array from './src/clean/array.js';
8
+ import _clean_boolean from './src/clean/boolean.js';
9
+ import _clean_buffer from './src/clean/buffer.js';
10
+ import _clean_custom from './src/clean/custom.js';
11
+ import _clean_integer from './src/clean/integer.js';
12
+ import _clean_number from './src/clean/number.js';
13
+ import _clean_object from './src/clean/object.js';
14
+ import _clean_string from './src/clean/string.js';
15
+ import _clean_timestamp from './src/clean/timestamp.js';
16
+ import _clean_uuid from './src/clean/uuid.js';
17
+ import _collectImports from './src/collectImports.js';
18
+ import _combineFiles from './src/combineFiles.js';
19
+ import _convertBytes from './src/convertBytes.js';
20
+ import _decrypt from './src/decrypt.js';
21
+ import _each from './src/each.js';
22
+ import _eachAsync from './src/eachAsync.js';
23
+ import _encrypt from './src/encrypt.js';
24
+ import _getAllFiles from './src/getAllFiles.js';
25
+ import _isUUID from './src/isUUID.js';
26
+ import _md5 from './src/md5.js';
27
+ import _password_check from './src/password/check.js';
28
+ import _password_hash from './src/password/hash.js';
29
+ import _random_array from './src/random/array.js';
30
+ import _random_arrayValue from './src/random/arrayValue.js';
31
+ import _random_boolean from './src/random/boolean.js';
32
+ import _random_integer from './src/random/integer.js';
33
+ import _random_number from './src/random/number.js';
34
+ import _random_object from './src/random/object.js';
35
+ import _random_string from './src/random/string.js';
36
+ import _random_timestamp from './src/random/timestamp.js';
37
+ import _random_uuid from './src/random/uuid.js';
38
+ import _setLocalEnvs from './src/setLocalEnvs.js';
39
+ import _shouldIgnore from './src/shouldIgnore.js';
40
+ import _thingType from './src/thingType.js';
41
+ import _toPennies from './src/toPennies.js';
42
+ import _utils_buildExportsTree from './src/utils/buildExportsTree.js';
43
+ import _utils_buildFileDataList from './src/utils/buildFileDataList.js';
44
+ import _utils_clean from './src/utils/clean.js';
45
+ import _utils_extractJSDocComment from './src/utils/extractJSDocComment.js';
46
+ import _utils_generateFile from './src/utils/generateFile.js';
47
+ import _utils_generateFlatExportLines from './src/utils/generateFlatExportLines.js';
48
+ import _utils_generateImportStatements from './src/utils/generateImportStatements.js';
49
+ import _utils_generateNamedExports from './src/utils/generateNamedExports.js';
50
+ import _utils_generateNamespaceCode from './src/utils/generateNamespaceCode.js';
51
+ import _utils_generateNamespaceExportLines from './src/utils/generateNamespaceExportLines.js';
52
+ import _uuid from './src/uuid.js';
53
+ import _validateSchema from './src/validateSchema.js';
54
+ import _wait from './src/wait.js';
55
+
56
+ export { _build as build };
57
+ export { _collectImports as collectImports };
58
+ export { _combineFiles as combineFiles };
59
+ export { _convertBytes as convertBytes };
60
+ export { _decrypt as decrypt };
61
+ export { _each as each };
62
+ export { _eachAsync as eachAsync };
63
+ export { _encrypt as encrypt };
64
+ export { _getAllFiles as getAllFiles };
65
+ export { _isUUID as isUUID };
66
+ export { _md5 as md5 };
67
+ export { _setLocalEnvs as setLocalEnvs };
68
+ export { _shouldIgnore as shouldIgnore };
69
+ export { _thingType as thingType };
70
+ export { _toPennies as toPennies };
71
+ export { _uuid as uuid };
72
+ export { _validateSchema as validateSchema };
73
+ export { _wait as wait };
74
+
75
+ export const clean = {
76
+ array: _clean_array,
77
+ boolean: _clean_boolean,
78
+ buffer: _clean_buffer,
79
+ custom: _clean_custom,
80
+ integer: _clean_integer,
81
+ number: _clean_number,
82
+ object: _clean_object,
83
+ string: _clean_string,
84
+ timestamp: _clean_timestamp,
85
+ uuid: _clean_uuid
86
+ };
87
+
88
+ export const password = {
89
+ check: _password_check,
90
+ hash: _password_hash
91
+ };
92
+
93
+ export const random = {
94
+ array: _random_array,
95
+ arrayValue: _random_arrayValue,
96
+ boolean: _random_boolean,
97
+ integer: _random_integer,
98
+ number: _random_number,
99
+ object: _random_object,
100
+ string: _random_string,
101
+ timestamp: _random_timestamp,
102
+ uuid: _random_uuid
103
+ };
104
+
105
+ export const utils = {
106
+ buildExportsTree: _utils_buildExportsTree,
107
+ buildFileDataList: _utils_buildFileDataList,
108
+ clean: _utils_clean,
109
+ extractJSDocComment: _utils_extractJSDocComment,
110
+ generateFile: _utils_generateFile,
111
+ generateFlatExportLines: _utils_generateFlatExportLines,
112
+ generateImportStatements: _utils_generateImportStatements,
113
+ generateNamedExports: _utils_generateNamedExports,
114
+ generateNamespaceCode: _utils_generateNamespaceCode,
115
+ generateNamespaceExportLines: _utils_generateNamespaceExportLines
116
+ };
117
+
118
+
119
+ export default {
99
120
  /**
100
121
  * Builds a file from the specified source directory and writes it to the destination file.
101
122
  *
@@ -107,19 +128,19 @@ export default {
107
128
  * @param {boolean} [options.includeComments=true] - Whether to include comments in the generated file.
108
129
  * @param {boolean} [options.dts=false] - Whether to generate TypeScript declaration files.
109
130
  * @returns {Promise<boolean>} A promise that resolves to true when the build is complete.
110
- */
111
- build: _build,
112
- collectImports: _collectImports,
113
- combineFiles: _combineFiles,
131
+ */
132
+ build: _build,
133
+ collectImports: _collectImports,
134
+ combineFiles: _combineFiles,
114
135
  /**
115
136
  * Converts a given number of bytes into a more readable string format with appropriate units.
116
137
  *
117
138
  * @param {number} bytes - The number of bytes to convert.
118
139
  * @param {number} [precision=2] - The number of decimal places to include in the result.
119
140
  * @returns {string} The converted bytes in a string format with appropriate units.
120
- */
121
- convertBytes: _convertBytes,
122
- decrypt: _decrypt,
141
+ */
142
+ convertBytes: _convertBytes,
143
+ decrypt: _decrypt,
123
144
  /**
124
145
  * Iterates over elements of an array or properties of an object, invoking a callback for each element/property.
125
146
  * The iteration stops if the callback returns `false`.
@@ -128,46 +149,57 @@ export default {
128
149
  * @param {Object|Array} objectOrArray - The object or array to iterate over.
129
150
  * @param {Function} callback - The function to invoke per iteration. It is invoked with two arguments: (value, key/index).
130
151
  * @returns {void}
131
- */
132
- each: _each,
133
- eachAsync: _eachAsync,
134
- encrypt: _encrypt,
135
- getAllFiles: _getAllFiles,
136
- isUUID: _isUUID,
137
- md5: _md5,
138
- setLocalEnvs: _setLocalEnvs,
139
- shouldIgnore: _shouldIgnore,
140
- thingType: _thingType,
141
- toPennies: _toPennies,
142
- uuid: _uuid,
143
- validateSchema: _validateSchema,
144
- wait: _wait,
145
- clean: {
146
- array: _clean_array,
147
- boolean: _clean_boolean,
148
- buffer: _clean_buffer,
149
- custom: _clean_custom,
150
- integer: _clean_integer,
151
- number: _clean_number,
152
- object: _clean_object,
153
- string: _clean_string,
154
- timestamp: _clean_timestamp,
155
- uuid: _clean_uuid,
156
- },
157
- password: {
158
- check: _password_check,
159
- hash: _password_hash,
160
- },
161
- utils: {
162
- buildExportsTree: _utils_buildExportsTree,
163
- buildFileDataList: _utils_buildFileDataList,
164
- clean: _utils_clean,
165
- extractJSDocComment: _utils_extractJSDocComment,
166
- generateFile: _utils_generateFile,
167
- generateFlatExportLines: _utils_generateFlatExportLines,
168
- generateImportStatements: _utils_generateImportStatements,
169
- generateNamedExports: _utils_generateNamedExports,
170
- generateNamespaceCode: _utils_generateNamespaceCode,
171
- generateNamespaceExportLines: _utils_generateNamespaceExportLines,
172
- },
152
+ */
153
+ each: _each,
154
+ eachAsync: _eachAsync,
155
+ encrypt: _encrypt,
156
+ getAllFiles: _getAllFiles,
157
+ isUUID: _isUUID,
158
+ md5: _md5,
159
+ setLocalEnvs: _setLocalEnvs,
160
+ shouldIgnore: _shouldIgnore,
161
+ thingType: _thingType,
162
+ toPennies: _toPennies,
163
+ uuid: _uuid,
164
+ validateSchema: _validateSchema,
165
+ wait: _wait,
166
+ clean: {
167
+ array: _clean_array,
168
+ boolean: _clean_boolean,
169
+ buffer: _clean_buffer,
170
+ custom: _clean_custom,
171
+ integer: _clean_integer,
172
+ number: _clean_number,
173
+ object: _clean_object,
174
+ string: _clean_string,
175
+ timestamp: _clean_timestamp,
176
+ uuid: _clean_uuid,
177
+ },
178
+ password: {
179
+ check: _password_check,
180
+ hash: _password_hash,
181
+ },
182
+ random: {
183
+ array: _random_array,
184
+ arrayValue: _random_arrayValue,
185
+ boolean: _random_boolean,
186
+ integer: _random_integer,
187
+ number: _random_number,
188
+ object: _random_object,
189
+ string: _random_string,
190
+ timestamp: _random_timestamp,
191
+ uuid: _random_uuid,
192
+ },
193
+ utils: {
194
+ buildExportsTree: _utils_buildExportsTree,
195
+ buildFileDataList: _utils_buildFileDataList,
196
+ clean: _utils_clean,
197
+ extractJSDocComment: _utils_extractJSDocComment,
198
+ generateFile: _utils_generateFile,
199
+ generateFlatExportLines: _utils_generateFlatExportLines,
200
+ generateImportStatements: _utils_generateImportStatements,
201
+ generateNamedExports: _utils_generateNamedExports,
202
+ generateNamespaceCode: _utils_generateNamespaceCode,
203
+ generateNamespaceExportLines: _utils_generateNamespaceExportLines,
204
+ },
173
205
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awesomeness-js/utils",
3
- "version": "1.1.23",
3
+ "version": "1.2.0",
4
4
  "description": "Awesomeness - Utils",
5
5
  "repository": {
6
6
  "type": "git",
@@ -65,15 +65,7 @@ const properties = {
65
65
  }
66
66
  }
67
67
  }
68
- },
69
-
70
- exampleRef: {
71
- type: 'array',
72
- items: {
73
- ref: 'someThing'
74
- }
75
68
  }
76
-
77
69
  };
78
70
 
79
71
  const edges = Object.freeze({
@@ -118,6 +110,7 @@ const relatedKVs = {
118
110
  export default {
119
111
  name: 'Blog Post',
120
112
  description: `a blog post`,
113
+ type: 'object',
121
114
  properties,
122
115
  edges,
123
116
  edgesIn,
@@ -65,15 +65,7 @@ const properties = {
65
65
  }
66
66
  }
67
67
  }
68
- },
69
-
70
- exampleRef: {
71
- type: 'array',
72
- items: {
73
- ref: 'someThing'
74
- }
75
68
  }
76
-
77
69
  };
78
70
 
79
71
  const edges = Object.freeze({
@@ -118,6 +110,7 @@ const relatedKVs = {
118
110
  export default {
119
111
  name: 'Blog Post',
120
112
  description: `a blog post`,
113
+ type: 'object',
121
114
  properties,
122
115
  edges,
123
116
  edgesIn,
@@ -0,0 +1,46 @@
1
+ import randomArrayValue from './arrayValue.js';
2
+ import randomBoolean from './boolean.js';
3
+ import randomInteger from './integer.js';
4
+ import randomNumber from './number.js';
5
+ import randomObject from './object.js';
6
+ import randomString from './string.js';
7
+ import randomTimestamp from './timestamp.js';
8
+ import randomUUID from './uuid.js';
9
+
10
+ function randomArray({
11
+ items = {
12
+ type: 'string',
13
+ minLength: 1,
14
+ maxLength: 10
15
+ },
16
+ min = 1,
17
+ max = 10
18
+ } = {}){
19
+
20
+ const randomTypes = {
21
+ array: randomArray,
22
+ arrayValue: randomArrayValue,
23
+ boolean: randomBoolean,
24
+ integer: randomInteger,
25
+ number: randomNumber,
26
+ object: randomObject,
27
+ string: randomString,
28
+ timestamp: randomTimestamp,
29
+ uuid: randomUUID
30
+ }
31
+
32
+ const array = [];
33
+
34
+ for(let i = 0; i < Math.floor(Math.random() * (max - min + 1)) + min; i++) {
35
+
36
+ const item = randomTypes[items.type](items);
37
+
38
+ array.push(item);
39
+
40
+ }
41
+
42
+ return array;
43
+
44
+ };
45
+
46
+ export default randomArray;
@@ -0,0 +1,5 @@
1
+ export default (array) => {
2
+
3
+ return array[Math.floor(Math.random() * array.length)];
4
+
5
+ };
@@ -0,0 +1,5 @@
1
+ export default () => {
2
+
3
+ return Math.random() < 0.5;
4
+
5
+ };
@@ -0,0 +1,8 @@
1
+ export default ({
2
+ min = 1,
3
+ max = 1_000_000,
4
+ } = {}) => {
5
+
6
+ return Math.floor(Math.random() * (max - min + 1)) + min;
7
+
8
+ };
@@ -0,0 +1,17 @@
1
+ export default ({
2
+ min = 1,
3
+ max = 1_000_000,
4
+ decimalPlaces = 0
5
+ } = {}) => {
6
+ const dp = Math.max(0, Math.floor(decimalPlaces));
7
+ const factor = 10 ** dp;
8
+
9
+ const lo = Math.min(min, max);
10
+ const hi = Math.max(min, max);
11
+
12
+ const loInt = Math.ceil(lo * factor);
13
+ const hiInt = Math.floor(hi * factor);
14
+
15
+ const rInt = Math.floor(Math.random() * (hiInt - loInt + 1)) + loInt;
16
+ return rInt / factor;
17
+ };
@@ -0,0 +1,46 @@
1
+ import randomArrayValue from './arrayValue.js';
2
+ import randomBoolean from './boolean.js';
3
+ import randomInteger from './integer.js';
4
+ import randomNumber from './number.js';
5
+ import randomArray from './array.js';
6
+ import randomString from './string.js';
7
+ import randomTimestamp from './timestamp.js';
8
+ import randomUUID from './uuid.js';
9
+ import each from '../each.js';
10
+
11
+ function randomObject({
12
+ properties = {},
13
+ } = {}) {
14
+
15
+ const result = {};
16
+
17
+ const randomTypes = {
18
+ array: randomArray,
19
+ arrayValue: randomArrayValue,
20
+ boolean: randomBoolean,
21
+ integer: randomInteger,
22
+ number: randomNumber,
23
+ object: randomObject,
24
+ string: randomString,
25
+ timestamp: randomTimestamp,
26
+ uuid: randomUUID
27
+ }
28
+
29
+ each(properties, (value, key) => {
30
+
31
+ if(typeof randomTypes[value.type] !== 'function') {
32
+
33
+ throw new Error(`Random function for type "${value.type}" is not defined.`);
34
+
35
+ }
36
+
37
+ result[key] = randomTypes[value.type](value);
38
+
39
+ });
40
+
41
+ return result;
42
+
43
+ };
44
+
45
+
46
+ export default randomObject;
@@ -0,0 +1,10 @@
1
+ export default ({
2
+ minLength = 5,
3
+ maxLength = 10,
4
+ } = {}) => {
5
+
6
+ const length = Math.floor(Math.random() * (maxLength - minLength + 1)) + minLength;
7
+
8
+ return Math.random().toString(36).substring(2, 2 + length);
9
+
10
+ };
@@ -0,0 +1,15 @@
1
+ export default ({
2
+ maxDays = 365,
3
+ minDays = 1,
4
+ future = false
5
+ } = {}) => {
6
+
7
+ const randomDays = Math.floor(Math.random() * (maxDays - minDays + 1)) + minDays;
8
+
9
+ const randomTimestamp = future
10
+ ? Date.now() + randomDays * 24 * 60 * 60 * 1000
11
+ : Date.now() - randomDays * 24 * 60 * 60 * 1000;
12
+
13
+ return new Date(randomTimestamp).toISOString();
14
+
15
+ };
@@ -0,0 +1,7 @@
1
+ import uuid from '../uuid.js'
2
+
3
+ export default () => {
4
+
5
+ return uuid();
6
+
7
+ };
@@ -1,7 +1,5 @@
1
1
  // example.test.js
2
- import {
3
- expect, test
4
- } from 'vitest';
2
+ import { expect, test } from 'vitest';
5
3
 
6
4
  test('adds 2 + 3 to equal 5', () => {
7
5
 
@@ -1,7 +1,5 @@
1
1
  // example.test.js
2
- import {
3
- expect, test
4
- } from 'vitest';
2
+ import { expect, test } from 'vitest';
5
3
  import utils from '../../index.js';
6
4
 
7
5
  const testStringArray = [ 'a', 'b', 'c' ];
@@ -1,7 +1,5 @@
1
1
  // example.test.js
2
- import {
3
- expect, test
4
- } from 'vitest';
2
+ import { expect, test } from 'vitest';
5
3
  import utils from '../../index.js';
6
4
 
7
5
  let x = true;
@@ -1,7 +1,5 @@
1
1
  // example.test.js
2
- import {
3
- expect, test
4
- } from 'vitest';
2
+ import { expect, test } from 'vitest';
5
3
  import utils from '../../index.js';
6
4
 
7
5
  let x = 1;
@@ -1,7 +1,5 @@
1
1
  // example.test.js
2
- import {
3
- expect, test
4
- } from 'vitest';
2
+ import { expect, test } from 'vitest';
5
3
  import utils from '../../index.js';
6
4
 
7
5
  let x = 1;
@@ -1,7 +1,5 @@
1
1
  // example.test.js
2
- import {
3
- expect, test
4
- } from 'vitest';
2
+ import { expect, test } from 'vitest';
5
3
  import utils from '../../index.js';
6
4
 
7
5
  const testObject = {
@@ -1,7 +1,5 @@
1
1
  // example.test.js
2
- import {
3
- expect, test
4
- } from 'vitest';
2
+ import { expect, test } from 'vitest';
5
3
  import utils from '../../index.js';
6
4
 
7
5
  test('good string', () => {
@@ -1,7 +1,5 @@
1
1
  // example.test.js
2
- import {
3
- expect, test
4
- } from 'vitest';
2
+ import { expect, test } from 'vitest';
5
3
  import utils from '../../index.js';
6
4
 
7
5
  test('good timestamp', () => {