Comparing version 1.0.0 to 1.0.1
@@ -6,4 +6,4 @@ import { PCGState } from './types'; | ||
export declare const randomInt: import("ts-toolbelt/out/Function/Curry").Curry<(min: number, max: number, pcg: PCGState) => [number, PCGState]>; | ||
export declare const randomList: import("ts-toolbelt/out/Function/Curry").Curry<(length: any, rng: any, pcg: any) => [number, PCGState][]>; | ||
export declare const randomList: import("ts-toolbelt/out/Function/Curry").Curry<(length: any, rng: any, initPcg: any) => [number, PCGState][]>; | ||
declare const _default: import("ts-toolbelt/out/Function/Curry").Curry<({ numOutputBits, multiplier, increment, outputFns }: any, { streamScheme, outputFnType }: any, initState: any, initStreamId: any) => PCGState>; | ||
export default _default; |
@@ -55,3 +55,3 @@ "use strict"; | ||
do { | ||
n = long_1.default.fromValue(nextPcg.getOutput(pcg.state)); | ||
n = long_1.default.fromValue(pcg.getOutput(nextPcg.state)); | ||
nextPcg = (0, exports.nextState)(nextPcg); | ||
@@ -61,3 +61,3 @@ } while (n.lt(threshold)); | ||
}); | ||
exports.randomList = (0, ramda_1.curry)((length, rng, pcg) => (0, ramda_1.scan)(([, nextPcg]) => rng(nextPcg), rng(pcg), new Array(length - 1))); | ||
exports.randomList = (0, ramda_1.curry)((length, rng, initPcg) => (0, ramda_1.scan)(([, lastPcg]) => rng(lastPcg), rng(initPcg), new Array(length - 1))); | ||
exports.default = (0, ramda_1.curry)(({ numOutputBits, multiplier, increment, outputFns }, { streamScheme = defaults_1.pcgDefaultStreamScheme, outputFnType = defaults_1.pcgDefaultOutputFnType }, initState, initStreamId) => { | ||
@@ -64,0 +64,0 @@ const streamId = long_1.default.fromValue(initStreamId).toUnsigned().shl(1).or(1); |
@@ -9,11 +9,11 @@ "use strict"; | ||
const types_1 = require("./types"); | ||
// export const pcgDefaultIncrement8 = 77; | ||
// export const pcgDefaultIncrement16 = 47989; | ||
// export const pcgDefaultIncrement32 = 2891336453; | ||
exports.pcgDefaultIncrement64 = long_1.default.fromString('1442695040888963407', true); | ||
// export const pcgDefaultMultiplier8 = 141; | ||
// export const pcgDefaultMultiplier16 = 12829; | ||
// export const pcgDefaultMultiplier32 = 747796405; | ||
exports.pcgDefaultMultiplier64 = long_1.default.fromString('6364136223846793005', true); | ||
// export const pcgDefaultIncrement8 = 77 | ||
// export const pcgDefaultIncrement16 = 47989 | ||
// export const pcgDefaultIncrement32 = Long.fromString('2891336453', 10) | ||
exports.pcgDefaultIncrement64 = long_1.default.fromString('1442695040888963407', 10); | ||
// export const pcgDefaultMultiplier8 = 141 | ||
// export const pcgDefaultMultiplier16 = 12829 | ||
// export const pcgDefaultMultiplier32 = Long.fromString('747796405') | ||
exports.pcgDefaultMultiplier64 = long_1.default.fromString('6364136223846793005', 10); | ||
exports.pcgDefaultOutputFnType = types_1.OutputFnType.XSH_RR; | ||
exports.pcgDefaultStreamScheme = types_1.StreamScheme.SETSEQ; |
export { stepState, nextState, prevState, randomInt, randomList } from './createPcg'; | ||
export declare const createPcg32: import("ts-toolbelt/out/Function/Curry").Curry<(p_0: any, p_1: any, p_2: any) => import("./types").PCGState>; | ||
export declare const createPcg32: import("ts-toolbelt/out/Function/Curry").Curry<(p_0: any, initState: any, initStreamId: any) => import("./types").PCGState>; |
@@ -23,3 +23,14 @@ "use strict"; | ||
[types_1.OutputFnType.XSH_RR]: (state) => (0, bitwise_1.ror32)(state.shru(59).toInt(), state.shru(18).xor(state).shru(27).toInt()), | ||
[types_1.OutputFnType.XSH_RS]: (state) => state.shru(22).xor(state).shru(state.shru(61).add(22)).toInt(), | ||
[types_1.OutputFnType.XSL_RR]: (state) => (0, bitwise_1.ror32)(state.shru(59).toInt(), state.shru(32).xor(state).toInt()), | ||
// [OutputFnType.XSL_RR_RR]: (state: Long): number => { | ||
// const high = state.shru(32) | ||
// const newlow = ror32(state.shru(59).toInt(), high.xor(state).toInt()) | ||
// return new Long(ror32(new Long(newlow).and(32).toInt(), high.toInt())).shl(32).or(newlow).toInt() | ||
// }, | ||
[types_1.OutputFnType.RXS_M_XS]: (state) => { | ||
const word = state.shru(13).add(3).xor(state).mul(62169); | ||
return word.shru(11).xor(word).toInt(); | ||
}, | ||
}, | ||
}); |
import Long from 'long'; | ||
export declare enum OutputFnType { | ||
XSH_RR = 0 | ||
XSH_RR = 0, | ||
XSH_RS = 1, | ||
XSL_RR = 2, | ||
RXS_M_XS = 4 | ||
} | ||
@@ -5,0 +8,0 @@ export type OutputFn = (state: Long) => number; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.StreamScheme = exports.OutputFnType = void 0; | ||
// TODO: Implement more output functions | ||
var OutputFnType; | ||
(function (OutputFnType) { | ||
OutputFnType[OutputFnType["XSH_RR"] = 0] = "XSH_RR"; | ||
// XSH_RS = 1 | ||
// XSL_RR = 2 | ||
// XSL_RR_RR = 3 | ||
// RXS_M_XS = 4 | ||
})(OutputFnType = exports.OutputFnType || (exports.OutputFnType = {})); | ||
OutputFnType[OutputFnType["XSH_RS"] = 1] = "XSH_RS"; | ||
OutputFnType[OutputFnType["XSL_RR"] = 2] = "XSL_RR"; | ||
// XSL_RR_RR = 3 // currently unstable | ||
OutputFnType[OutputFnType["RXS_M_XS"] = 4] = "RXS_M_XS"; | ||
})(OutputFnType || (exports.OutputFnType = OutputFnType = {})); | ||
// TODO: Implement more stream schemes | ||
@@ -20,2 +19,2 @@ var StreamScheme; | ||
StreamScheme[StreamScheme["MCG"] = 3] = "MCG"; | ||
})(StreamScheme = exports.StreamScheme || (exports.StreamScheme = {})); | ||
})(StreamScheme || (exports.StreamScheme = StreamScheme = {})); |
{ | ||
"name": "pcg", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A functional typescript implementation of the PCG family random number generators", | ||
@@ -27,21 +27,21 @@ "sideEffects": false, | ||
"long": "5.2.3", | ||
"ramda": "0.29.0" | ||
"ramda": "0.29.1" | ||
}, | ||
"devDependencies": { | ||
"@philihp/eslint-config": "6.0.2", | ||
"@philihp/eslint-config": "6.1.0", | ||
"@philihp/prettier-config": "1.0.0", | ||
"@tsconfig/node20": "1.0.0", | ||
"@types/jest": "29.5.1", | ||
"@types/ramda": "0.29.1", | ||
"@typescript-eslint/eslint-plugin": "5.59.2", | ||
"@typescript-eslint/parser": "5.59.2", | ||
"eslint": "8.40.0", | ||
"eslint-import-resolver-typescript": "3.5.5", | ||
"eslint-plugin-import": "2.27.5", | ||
"husky": "8.0.3", | ||
"jest": "29.5.0", | ||
"lint-staged": "13.2.2", | ||
"prettier": "2.8.8", | ||
"ts-jest": "29.1.0", | ||
"typescript": "5.0.4" | ||
"@tsconfig/node20": "20.1.4", | ||
"@types/jest": "29.5.12", | ||
"@types/ramda": "0.29.12", | ||
"@typescript-eslint/eslint-plugin": "6.21.0", | ||
"@typescript-eslint/parser": "6.21.0", | ||
"eslint": "8.57.0", | ||
"eslint-import-resolver-typescript": "3.6.1", | ||
"eslint-plugin-import": "2.29.1", | ||
"husky": "9.0.11", | ||
"jest": "29.7.0", | ||
"lint-staged": "15.2.2", | ||
"prettier": "3.2.5", | ||
"ts-jest": "29.1.2", | ||
"typescript": "5.4.4" | ||
}, | ||
@@ -48,0 +48,0 @@ "lint-staged": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
15934
207
0
+ Addedramda@0.29.1(transitive)
- Removedramda@0.29.0(transitive)
Updatedramda@0.29.1