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

tscommons-core

Package Overview
Dependencies
Maintainers
1
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tscommons-core - npm Package Compare versions

Comparing version 1.27.0 to 1.28.0

1

dist/helpers/commons-number.d.ts

@@ -26,2 +26,3 @@ export declare abstract class CommonsNumber {

static sampleIndices(length: number, samples: number, blockSize: number, allowUnderflow?: boolean): number[];
static roughFactor(items: number, factor: number): number[];
}

@@ -252,4 +252,51 @@ "use strict";

}
static roughFactor(items, factor) {
if (factor === 0)
throw new Error('Cannot factor into zero');
if (items < factor)
return [items];
const div = Math.round(items / factor);
const center = div * factor;
const results = [];
for (let i = div; i-- > 0;)
results.push(factor);
if (items === center)
return results;
let ttl = items; // just to protect against infinite loops
if (items < center) {
// subtract from the rightmost back
let index = results.length - 1;
while (ttl-- > 0) {
let sum = 0;
for (const r of results)
sum += r;
if (sum === items)
break;
results[index]--;
index--;
if (index < 0)
index = results.length - 1;
}
}
else {
// add from the leftmost forward
let index = 0;
while (ttl-- > 0) {
let sum = 0;
for (const r of results)
sum += r;
if (sum === items)
break;
results[index]++;
index++;
if (index === results.length)
index = 0;
}
}
if (ttl < 0)
throw new Error('TTL expired during attempt roughtFactor');
return results;
}
}
exports.CommonsNumber = CommonsNumber;
//# sourceMappingURL=commons-number.js.map

2

package.json
{
"name": "tscommons-core",
"version": "1.27.0",
"version": "1.28.0",
"description": "",

@@ -5,0 +5,0 @@ "scripts": {

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