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

chance-generators

Package Overview
Dependencies
Maintainers
2
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chance-generators - npm Package Compare versions

Comparing version 2.12.0 to 2.13.0

45

lib/chance-generators.js

@@ -84,7 +84,12 @@ "use strict";

var that = this;
var chance = typeof seed === "undefined" ? new Chance() : new Chance(seed);
that.reset = function () {
that.chance = typeof seed === "undefined" ? new Chance() : new Chance(seed);
};
that.reset();
// Fix that pick provided a count of zero or one does not return an array
var originalPick = Chance.prototype.pick;
chance.pick = function (array, count) {
that.chance.pick = function (array, count) {
if (count === 0) {

@@ -95,9 +100,9 @@ return [];

if (count === 1) {
return [originalPick.call(chance, array, count)];
return [originalPick.call(that.chance, array, count)];
}
return originalPick.call(chance, array, count);
return originalPick.call(that.chance, array, count);
};
chance.shape = function (data) {
that.chance.shape = function (data) {
return unwrap(data);

@@ -162,3 +167,3 @@ };

var picksetGenerator = generatorFunction("pickset", [data, count], function () {
picksetGenerator.lastValue = chance.pickset(data, unwrap(count));
picksetGenerator.lastValue = that.chance.pickset(data, unwrap(count));
picksetGenerator.lastUnwrappedValue = unwrap(picksetGenerator.lastValue);

@@ -183,7 +188,7 @@ return picksetGenerator.lastUnwrappedValue;

var comparator = options && options.comparator;
return comparator ? chance.unique(function () {
return comparator ? that.chance.unique(function () {
return generator();
}, unwrap(count), {
comparator: comparator
}) : chance.unique(generator, unwrap(count));
}) : that.chance.unique(generator, unwrap(count));
});

@@ -201,3 +206,3 @@

var generator = generatorFunction("weighted", [data, weights], function () {
generator.lastValue = chance.weighted(data, weights);
generator.lastValue = that.chance.weighted(data, weights);
generator.lastUnwrappedValue = unwrap(generator.lastValue);

@@ -411,4 +416,4 @@ return generator.lastUnwrappedValue;

var margin = Math.max(Math.min(Math.floor((text.length - data.length) / 2), Math.ceil(data.length * 0.3)), 0);
var includeLeftMargin = chance.bool({ likelihood: 70 });
var includeRightMargin = chance.bool({ likelihood: 70 });
var includeLeftMargin = that.chance.bool({ likelihood: 70 });
var includeRightMargin = that.chance.bool({ likelihood: 70 });
var marginLength = (includeLeftMargin ? margin : 0) + (includeRightMargin ? margin : 0);

@@ -425,3 +430,3 @@ var result = new Array(marginLength + data.length);

for (var j = 0; j < data.length; i++, j++) {
result[i] = chance.bool({ likelihood: 95 }) ? data[j] : text[i % text.length];
result[i] = that.chance.bool({ likelihood: 95 }) ? data[j] : text[i % text.length];
}

@@ -449,3 +454,3 @@

for (var j = 0; j < data.length; i++, j++) {
result[i] = chance.bool({ likelihood: 95 }) ? data[j] : items[i % items.length];
result[i] = that.chance.bool({ likelihood: 95 }) ? data[j] : items[i % items.length];
}

@@ -518,3 +523,5 @@

if (options.length === 0) {
return chance[name].apply(chance, _toConsumableArray(args.map(function (arg, i) {
var _that$chance;
return (_that$chance = that.chance)[name].apply(_that$chance, _toConsumableArray(args.map(function (arg, i) {
return omitUnwrapIndex[i] ? arg : unwrap(arg);

@@ -555,3 +562,3 @@ })));

["shape"].concat(Object.keys(Chance.prototype)).forEach(function (key) {
var property = chance[key];
var property = that.chance[key];
if (typeof property === "function") {

@@ -587,4 +594,4 @@ if (overrides[key]) {

var g = generatorFunction("stringSplicer", [text, options], function () {
var from = chance.natural({ max: text.length });
var length = chance.natural({ max: text.length - min });
var from = that.chance.natural({ max: text.length });
var length = that.chance.natural({ max: text.length - min });

@@ -623,4 +630,4 @@ return text.slice(0, from) + text.slice(from + length);

var g = generatorFunction("arraySplicer", [array, options], function () {
var from = chance.natural({ max: array.length });
var length = chance.natural({ max: array.length - min });
var from = that.chance.natural({ max: array.length });
var length = that.chance.natural({ max: array.length - min });

@@ -627,0 +634,0 @@ g.lastValue = array.slice();

@@ -6,3 +6,3 @@ {

"license": "MIT",
"version": "2.12.0",
"version": "2.13.0",
"main": "lib/chance-generators.js",

@@ -9,0 +9,0 @@ "files": [

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