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

@plasmicapp/loader-splits

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@plasmicapp/loader-splits - npm Package Compare versions

Comparing version 1.0.49 to 1.0.51

44

./dist/index.js

@@ -135,2 +135,3 @@ "use strict";

splits.forEach((split) => {
var _a;
const key = getSplitKey(split);

@@ -145,10 +146,39 @@ const knownVal = getKnownValue == null ? void 0 : getKnownValue(key);

if (split.type === "experiment") {
let p = getRandomValue(split.id);
chosenSlice = split.slices[numSlices - 1];
for (let i = 0; i < numSlices; i++) {
if (p - split.slices[i].prob <= 0) {
chosenSlice = split.slices[i];
break;
if (opts.useSeedBucketing) {
const seed = opts.traits[PLASMIC_SEED];
const buckets = [];
const totalBuckets = (_a = opts.seedRange) != null ? _a : 1;
let avaiableBuckets = totalBuckets;
for (let i = 0; i < numSlices; i++) {
const slice = split.slices[i];
const numBuckets = Math.min(
Math.floor(slice.prob * totalBuckets),
avaiableBuckets
);
for (let j = 0; j < numBuckets; j++) {
buckets.push(slice.id);
}
avaiableBuckets -= numBuckets;
}
p -= split.slices[i].prob;
if (buckets.length > 0) {
const shuffleRand = getSeededRandomFunction(split.id);
for (let i = 0; i < buckets.length; i++) {
const j = Math.floor(shuffleRand() * (i + 1));
[buckets[i], buckets[j]] = [buckets[j], buckets[i]];
}
const sliceIdx = +(seed != null ? seed : "0") % buckets.length;
chosenSlice = split.slices.find((s) => s.id === buckets[sliceIdx]);
} else {
chosenSlice = split.slices[numSlices - 1];
}
} else {
let p = getRandomValue(split.id);
chosenSlice = split.slices[numSlices - 1];
for (let i = 0; i < numSlices; i++) {
if (p - split.slices[i].prob <= 0) {
chosenSlice = split.slices[i];
break;
}
p -= split.slices[i].prob;
}
}

@@ -155,0 +185,0 @@ } else if (split.type === "segment") {

@@ -14,2 +14,4 @@ import type { Split } from '@plasmicapp/loader-fetcher';

enableUnseededExperiments?: boolean;
useSeedBucketing?: boolean;
seedRange?: number;
}): Record<string, string>;

@@ -16,0 +18,0 @@

@@ -99,2 +99,3 @@ var __defProp = Object.defineProperty;

splits.forEach((split) => {
var _a;
const key = getSplitKey(split);

@@ -109,10 +110,39 @@ const knownVal = getKnownValue == null ? void 0 : getKnownValue(key);

if (split.type === "experiment") {
let p = getRandomValue(split.id);
chosenSlice = split.slices[numSlices - 1];
for (let i = 0; i < numSlices; i++) {
if (p - split.slices[i].prob <= 0) {
chosenSlice = split.slices[i];
break;
if (opts.useSeedBucketing) {
const seed = opts.traits[PLASMIC_SEED];
const buckets = [];
const totalBuckets = (_a = opts.seedRange) != null ? _a : 1;
let avaiableBuckets = totalBuckets;
for (let i = 0; i < numSlices; i++) {
const slice = split.slices[i];
const numBuckets = Math.min(
Math.floor(slice.prob * totalBuckets),
avaiableBuckets
);
for (let j = 0; j < numBuckets; j++) {
buckets.push(slice.id);
}
avaiableBuckets -= numBuckets;
}
p -= split.slices[i].prob;
if (buckets.length > 0) {
const shuffleRand = getSeededRandomFunction(split.id);
for (let i = 0; i < buckets.length; i++) {
const j = Math.floor(shuffleRand() * (i + 1));
[buckets[i], buckets[j]] = [buckets[j], buckets[i]];
}
const sliceIdx = +(seed != null ? seed : "0") % buckets.length;
chosenSlice = split.slices.find((s) => s.id === buckets[sliceIdx]);
} else {
chosenSlice = split.slices[numSlices - 1];
}
} else {
let p = getRandomValue(split.id);
chosenSlice = split.slices[numSlices - 1];
for (let i = 0; i < numSlices; i++) {
if (p - split.slices[i].prob <= 0) {
chosenSlice = split.slices[i];
break;
}
p -= split.slices[i].prob;
}
}

@@ -119,0 +149,0 @@ } else if (split.type === "segment") {

@@ -135,2 +135,3 @@ "use strict";

splits.forEach((split) => {
var _a;
const key = getSplitKey(split);

@@ -145,10 +146,39 @@ const knownVal = getKnownValue == null ? void 0 : getKnownValue(key);

if (split.type === "experiment") {
let p = getRandomValue(split.id);
chosenSlice = split.slices[numSlices - 1];
for (let i = 0; i < numSlices; i++) {
if (p - split.slices[i].prob <= 0) {
chosenSlice = split.slices[i];
break;
if (opts.useSeedBucketing) {
const seed = opts.traits[PLASMIC_SEED];
const buckets = [];
const totalBuckets = (_a = opts.seedRange) != null ? _a : 1;
let avaiableBuckets = totalBuckets;
for (let i = 0; i < numSlices; i++) {
const slice = split.slices[i];
const numBuckets = Math.min(
Math.floor(slice.prob * totalBuckets),
avaiableBuckets
);
for (let j = 0; j < numBuckets; j++) {
buckets.push(slice.id);
}
avaiableBuckets -= numBuckets;
}
p -= split.slices[i].prob;
if (buckets.length > 0) {
const shuffleRand = getSeededRandomFunction(split.id);
for (let i = 0; i < buckets.length; i++) {
const j = Math.floor(shuffleRand() * (i + 1));
[buckets[i], buckets[j]] = [buckets[j], buckets[i]];
}
const sliceIdx = +(seed != null ? seed : "0") % buckets.length;
chosenSlice = split.slices.find((s) => s.id === buckets[sliceIdx]);
} else {
chosenSlice = split.slices[numSlices - 1];
}
} else {
let p = getRandomValue(split.id);
chosenSlice = split.slices[numSlices - 1];
for (let i = 0; i < numSlices; i++) {
if (p - split.slices[i].prob <= 0) {
chosenSlice = split.slices[i];
break;
}
p -= split.slices[i].prob;
}
}

@@ -155,0 +185,0 @@ } else if (split.type === "segment") {

4

package.json
{
"version": "1.0.49",
"version": "1.0.51",
"license": "MIT",

@@ -51,3 +51,3 @@ "types": "./dist/index.d.ts",

},
"gitHead": "9216f61b95565cb9ff8639fa7f2d2640a320e731"
"gitHead": "9638cc7f1d2af2fbbf9966b4096449e9c82b375b"
}

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