@wandzai/utils 1.0.70-slack-channels-enum-3 → 1.0.71-wandz-5005-abtest-analytics-1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wandzai/utils",
3
- "version": "1.0.70-slack-channels-enum-3",
3
+ "version": "1.0.71-wandz-5005-abtest-analytics-1",
4
4
  "description": "Common used utilities library",
5
5
  "main": "src/index",
6
6
  "scripts": {
package/src/common.d.ts CHANGED
@@ -11,7 +11,7 @@ export declare const upperCaseFirstCharOfEachWord: (str: string) => string;
11
11
  export declare const upperCaseFirstCharOfEachWordSplitBySpace: (str: string) => string;
12
12
  export declare const jsonToConsistentString: (jsonObj: any) => string;
13
13
  export declare const booleanStringToBoolean: (value: string) => value is "true";
14
- export declare const booleanStringToNumber: (value: string) => 0 | 1;
14
+ export declare const booleanStringToNumber: (value: string) => 1 | 0;
15
15
  export declare const normalizeSfResponseObjKeys: (obj: Record<string, any>) => {
16
16
  [k: string]: any;
17
17
  };
package/src/numeric.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export declare const getRandomIntInclusive: (minVal: number, maxVal: number) => number;
2
2
  export declare const getRandomFloatInclusive: (minVal: number, maxVal: number) => number;
3
+ export declare const fractionToPercentageNumber: (value: number, decimal?: number) => number;
package/src/numeric.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRandomFloatInclusive = exports.getRandomIntInclusive = void 0;
3
+ exports.fractionToPercentageNumber = exports.getRandomFloatInclusive = exports.getRandomIntInclusive = void 0;
4
4
  const getRandomIntInclusive = (minVal, maxVal) => {
5
5
  const min = Math.ceil(minVal);
6
6
  const max = Math.floor(maxVal);
@@ -11,4 +11,9 @@ const getRandomFloatInclusive = (minVal, maxVal) => {
11
11
  return Number((Math.random() * (minVal - maxVal + 1) + minVal).toFixed(2));
12
12
  };
13
13
  exports.getRandomFloatInclusive = getRandomFloatInclusive;
14
+ const fractionToPercentageNumber = (value, decimal = 0) => {
15
+ const formattedValue = (value * 100).toFixed(decimal);
16
+ return parseFloat(formattedValue);
17
+ };
18
+ exports.fractionToPercentageNumber = fractionToPercentageNumber;
14
19
  //# sourceMappingURL=numeric.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"numeric.js","sourceRoot":"","sources":["../../../../libs/utils/src/numeric.ts"],"names":[],"mappings":";;;AAAO,MAAM,qBAAqB,GAAG,CAAC,MAAc,EAAE,MAAc,EAAE,EAAE;IACtE,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;AAC3D,CAAC,CAAC;AAJW,QAAA,qBAAqB,yBAIhC;AAEK,MAAM,uBAAuB,GAAG,CAAC,MAAc,EAAE,MAAc,EAAE,EAAE;IACxE,OAAO,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7E,CAAC,CAAC;AAFW,QAAA,uBAAuB,2BAElC"}
1
+ {"version":3,"file":"numeric.js","sourceRoot":"","sources":["../../../../libs/utils/src/numeric.ts"],"names":[],"mappings":";;;AAAO,MAAM,qBAAqB,GAAG,CAAC,MAAc,EAAE,MAAc,EAAE,EAAE;IACtE,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CA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