@rh-support/utils 0.2.16 → 0.2.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,4 +22,5 @@ export * from './customElementUtils';
22
22
  export * from './userUtils';
23
23
  export * from './styleUtils';
24
24
  export * from './translation-helper';
25
+ export * from './outlier';
25
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC"}
package/lib/cjs/index.js CHANGED
@@ -34,3 +34,4 @@ __exportStar(require("./customElementUtils"), exports);
34
34
  __exportStar(require("./userUtils"), exports);
35
35
  __exportStar(require("./styleUtils"), exports);
36
36
  __exportStar(require("./translation-helper"), exports);
37
+ __exportStar(require("./outlier"), exports);
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Outlier Function
3
+ * Refer: https://www.cuemath.com/outlier-formula/
4
+ *
5
+ * An outlier function which takers array of number and find high outlier and low outlier
6
+ * 1. Taker array of number and sort then in ascending order.
7
+ * 2. Calculate first(q1) and third(q3) quartile.
8
+ * 3. Calculate inter-quartile(iqr) range (q3-q1).
9
+ * 4. Find the upper boundary value by formula q3 + iqr*1.5.
10
+ * 5. Find the lower boundary value by formula q1 - iqr*1.5
11
+ *
12
+ * @param {number[]} numbers
13
+ * @returns {number[]} upper and lower boundary value
14
+ */
15
+ export declare const outlier: (array: Array<number>) => Array<number>;
16
+ //# sourceMappingURL=outlier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outlier.d.ts","sourceRoot":"","sources":["../../src/outlier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,OAAO,UAAW,MAAM,MAAM,CAAC,KAAG,MAAM,MAAM,CAkC1D,CAAC"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ /**
3
+ * Outlier Function
4
+ * Refer: https://www.cuemath.com/outlier-formula/
5
+ *
6
+ * An outlier function which takers array of number and find high outlier and low outlier
7
+ * 1. Taker array of number and sort then in ascending order.
8
+ * 2. Calculate first(q1) and third(q3) quartile.
9
+ * 3. Calculate inter-quartile(iqr) range (q3-q1).
10
+ * 4. Find the upper boundary value by formula q3 + iqr*1.5.
11
+ * 5. Find the lower boundary value by formula q1 - iqr*1.5
12
+ *
13
+ * @param {number[]} numbers
14
+ * @returns {number[]} upper and lower boundary value
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.outlier = void 0;
18
+ var outlier = function (array) {
19
+ // Take array length
20
+ var arrayLength = array.length;
21
+ // Check if length is smaller than four then return array result as it is
22
+ if (arrayLength < 4) {
23
+ return array;
24
+ }
25
+ var q1, q3, iqr, upperBoundary, lowerBoundary;
26
+ // Make a copy of array plus sort it in ascending order
27
+ var sortedArray = array.slice().sort(function (a, b) { return a - b; });
28
+ // Find the quartiles range
29
+ // If median is odd adjust the index by minus one
30
+ if (((arrayLength - 1) / 4) % 1 === 0 || (arrayLength / 4) % 1 === 0) {
31
+ q1 = (1 / 2) * (sortedArray[Math.floor(arrayLength / 4) - 1] + sortedArray[Math.floor(arrayLength / 4)]);
32
+ q3 =
33
+ (1 / 2) *
34
+ (sortedArray[Math.ceil(arrayLength * (3 / 4)) - 1] + sortedArray[Math.ceil(arrayLength * (3 / 4))]);
35
+ }
36
+ else {
37
+ q1 = sortedArray[Math.floor(arrayLength / 4)];
38
+ q3 = sortedArray[Math.floor(arrayLength * (3 / 4))];
39
+ }
40
+ // Calculate inter-quartile range
41
+ iqr = q3 - q1;
42
+ // upper boundary
43
+ upperBoundary = q3 + iqr * 1.5;
44
+ // lower boundary
45
+ lowerBoundary = q1 - iqr * 1.5;
46
+ return [upperBoundary, lowerBoundary];
47
+ };
48
+ exports.outlier = outlier;
@@ -22,4 +22,5 @@ export * from './customElementUtils';
22
22
  export * from './userUtils';
23
23
  export * from './styleUtils';
24
24
  export * from './translation-helper';
25
+ export * from './outlier';
25
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC"}
package/lib/esm/index.js CHANGED
@@ -22,3 +22,4 @@ export * from './customElementUtils';
22
22
  export * from './userUtils';
23
23
  export * from './styleUtils';
24
24
  export * from './translation-helper';
25
+ export * from './outlier';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Outlier Function
3
+ * Refer: https://www.cuemath.com/outlier-formula/
4
+ *
5
+ * An outlier function which takers array of number and find high outlier and low outlier
6
+ * 1. Taker array of number and sort then in ascending order.
7
+ * 2. Calculate first(q1) and third(q3) quartile.
8
+ * 3. Calculate inter-quartile(iqr) range (q3-q1).
9
+ * 4. Find the upper boundary value by formula q3 + iqr*1.5.
10
+ * 5. Find the lower boundary value by formula q1 - iqr*1.5
11
+ *
12
+ * @param {number[]} numbers
13
+ * @returns {number[]} upper and lower boundary value
14
+ */
15
+ export declare const outlier: (array: Array<number>) => Array<number>;
16
+ //# sourceMappingURL=outlier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outlier.d.ts","sourceRoot":"","sources":["../../src/outlier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,OAAO,UAAW,MAAM,MAAM,CAAC,KAAG,MAAM,MAAM,CAkC1D,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Outlier Function
3
+ * Refer: https://www.cuemath.com/outlier-formula/
4
+ *
5
+ * An outlier function which takers array of number and find high outlier and low outlier
6
+ * 1. Taker array of number and sort then in ascending order.
7
+ * 2. Calculate first(q1) and third(q3) quartile.
8
+ * 3. Calculate inter-quartile(iqr) range (q3-q1).
9
+ * 4. Find the upper boundary value by formula q3 + iqr*1.5.
10
+ * 5. Find the lower boundary value by formula q1 - iqr*1.5
11
+ *
12
+ * @param {number[]} numbers
13
+ * @returns {number[]} upper and lower boundary value
14
+ */
15
+ export const outlier = (array) => {
16
+ // Take array length
17
+ const arrayLength = array.length;
18
+ // Check if length is smaller than four then return array result as it is
19
+ if (arrayLength < 4) {
20
+ return array;
21
+ }
22
+ let q1, q3, iqr, upperBoundary, lowerBoundary;
23
+ // Make a copy of array plus sort it in ascending order
24
+ const sortedArray = array.slice().sort((a, b) => a - b);
25
+ // Find the quartiles range
26
+ // If median is odd adjust the index by minus one
27
+ if (((arrayLength - 1) / 4) % 1 === 0 || (arrayLength / 4) % 1 === 0) {
28
+ q1 = (1 / 2) * (sortedArray[Math.floor(arrayLength / 4) - 1] + sortedArray[Math.floor(arrayLength / 4)]);
29
+ q3 =
30
+ (1 / 2) *
31
+ (sortedArray[Math.ceil(arrayLength * (3 / 4)) - 1] + sortedArray[Math.ceil(arrayLength * (3 / 4))]);
32
+ }
33
+ else {
34
+ q1 = sortedArray[Math.floor(arrayLength / 4)];
35
+ q3 = sortedArray[Math.floor(arrayLength * (3 / 4))];
36
+ }
37
+ // Calculate inter-quartile range
38
+ iqr = q3 - q1;
39
+ // upper boundary
40
+ upperBoundary = q3 + iqr * 1.5;
41
+ // lower boundary
42
+ lowerBoundary = q1 - iqr * 1.5;
43
+ return [upperBoundary, lowerBoundary];
44
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/utils",
3
- "version": "0.2.16",
3
+ "version": "0.2.17",
4
4
  "description": "> TODO: description",
5
5
  "author": "Vikas Rathee <vrathee@redhat.com>",
6
6
  "license": "ISC",
@@ -87,5 +87,5 @@
87
87
  "@types/react-dom": "^17.0.9",
88
88
  "moment-timezone": "^0.5.32"
89
89
  },
90
- "gitHead": "b2165709013e4bfb0d0279915ee378bf8defb414"
90
+ "gitHead": "2821a4eb373d262b83d3a512900eb68d1fa22d55"
91
91
  }