mentie 0.1.4 → 0.1.5
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/index.js +2 -1
- package/modules/cache.js +20 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -4,4 +4,5 @@ export * from './modules/environment.js'
|
|
|
4
4
|
export * from './modules/validations.js'
|
|
5
5
|
export * from './modules/text.js'
|
|
6
6
|
export * from './modules/numbers.js'
|
|
7
|
-
export * from './modules/promises.js'
|
|
7
|
+
export * from './modules/promises.js'
|
|
8
|
+
export * from './modules/cache.js'
|
package/modules/cache.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache object for storing data.
|
|
3
|
+
* @type {Object}
|
|
4
|
+
* @private
|
|
5
|
+
*/
|
|
6
|
+
const _cache = {}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Caches the value with the specified key.
|
|
10
|
+
* If a value is provided, it sets the value in the cache.
|
|
11
|
+
* If no value is provided, it retrieves the value from the cache.
|
|
12
|
+
*
|
|
13
|
+
* @param {string} key - The key to cache the value.
|
|
14
|
+
* @param {*} [value] - The value to be cached (optional).
|
|
15
|
+
* @returns {*} The cached value.
|
|
16
|
+
*/
|
|
17
|
+
export function cache( key, value ) {
|
|
18
|
+
if( value ) _cache[key] = value
|
|
19
|
+
return _cache[key]
|
|
20
|
+
}
|