@awesomeness-js/utils 1.0.18 → 1.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/build.js +7 -0
- package/index.js +47 -0
- package/package.json +13 -10
- package/schemas/schema1.js +121 -0
- package/schemas/schema2.js +121 -0
- package/schemas.js +15 -0
- package/secrets/dev.env +2 -1
- package/secrets/local.env +2 -1
- package/src/clean/array.js +43 -0
- package/src/clean/boolean.js +22 -0
- package/src/clean/integer.js +55 -0
- package/src/clean/number.js +75 -0
- package/src/clean/object.js +67 -0
- package/src/clean/string.js +58 -0
- package/src/clean/thing.js +31 -0
- package/src/clean/timestamp.js +56 -0
- package/src/clean/uuid.js +33 -0
- package/src/combineFiles.js +10 -1
- package/src/decrypt.js +19 -0
- package/src/each.js +10 -0
- package/src/encrypt.js +29 -0
- package/src/password/check.js +9 -0
- package/src/password/hash.js +11 -0
- package/src/setLocalEnvs.js +9 -4
- package/src/thingType.js +33 -0
- package/src/validateSchema.js +78 -0
- package/test/js/abc.test.js +6 -0
- package/test/secret.test.js +7 -1
- package/tests/combineFiles.test.js +24 -0
- package/tests/convertBytes.test.js +9 -0
- package/tests/env.test.js +17 -0
- package/tests/example.test.js +6 -0
- package/tests/fileList.test.js +21 -0
- package/tests/hash-and-encrypt.test.js +26 -0
- package/tests/md5.test.js +7 -0
- package/tests/uuid.test.js +15 -0
- package/tests/validateSchema.test.js +30 -0
- package/types/clean/array.d.ts +2 -0
- package/types/clean/boolean.d.ts +3 -0
- package/types/clean/integer.d.ts +5 -0
- package/types/clean/number.d.ts +7 -0
- package/types/clean/object.d.ts +2 -0
- package/types/clean/string.d.ts +7 -0
- package/types/clean/thing.d.ts +2 -0
- package/types/clean/timestamp.d.ts +5 -0
- package/types/clean/uuid.d.ts +3 -0
- package/types/decrypt.d.ts +1 -0
- package/types/each.d.ts +10 -1
- package/types/encrypt.d.ts +5 -0
- package/types/hashPassword.d.ts +1 -0
- package/types/index.d.ts +47 -0
- package/types/password/check.d.ts +1 -0
- package/types/password/hash.d.ts +1 -0
- package/types/thingType.d.ts +2 -0
- package/types/validatePassword.d.ts +1 -0
- package/types/validateSchema.d.ts +2 -0
- package/vitest.config.js +6 -0
- package/test.js +0 -42
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function decrypt(encryptedData: any, key?: any): any;
|
package/types/each.d.ts
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Iterates over elements of an array or properties of an object, invoking a callback for each element/property.
|
|
3
|
+
* The iteration stops if the callback returns `false`.
|
|
4
|
+
*
|
|
5
|
+
* @example each({ a: 1, b: 2 }, (value, key) => { console.log(value, key); });
|
|
6
|
+
* @param {Object|Array} objectOrArray - The object or array to iterate over.
|
|
7
|
+
* @param {Function} callback - The function to invoke per iteration. It is invoked with two arguments: (value, key/index).
|
|
8
|
+
* @returns {void}
|
|
9
|
+
*/
|
|
10
|
+
export default function each(objectOrArray: any | any[], callback: Function): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function hashPassword(password: any): string;
|
package/types/index.d.ts
CHANGED
|
@@ -4,16 +4,30 @@
|
|
|
4
4
|
* Do not edit manually.
|
|
5
5
|
*/
|
|
6
6
|
import type _build from './build';
|
|
7
|
+
import type _clean_array from './clean/array';
|
|
8
|
+
import type _clean_boolean from './clean/boolean';
|
|
9
|
+
import type _clean_integer from './clean/integer';
|
|
10
|
+
import type _clean_number from './clean/number';
|
|
11
|
+
import type _clean_object from './clean/object';
|
|
12
|
+
import type _clean_string from './clean/string';
|
|
13
|
+
import type _clean_thing from './clean/thing';
|
|
14
|
+
import type _clean_timestamp from './clean/timestamp';
|
|
15
|
+
import type _clean_uuid from './clean/uuid';
|
|
7
16
|
import type _combineFiles from './combineFiles';
|
|
8
17
|
import type _convertBytes from './convertBytes';
|
|
18
|
+
import type _decrypt from './decrypt';
|
|
9
19
|
import type _each from './each';
|
|
10
20
|
import type _eachAsync from './eachAsync';
|
|
21
|
+
import type _encrypt from './encrypt';
|
|
11
22
|
import type _getAllFiles from './getAllFiles';
|
|
12
23
|
import type _ignoreFolder_ignoreMe from './ignoreFolder/ignoreMe';
|
|
13
24
|
import type _ignoreMe from './ignoreMe';
|
|
14
25
|
import type _isUUID from './isUUID';
|
|
15
26
|
import type _md5 from './md5';
|
|
27
|
+
import type _password_check from './password/check';
|
|
28
|
+
import type _password_hash from './password/hash';
|
|
16
29
|
import type _setLocalEnvs from './setLocalEnvs';
|
|
30
|
+
import type _thingType from './thingType';
|
|
17
31
|
import type _toPennies from './toPennies';
|
|
18
32
|
import type _utils_buildExportsTree from './utils/buildExportsTree';
|
|
19
33
|
import type _utils_buildFileDataList from './utils/buildFileDataList';
|
|
@@ -26,19 +40,24 @@ import type _utils_generateNamespaceCode from './utils/generateNamespaceCode';
|
|
|
26
40
|
import type _utils_generateNamespaceExportLines from './utils/generateNamespaceExportLines';
|
|
27
41
|
import type _utils_shouldIgnore from './utils/shouldIgnore';
|
|
28
42
|
import type _uuid from './uuid';
|
|
43
|
+
import type _validateSchema from './validateSchema';
|
|
29
44
|
|
|
30
45
|
export declare const build: typeof _build;
|
|
31
46
|
export declare const combineFiles: typeof _combineFiles;
|
|
32
47
|
export declare const convertBytes: typeof _convertBytes;
|
|
48
|
+
export declare const decrypt: typeof _decrypt;
|
|
33
49
|
export declare const each: typeof _each;
|
|
34
50
|
export declare const eachAsync: typeof _eachAsync;
|
|
51
|
+
export declare const encrypt: typeof _encrypt;
|
|
35
52
|
export declare const getAllFiles: typeof _getAllFiles;
|
|
36
53
|
export declare const ignoreMe: typeof _ignoreMe;
|
|
37
54
|
export declare const isUUID: typeof _isUUID;
|
|
38
55
|
export declare const md5: typeof _md5;
|
|
39
56
|
export declare const setLocalEnvs: typeof _setLocalEnvs;
|
|
57
|
+
export declare const thingType: typeof _thingType;
|
|
40
58
|
export declare const toPennies: typeof _toPennies;
|
|
41
59
|
export declare const uuid: typeof _uuid;
|
|
60
|
+
export declare const validateSchema: typeof _validateSchema;
|
|
42
61
|
|
|
43
62
|
declare const _default: {
|
|
44
63
|
/**
|
|
@@ -63,18 +82,46 @@ declare const _default: {
|
|
|
63
82
|
* @returns {string} The converted bytes in a string format with appropriate units.
|
|
64
83
|
*/
|
|
65
84
|
convertBytes: typeof _convertBytes;
|
|
85
|
+
decrypt: typeof _decrypt;
|
|
86
|
+
/**
|
|
87
|
+
* Iterates over elements of an array or properties of an object, invoking a callback for each element/property.
|
|
88
|
+
* The iteration stops if the callback returns `false`.
|
|
89
|
+
*
|
|
90
|
+
* @example each({ a: 1, b: 2 }, (value, key) => { console.log(value, key); });
|
|
91
|
+
* @param {Object|Array} objectOrArray - The object or array to iterate over.
|
|
92
|
+
* @param {Function} callback - The function to invoke per iteration. It is invoked with two arguments: (value, key/index).
|
|
93
|
+
* @returns {void}
|
|
94
|
+
*/
|
|
66
95
|
each: typeof _each;
|
|
67
96
|
eachAsync: typeof _eachAsync;
|
|
97
|
+
encrypt: typeof _encrypt;
|
|
68
98
|
getAllFiles: typeof _getAllFiles;
|
|
69
99
|
ignoreMe: typeof _ignoreMe;
|
|
70
100
|
isUUID: typeof _isUUID;
|
|
71
101
|
md5: typeof _md5;
|
|
72
102
|
setLocalEnvs: typeof _setLocalEnvs;
|
|
103
|
+
thingType: typeof _thingType;
|
|
73
104
|
toPennies: typeof _toPennies;
|
|
74
105
|
uuid: typeof _uuid;
|
|
106
|
+
validateSchema: typeof _validateSchema;
|
|
107
|
+
clean: {
|
|
108
|
+
array: typeof _clean_array,
|
|
109
|
+
boolean: typeof _clean_boolean,
|
|
110
|
+
integer: typeof _clean_integer,
|
|
111
|
+
number: typeof _clean_number,
|
|
112
|
+
object: typeof _clean_object,
|
|
113
|
+
string: typeof _clean_string,
|
|
114
|
+
thing: typeof _clean_thing,
|
|
115
|
+
timestamp: typeof _clean_timestamp,
|
|
116
|
+
uuid: typeof _clean_uuid,
|
|
117
|
+
},
|
|
75
118
|
ignoreFolder: {
|
|
76
119
|
ignoreMe: typeof _ignoreFolder_ignoreMe,
|
|
77
120
|
},
|
|
121
|
+
password: {
|
|
122
|
+
check: typeof _password_check,
|
|
123
|
+
hash: typeof _password_hash,
|
|
124
|
+
},
|
|
78
125
|
utils: {
|
|
79
126
|
buildExportsTree: typeof _utils_buildExportsTree,
|
|
80
127
|
buildFileDataList: typeof _utils_buildFileDataList,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function validatePassword(password: any, storedHash: any): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function hashPassword(password: any): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function validatePassword(password: any, storedHash: any): boolean;
|
package/vitest.config.js
ADDED
package/test.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import utils from './index.js';
|
|
2
|
-
|
|
3
|
-
let fileList2 = utils.getAllFiles('./test', {
|
|
4
|
-
// fileTypes: ['.css'],
|
|
5
|
-
// fileTypes: ['.js'],
|
|
6
|
-
ignore: [
|
|
7
|
-
"/ignoreFolder",
|
|
8
|
-
"/ignoreFolder2/",
|
|
9
|
-
"*.env",
|
|
10
|
-
"*.test.js",
|
|
11
|
-
"/css/*.js",
|
|
12
|
-
"/js/*.css"
|
|
13
|
-
]
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
console.log({fileList2});
|
|
17
|
-
|
|
18
|
-
let md5Test = utils.md5('test');
|
|
19
|
-
console.log({md5Test});
|
|
20
|
-
|
|
21
|
-
let uuidTest = utils.uuid();
|
|
22
|
-
console.log({uuidTest});
|
|
23
|
-
|
|
24
|
-
let convertBytesTest = utils.convertBytes(1024);
|
|
25
|
-
console.log({convertBytesTest});
|
|
26
|
-
|
|
27
|
-
let isUUIDTest = utils.isUUID(uuidTest);
|
|
28
|
-
console.log({isUUIDTest});
|
|
29
|
-
|
|
30
|
-
let combineTest = utils.combineFiles('./src', 'js');
|
|
31
|
-
console.log('combineTest', combineTest.length);
|
|
32
|
-
|
|
33
|
-
let combineTestBrowser = utils.combineFiles('./src', 'js', {
|
|
34
|
-
moduleToBrowser: true
|
|
35
|
-
});
|
|
36
|
-
console.log('combineTestBrowser', combineTestBrowser.length);
|
|
37
|
-
|
|
38
|
-
await utils.setLocalEnvs('./secrets/local.env');
|
|
39
|
-
console.log('localEnv', process.env.JUST_A_TEST);
|
|
40
|
-
|
|
41
|
-
await utils.setLocalEnvs('./secrets/dev.env');
|
|
42
|
-
console.log('localEnv', process.env.JUST_A_TEST);
|