Gathering detailed insights and metrics for random-sum-float
Gathering detailed insights and metrics for random-sum-float
Gathering detailed insights and metrics for random-sum-float
Gathering detailed insights and metrics for random-sum-float
npm install random-sum-float
Typescript
Module System
Node Version
NPM Version
61.5
Supply Chain
48
Quality
75.4
Maintenance
100
Vulnerability
98.9
License
TypeScript (66.72%)
JavaScript (33.28%)
Total Downloads
4,435
Last Day
2
Last Week
3
Last Month
38
Last Year
625
2 Stars
388 Commits
2 Watchers
1 Branches
2 Contributors
Updated on Jan 04, 2022
Minified
Minified + Gzipped
Latest Version
1.0.29
Package Id
random-sum-float@1.0.29
Unpacked Size
18.62 kB
Size
4.50 kB
File Count
17
NPM Version
lerna/6.6.2/node@v20.8.0+x64 (win32)
Node Version
20.8.0
Published on
Nov 20, 2023
Cumulative downloads
Total Downloads
Last Day
0%
2
Compared to previous day
Last Week
-85.7%
3
Compared to previous week
Last Month
-44.1%
38
Compared to previous month
Last Year
-24.2%
625
Compared to previous year
1
create random float number array by size, sum, min, max
1npm install random-sum-float
1declare function randomSumFloat(size: number, sum?: number, min?: number, max?: number): number[]; 2declare namespace randomSumFloat { 3 var create: (size: number, sum?: number, min?: number, max?: number, noUnique?: boolean, limit?: number) => () => number[]; 4 var randomSumFloat: typeof randomSumFloat; 5 var default: typeof randomSumFloat; 6} 7export = randomSumFloat;
1import randomSumFloat from 'random-sum-float';
2
3let size = 3;
4let sum = 10;
5let min = 1;
6let max = 10;
7
8/**
9 * recommend way, otherwise will slow
10 */
11let fn = randomSumFloat.create(size, sum, min, max);
12let v: number[];
13
14v = fn();
15
16console.log(v, array_sum(v));
17// => [ 2.828736460774711, 5.763831427698853, 1.407432111526436 ] 10
18
19/**
20 * will slow if not same [size, sum, min, max]
21 */
22v = randomSumFloat(size, sum, min, max);
23// => [ 1.0521188269862214, 4.661026586341693, 4.286854586672085 ] 10
24
25console.log(v, array_sum(v));
26
27/**
28 * auto create sum
29 */
30v = randomSumFloat(size, null, min, max);
31// => [ 3.9067266610605182, 4.259092854483752, 3.834180484455729 ] 12
32
33console.log(v, array_sum(v));
34
35/**
36 * auto create sum v2
37 */
38v = randomSumFloat(size);
39// => [ 0.3641343986242387, 0.4843074708676399, 0.1515581305081214 ] 1
40
41console.log(v, array_sum(v));
42
43v = randomSumFloat(size, 0, -5, 10);
44// => [ 2.879740922080848, -0.4913386492777585, -2.3884022728030896 ] 0
45
46console.log(v, array_sum(v));
47
48v = randomSumFloat(size, -10, -5, 10);
49// => [ -4.429865487852505, -3.5847740400416157, -1.9853604721058797 ] -10
50
51console.log(v, array_sum(v));
52
53export function array_sum(na: number[])
54{
55 return na.reduce((a, b) => a + b)
56}
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
8 existing vulnerabilities detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
no SAST tool detected
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
project is not fuzzed
Details
Score
Last Scanned on 2025-06-09
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More