New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pcg

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pcg - npm Package Compare versions

Comparing version 0.1.0 to 1.0.0

dist/bitwise.d.ts

123

package.json
{
"name": "pcg",
"version": "0.1.0",
"description": "A functional implementation of the PCG family random number generators, written in JavaScript",
"main": "lib/index.js",
"repository": "https://github.com/kripod/pcg",
"author": "Kristóf Poduszló <kripod@protonmail.com>",
"version": "1.0.0",
"description": "A functional typescript implementation of the PCG family random number generators",
"sideEffects": false,
"main": "dist/index.js",
"files": [
"/dist/",
"!/dist/**/__tests__/*.js"
],
"repository": "https://github.com/philihp/pcg",
"contributors": [
"Kristóf Poduszló <kripod@protonmail.com>",
"Philihp Busby <philihp@gmail.com>"
],
"license": "MIT",
"scripts": {
"build": "babel src -d lib -s",
"lint": "eslint ./src",
"test": "nyc -r lcov -r text ava -T 30s"
"build": "tsc -p tsconfig.build.json",
"lint": "eslint --ext .ts src",
"prepare": "husky install && npm run build",
"test": "jest",
"test:coverage": "jest --coverage",
"test:watch": "jest --watch"
},
"dependencies": {
"long": "^3.2.0",
"ramda": "^0.23.0"
"long": "5.2.3",
"ramda": "0.29.0"
},
"devDependencies": {
"ava": "^0.17.0",
"babel-cli": "^6.18.0",
"babel-preset-latest": "^6.16.0",
"eslint": "^3.12.1",
"eslint-config-airbnb-base": "^11.0.0",
"eslint-plugin-import": "^2.2.0",
"nyc": "^10.0.0"
"@philihp/eslint-config": "6.0.2",
"@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"
},
"lint-staged": {
"src/**/*.ts": [
"eslint --ext .ts --fix"
]
},
"jest": {
"preset": "ts-jest",
"modulePathIgnorePatterns": [
"dist/"
]
},
"prettier": "@philihp/prettier-config",
"eslintConfig": {
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": [
"@typescript-eslint"
],
"extends": [
"@philihp",
"plugin:jest/all",
"plugin:@typescript-eslint/recommended"
],
"settings": {
"react": {
"version": "18.2.0"
},
"import/extensions": [
".js",
".ts"
],
"import/parsers": {
"@typescript-eslint/parser": [
".ts",
".js"
]
},
"import/resolver": {
"typescript": {},
"node": {
"extensions": [
".js",
".ts"
]
}
}
},
"rules": {
"import/extensions": [
"error",
"ignorePackages",
{
"js": "never",
"ts": "never"
}
],
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "_",
"varsIgnorePattern": "_",
"caughtErrorsIgnorePattern": "_"
}
],
"jest/max-expects": "off"
}
}
}

42

README.md

@@ -1,6 +0,8 @@

# pcg.js
# pcg
[![NPM](https://img.shields.io/npm/v/pcg.svg)](https://www.npmjs.com/package/pcg)
[![Travis CI](https://img.shields.io/travis/kripod/pcg.js/master.svg)](https://travis-ci.org/kripod/pcg.js)
[![Codecov](https://img.shields.io/codecov/c/github/kripod/pcg.js.svg)](https://codecov.io/gh/kripod/pcg.js)
[![Version](https://img.shields.io/npm/v/pcg.svg)](https://www.npmjs.com/package/pcg)
[![Tests](https://github.com/philihp/pcg/actions/workflows/tests.yml/badge.svg)](https://github.com/philihp/pcg/actions/workflows/tests.yml)
[![Coverage](https://coveralls.io/repos/github/philihp/pcg/badge.svg?branch=main)](https://coveralls.io/github/philihp/pcg?branch=main)
![Downloads](https://img.shields.io/npm/dt/pcg)
![License](https://img.shields.io/npm/l/pcg)

@@ -15,11 +17,11 @@ A functional implementation of the [PCG family random number generators](), written in JavaScript.

Firstly, create a random number engine:
First, seed a PCG state. A stream ID specifies _which_ unique periodic series of entropy to use. The state specifies _where_ in that series we start.
```js
import { createPcg32 } from 'pcg';
```
import { createPcg32 } from 'pcg'
const advancedOptions = {};
const initState = 42;
const initStreamId = 54;
const pcg = createPcg32(advancedOptions, initState, initStreamId);
const advancedOptions = {}
const initState = 42
const initStreamId = 54
const state0 = createPcg32(advancedOptions, initState, initStreamId)
```

@@ -30,10 +32,16 @@

```js
import { nextState, prevState, randomInt, randomList } from 'pcg';
import { nextState, prevState, randomInt, randomList } from 'fn-pcg'
const randomUint32 = randomInt(0, (2 ** 32) - 1);
let [value, nextPcg] = randomUint32(pcg);
const randomUint32 = randomInt(0, 2 ** 32 - 1)
const [value, nextState] = randomUint32(state0)
const listLength = 6;
const listItemRng = randomUint32;
[value, nextPcg] = randomList(listLength, listItemRng, pcg);
const listLength = 3
const listItemRng = randomUint32
const [[v1, state1], [v2, state2], [v3, state3]] = randomList(listLength, listItemRng, state0)
```
In this above example, `value === v1`, and `nextState === state1`
## Thanks
- [@kripod](https://github.com/kripod/), who wrote the original [`pcg.js`](https://github.com/kripod/pcg.js)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc