Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cardcore/util

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cardcore/util - npm Package Compare versions

Comparing version 0.0.1-1f746c46 to 0.0.1-4a0572cd

dist/box.js

20

dist/index.js

@@ -54,2 +54,22 @@ "use strict";

});
var _box = require("./box");
Object.defineProperty(exports, "Box", {
enumerable: true,
get: function get() {
return _interopRequireDefault(_box).default;
}
});
var _hashState = require("./hash-state");
Object.defineProperty(exports, "hashState", {
enumerable: true,
get: function get() {
return _interopRequireDefault(_hashState).default;
}
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=index.js.map

15

dist/random-util.js

@@ -10,3 +10,3 @@ "use strict";

var _ssbKeys = require("ssb-keys");
var _ssbKeys = require("@streamplace/ssb-keys");

@@ -38,6 +38,5 @@ var _ssbKeys2 = _interopRequireDefault(_ssbKeys);

if (!seed) {
seed = _ssbKeys2.default.hash("" + Math.random());
if (seed) {
this.setSeed(seed);
}
this.setSeed(seed);
}

@@ -68,2 +67,5 @@

value: function next() {
if (!this.seed) {
throw new Error("tried to use RNG without providing a seed!");
}
return this.seed = this.seed * 16807 % 2147483647;

@@ -76,2 +78,7 @@ }

}
}, {
key: "clearSeed",
value: function clearSeed() {
this.seed = null;
}
}]);

@@ -78,0 +85,0 @@

@@ -6,4 +6,13 @@ "use strict";

});
exports.uid = exports.traverseSecret = exports.getRightPlayer = exports.getLeftPlayer = exports.rotateArray = undefined;
exports.range = range;
var _randomUtil = require("./random-util");
var _ssbKeys = require("@streamplace/ssb-keys");
var _ssbKeys2 = _interopRequireDefault(_ssbKeys);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }

@@ -41,2 +50,24 @@

/**
* Get the player to the left of this one
*/
var getLeftPlayer = exports.getLeftPlayer = function getLeftPlayer(playerId, players) {
var index = players.indexOf(playerId);
if (index === 0) {
return players[players.length - 1];
}
return players[index - 1];
};
/**
* Get the player to the right of this one
*/
var getRightPlayer = exports.getRightPlayer = function getRightPlayer(playerId, players) {
var index = players.indexOf(playerId);
if (index === players.length - 1) {
return players[0];
}
return players[index + 1];
};
var traverseSecret = exports.traverseSecret = function traverseSecret(secret, secrets) {

@@ -52,12 +83,5 @@ if (!secret || !secret.secret) {

/**
* id-generation function that assumes that all users will execute it in the _exact_ same order.
* this is.... hopefully reasonable.
*/
var cur = 0;
var uid = exports.uid = function uid() {
var res = "id-" + cur;
cur += 1;
return res;
return "id-" + _randomUtil.rando.next();
};
//# sourceMappingURL=util.js.map
{
"name": "@cardcore/util",
"version": "0.0.1-1f746c46",
"version": "0.0.1-4a0572cd",
"description": "various streamcards utilities",

@@ -13,3 +13,6 @@ "main": "dist/index.js",

},
"gitHead": "1f746c46c9911e36a1e9be89edf6da902e8ff20f"
"dependencies": {
"@streamplace/ssb-keys": "^7.0.16"
},
"gitHead": "4a0572cd286ae86d011a80c5b81ac8fcfe50072b"
}

@@ -5,1 +5,3 @@ export * from "./target-helper";

export * from "./constants";
export { default as Box } from "./box";
export { default as hashState } from "./hash-state";
// very simple PRNG from here https://gist.github.com/blixt/f17b47c62508be59987b
import ssbKeys from "ssb-keys";
import ssbKeys from "@streamplace/ssb-keys";

@@ -14,6 +14,5 @@ export function shuffle(arr, func = Math.random) {

constructor(seed) {
if (!seed) {
seed = ssbKeys.hash(`${Math.random()}`);
if (seed) {
this.setSeed(seed);
}
this.setSeed(seed);
}

@@ -40,2 +39,5 @@

next() {
if (!this.seed) {
throw new Error("tried to use RNG without providing a seed!");
}
return (this.seed = (this.seed * 16807) % 2147483647);

@@ -47,4 +49,8 @@ }

}
clearSeed() {
this.seed = null;
}
}
export const rando = new RandomUtil();

@@ -0,1 +1,4 @@

import { rando } from "./random-util";
import ssbKeys from "@streamplace/ssb-keys";
/**

@@ -27,2 +30,24 @@ * Like Python's range. Get an array of numbers from 0 to n.

/**
* Get the player to the left of this one
*/
export const getLeftPlayer = (playerId, players) => {
const index = players.indexOf(playerId);
if (index === 0) {
return players[players.length - 1];
}
return players[index - 1];
};
/**
* Get the player to the right of this one
*/
export const getRightPlayer = (playerId, players) => {
const index = players.indexOf(playerId);
if (index === players.length - 1) {
return players[0];
}
return players[index + 1];
};
export const traverseSecret = (secret, secrets) => {

@@ -38,11 +63,4 @@ if (!secret || !secret.secret) {

/**
* id-generation function that assumes that all users will execute it in the _exact_ same order.
* this is.... hopefully reasonable.
*/
let cur = 0;
export const uid = () => {
let res = `id-${cur}`;
cur += 1;
return res;
return `id-${rando.next()}`;
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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