@xtia/alea-rc 0.0.8 → 0.0.9
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/internal/alea.js +3 -2
- package/internal/util.js +0 -1
- package/package.json +1 -1
package/internal/alea.js
CHANGED
|
@@ -77,9 +77,10 @@ export class Alea {
|
|
|
77
77
|
string(length, charset) {
|
|
78
78
|
if (!Number.isInteger(length) || length < 0)
|
|
79
79
|
throw new RangeError("length must be a non-negative integer");
|
|
80
|
-
|
|
80
|
+
const pool = [...charset];
|
|
81
|
+
if (pool.length === 0)
|
|
81
82
|
throw new RangeError("charset must not be empty");
|
|
82
|
-
const chars = Array.from({ length }, () =>
|
|
83
|
+
const chars = Array.from({ length }, () => this.sample(pool));
|
|
83
84
|
return chars.join("");
|
|
84
85
|
}
|
|
85
86
|
/**
|
package/internal/util.js
CHANGED