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

@idigi/random

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@idigi/random - npm Package Compare versions

Comparing version 0.0.0 to 0.0.1

8

package.json
{
"name": "@idigi/random",
"version": "0.0.0",
"version": "0.0.1",
"description": "A drop-in replacement for the 'random' Meteor package",

@@ -31,6 +31,6 @@ "main": "src/index.js",

"@types/bunyan-format": "^0.2.3",
"@types/jest": "^26.0.13",
"@types/jest": "^26.0.22",
"@types/lodash": "^4.14.161",
"@types/loggly": "^1.1.30",
"@types/mocha": "^8.0.3",
"@types/mocha": "^8.2.2",
"@types/node": "^14.6.2",

@@ -61,4 +61,6 @@ "@types/node-loggly-bulk": "^2.2.0",

"publishConfig": {
"cache": "~/.npm",
"registry": "https://npm.pkg.github.com",
"access": "public"
}
}
import RandomGenerator from "./RandomGenerator";
declare const Random: RandomGenerator<DataView | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | null>;
declare const Random: RandomGenerator<import("./Random.Declares").RandomValues>;
export default Random;
import RandomGenerator from "./RandomGenerator";
declare const _default: RandomGenerator<DataView | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | null>;
declare const _default: RandomGenerator<import("./Random.Declares").RandomValues>;
export default _default;

@@ -14,2 +14,3 @@ import { AleaType, NodeCryptoype, RandomValues } from "./Random.Declares";

fraction(): number;
code(numberCount?: number): string;
hexString(digits: number): string;

@@ -16,0 +17,0 @@ private _randomString;

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

"use strict";var __importDefault=this&&this.__importDefault||function(mod){return mod&&mod.__esModule?mod:{default:mod}};Object.defineProperty(exports,"__esModule",{value:!0});const Alea_1=__importDefault(require("./Alea")),UNMISTAKABLE_CHARS="23456789ABCDEFGHJKLMNPQRSTWXYZabcdefghijkmnopqrstuvwxyz",BASE64_CHARS="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_";class RandomGenerator{constructor(options){(null==options?void 0:options.seeds)&&Array.isArray(null==options?void 0:options.seeds)&&(this.alea=Alea_1.default(...options.seeds)),this.getRandomValues=null==options?void 0:options.getRandomValues,this.nodeCrypto=null==options?void 0:options.nodeCrypto}fraction(){if(this.alea&&"function"==typeof this.alea)return this.alea();if(this.nodeCrypto){return 2.3283064365386963e-10*parseInt(this.hexString(8),16)}if(this.getRandomValues){const array=new Uint32Array(1);return this.getRandomValues(array),2.3283064365386963e-10*array[0]}throw new Error("No random generator available")}hexString(digits){if(this.nodeCrypto&&!this.alea){const numBytes=Math.ceil(digits/2);let bytes;try{bytes=this.nodeCrypto.randomBytes(numBytes)}catch(e){bytes=this.nodeCrypto.pseudoRandomBytes(numBytes)}return bytes.toString("hex").substring(0,digits)}const hexDigits=[];for(let i=0;i<digits;++i)hexDigits.push(this.choice("0123456789abcdef"));return hexDigits.join("")}_randomString(charsCount,alphabet){const digits=[];for(let i=0;i<charsCount;i++)digits[i]=this.choice(alphabet);return digits.join("")}id(charsCount=17){return this._randomString(charsCount,UNMISTAKABLE_CHARS)}secret(charsCount=43){return this._randomString(charsCount,BASE64_CHARS)}choice(arrayOrString){const index=Math.floor(this.fraction()*arrayOrString.length);return"string"==typeof arrayOrString?arrayOrString.substr(index,1):arrayOrString[index]}createWithSeeds(...seeds){if(0===seeds.length)throw new Error("No seeds were provided");return new RandomGenerator({seeds:seeds})}}exports.default=RandomGenerator;
"use strict";var __importDefault=this&&this.__importDefault||function(mod){return mod&&mod.__esModule?mod:{default:mod}};Object.defineProperty(exports,"__esModule",{value:!0});const Alea_1=__importDefault(require("./Alea")),UNMISTAKABLE_CHARS="23456789ABCDEFGHJKLMNPQRSTWXYZabcdefghijkmnopqrstuvwxyz",BASE64_CHARS="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_";class RandomGenerator{constructor(options){(null==options?void 0:options.seeds)&&Array.isArray(null==options?void 0:options.seeds)&&(this.alea=Alea_1.default(...options.seeds)),this.getRandomValues=null==options?void 0:options.getRandomValues,this.nodeCrypto=null==options?void 0:options.nodeCrypto}fraction(){if(this.alea&&"function"==typeof this.alea)return this.alea();if(this.nodeCrypto){return 2.3283064365386963e-10*parseInt(this.hexString(8),16)}if(this.getRandomValues){const array=new Uint32Array(1);return this.getRandomValues(array),2.3283064365386963e-10*array[0]}throw new Error("No random generator available")}code(numberCount=6){if(numberCount>12)throw new Error("No random generator available");return this.fraction().toString().split(".")[1].substr(0,numberCount)}hexString(digits){if(this.nodeCrypto&&!this.alea){const numBytes=Math.ceil(digits/2);let bytes;try{bytes=this.nodeCrypto.randomBytes(numBytes)}catch(e){bytes=this.nodeCrypto.pseudoRandomBytes(numBytes)}return bytes.toString("hex").substring(0,digits)}const hexDigits=[];for(let i=0;i<digits;++i)hexDigits.push(this.choice("0123456789abcdef"));return hexDigits.join("")}_randomString(charsCount,alphabet){const digits=[];for(let i=0;i<charsCount;i++)digits[i]=this.choice(alphabet);return digits.join("")}id(charsCount=17){return this._randomString(charsCount,UNMISTAKABLE_CHARS)}secret(charsCount=43){return this._randomString(charsCount,BASE64_CHARS)}choice(arrayOrString){const index=Math.floor(this.fraction()*arrayOrString.length);return"string"==typeof arrayOrString?arrayOrString.substr(index,1):arrayOrString[index]}createWithSeeds(...seeds){if(0===seeds.length)throw new Error("No seeds were provided");return new RandomGenerator({seeds:seeds})}}exports.default=RandomGenerator;
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