randomness
Version:
Randomness tests
41 lines • 2.08 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const approximate_entropy_test_1 = __importDefault(require("./tests/approximate-entropy-test"));
const binary_matrix_rank_test_1 = __importDefault(require("./tests/binary-matrix-rank-test"));
const cumulative_sums_test_1 = __importDefault(require("./tests/cumulative-sums-test"));
const dft_test_1 = __importDefault(require("./tests/dft-test"));
const frequency_within_block_test_1 = __importDefault(require("./tests/frequency-within-block-test"));
const longest_run_ones_in_a_block_test_1 = __importDefault(require("./tests/longest-run-ones-in-a-block-test"));
const monobit_test_1 = __importDefault(require("./tests/monobit-test"));
const runs_test_1 = __importDefault(require("./tests/runs-test"));
const isBitArray = (input) => Array.isArray(input);
const bufferToBits = (input) => {
const bits = [];
for (let i = 0; i < input.length; i++) {
bits.push(((input[i] >> 7) & 1));
bits.push(((input[i] >> 6) & 1));
bits.push(((input[i] >> 5) & 1));
bits.push(((input[i] >> 4) & 1));
bits.push(((input[i] >> 3) & 1));
bits.push(((input[i] >> 2) & 1));
bits.push(((input[i] >> 1) & 1));
bits.push((input[i] & 1));
}
return bits;
};
const wrap = (fn) => (input, alpha) => fn(isBitArray(input) ? input : bufferToBits(input), alpha);
const tests = {
approximateEntropyTest: wrap(approximate_entropy_test_1.default),
binaryMatrixRankTest: wrap(binary_matrix_rank_test_1.default),
cumulativeSumsTest: wrap(cumulative_sums_test_1.default),
dftTest: wrap(dft_test_1.default),
frequencyWithinBlockTest: wrap(frequency_within_block_test_1.default),
longestRunOnesInABlockTest: wrap(longest_run_ones_in_a_block_test_1.default),
monobitTest: wrap(monobit_test_1.default),
runsTest: wrap(runs_test_1.default),
};
exports.default = tests;
//# sourceMappingURL=index.js.map