mentie 0.3.18 → 0.3.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/index.js CHANGED
@@ -7,4 +7,5 @@ export * from './modules/numbers.js'
7
7
  export * from './modules/promises.js'
8
8
  export * from './modules/cache.js'
9
9
  export * from './modules/crypto.js'
10
- export * from './modules/network.js'
10
+ export * from './modules/network.js'
11
+ export * from './modules/manipulations.js'
package/modules/cache.js CHANGED
@@ -5,7 +5,7 @@ import { log } from "./logging.js"
5
5
  * @type {Object}
6
6
  * @private
7
7
  */
8
- const _cache = {}
8
+ let _cache = {}
9
9
 
10
10
  /**
11
11
  * Caches the value with the specified key.
@@ -101,6 +101,17 @@ cache.dump = () => {
101
101
 
102
102
  }
103
103
 
104
+ /**
105
+ * Clears the cache entirely
106
+ */
107
+ cache.clear = ( { i_am_sure=false } ) => {
108
+ if( i_am_sure ) {
109
+ _cache = {}
110
+ } else {
111
+ log.warn( `cache.clear() called without i_am_sure=true, cache not cleared` )
112
+ }
113
+ }
114
+
104
115
  /**
105
116
  *
106
117
  * @returns {Object} stats - An object containing statistics about the cache.
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Shuffle an array using the Fisher-Yates algorithm.
3
+ * @param {Array} array
4
+ * @returns {Array} The shuffled array.
5
+ */
6
+ export const shuffle_array = array => {
7
+
8
+ // Validate input
9
+ if( Array.isArray( array ) === false ) throw new Error( 'Input must be an array' )
10
+
11
+ // Fisher-Yates shuffle
12
+ for( let i = array.length - 1; i > 0; i-- ) {
13
+ const j = Math.floor( Math.random() * ( i + 1 ) );
14
+ [ array[i], array[j] ] = [ array[j], array[i] ]
15
+ }
16
+
17
+ return array
18
+
19
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mentie",
3
- "version": "0.3.18",
3
+ "version": "0.3.20",
4
4
  "description": "Mentor's toolbelt",
5
5
  "type": "module",
6
6
  "main": "index.js",