tscommons-core
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -19,2 +19,3 @@ export declare abstract class CommonsNumber { | ||
static prettyPercent(value: number, whole?: boolean): string; | ||
static sampleIndices(length: number, samples: number, blockSize: number, allowUnderflow?: boolean): number[]; | ||
} |
@@ -167,4 +167,26 @@ "use strict"; | ||
} | ||
static sampleIndices(length, samples, blockSize, allowUnderflow = false) { | ||
if (length === 0) | ||
return []; | ||
if (blockSize > length && !allowUnderflow) | ||
return []; | ||
if (samples < 1) | ||
throw new Error('Minimum of 2 samples required'); | ||
if (blockSize < 1) | ||
throw new Error('Minimum of block size 1 required'); | ||
let step = Math.floor(length / samples); | ||
if (step < blockSize) | ||
step = blockSize; | ||
const indices = []; | ||
let index = 0; | ||
while (true) { | ||
indices.push(index); | ||
index += step; | ||
if ((index + blockSize) > length) | ||
break; | ||
} | ||
return indices; | ||
} | ||
} | ||
exports.CommonsNumber = CommonsNumber; | ||
//# sourceMappingURL=commons-number.js.map |
@@ -339,3 +339,2 @@ "use strict"; | ||
// unknown | ||
console.log('Unknown value type encountered', typeof test); | ||
return false; | ||
@@ -597,3 +596,2 @@ } | ||
// unknown | ||
console.log('Unknown value type encountered', typeof value); | ||
return value; | ||
@@ -632,3 +630,2 @@ } | ||
// unknown | ||
console.log('Unknown value type encountered', typeof value); | ||
return value; | ||
@@ -635,0 +632,0 @@ } |
{ | ||
"name": "tscommons-core", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "", | ||
"scripts": { | ||
"preprepare": "cti ./src && tsc" | ||
"preprepare": "rm -rf ./dist; cti ./src && tsc" | ||
}, | ||
@@ -8,0 +8,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
147057
2048