@orderly.network/utils 0.0.2 → 0.0.3
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/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -3
- package/.turbo/turbo-build.log +0 -22
- package/CHANGELOG.md +0 -7
- package/__test__/decimal.test.ts +0 -8
- package/babel.config.js +0 -6
- package/src/dateTime.ts +0 -8
- package/src/decimal.ts +0 -51
- package/src/index.ts +0 -3
- package/tsconfig.json +0 -13
- package/tsup.config.ts +0 -12
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var d=Object.create;var i=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var b=(t,o)=>{for(var r in o)i(t,r,{get:o[r],enumerable:!0})},u=(t,o,r,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of f(o))!x.call(t,n)&&n!==r&&i(t,n,{get:()=>o[n],enumerable:!(e=g(o,n))||e.enumerable});return t};var c=(t,o,r)=>(r=t!=null?d(h(t)):{},u(o||!t||!t.__esModule?i(r,"default",{value:t,enumerable:!0}):r,t)),M=t=>u(i({},"__esModule",{value:!0}),t);var w={};b(w,{Decimal:()=>l,commify:()=>D,cutNumber:()=>S,dayjs:()=>m.default,getPrecisionByNumber:()=>N,numberToHumanStyle:()=>P,timeConvertString:()=>v,zero:()=>y});module.exports=M(w);var m=c(require("dayjs"));var s=c(require("decimal.js-light"));s.default.set({rounding:s.default.ROUND_DOWN});var l=s.default,S=(t,o)=>{},y=new s.default(0),D=t=>{var o=t.toString().split(".");let r=o[0],e=o[1],n=/\B(?=(\d{3})+(?!\d))/g;return r.replace(n,",")+(e?"."+e:"")},N=t=>{let o=t.toString().split(".");return o[1]?o[1].length:0};function P(t){let o=["","thousand","million","billion","trillion","quadrillion"],r=",";if(t<1e3)return t.toString();let e=Math.sign(t),n=Math.abs(t),a=Math.floor(Math.log10(n)/3),p=(Math.round(n/Math.pow(1e3,a)*10)/10).toLocaleString();return(e<0?"-":"")+p+" "+o[a]}var v=t=>{t/=1e3;let o=Math.floor(t/3600),r=Math.floor(t/60%60),e=Math.floor(t%60);return[o,r,e]};0&&(module.exports={Decimal,commify,cutNumber,dayjs,getPrecisionByNumber,numberToHumanStyle,timeConvertString,zero});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/decimal.ts","../src/dateTime.ts"],"sourcesContent":["export {default as Decimal} from
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/decimal.ts","../src/dateTime.ts"],"sourcesContent":["export { default as dayjs } from \"dayjs\";\n\nexport { default as Decimal } from \"./decimal\";\nexport * from \"./decimal\";\nexport * from \"./dateTime\";\n","import Decimal from \"decimal.js-light\";\n\nDecimal.set({\n rounding: Decimal.ROUND_DOWN,\n});\n\nexport default Decimal;\n\nexport const cutNumber = (num: number | string, lenght: number) => {};\n\nexport const zero = new Decimal(0);\n\nexport const commify = (num: number | string): string => {\n var parts = num.toString().split(\".\");\n const numberPart = parts[0];\n const decimalPart = parts[1];\n const thousands = /\\B(?=(\\d{3})+(?!\\d))/g;\n return (\n numberPart.replace(thousands, \",\") + (decimalPart ? \".\" + decimalPart : \"\")\n );\n};\n\nexport const getPrecisionByNumber = (num: number | string): number => {\n // if(Math.floor(num) === num) return 0;\n const parts = num.toString().split(\".\");\n return parts[1] ? parts[1].length : 0;\n};\n\nexport function numberToHumanStyle(number: number): string {\n const units = [\n \"\",\n \"thousand\",\n \"million\",\n \"billion\",\n \"trillion\",\n \"quadrillion\",\n ];\n const delimiter = \",\";\n\n if (number < 1000) {\n return number.toString();\n }\n\n const sign = Math.sign(number);\n const num = Math.abs(number);\n const exp = Math.floor(Math.log10(num) / 3);\n const rounded = Math.round((num / Math.pow(1000, exp)) * 10) / 10;\n const formatted = rounded.toLocaleString();\n\n return (sign < 0 ? \"-\" : \"\") + formatted + \" \" + units[exp];\n}\n","export const timeConvertString = (time: number): number[] => {\n time /= 1000;\n const h = Math.floor(time / 3600);\n const m = Math.floor((time / 60) % 60);\n const s = Math.floor(time % 60);\n // return result = h + \"小时\" + m + \"分钟\" + s + \"秒\";\n return [h, m, s];\n};\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,YAAAC,EAAA,cAAAC,EAAA,6CAAAC,EAAA,uBAAAC,EAAA,sBAAAC,EAAA,SAAAC,IAAA,eAAAC,EAAAT,GAAA,IAAAU,EAAiC,oBCAjC,IAAAC,EAAoB,+BAEpB,EAAAC,QAAQ,IAAI,CACV,SAAU,EAAAA,QAAQ,UACpB,CAAC,EAED,IAAOC,EAAQ,EAAAD,QAEFE,EAAY,CAACC,EAAsBC,IAAmB,CAAC,EAEvDC,EAAO,IAAI,EAAAL,QAAQ,CAAC,EAEpBM,EAAWH,GAAiC,CACvD,IAAII,EAAQJ,EAAI,SAAS,EAAE,MAAM,GAAG,EACpC,IAAMK,EAAaD,EAAM,CAAC,EACpBE,EAAcF,EAAM,CAAC,EACrBG,EAAY,wBAClB,OACEF,EAAW,QAAQE,EAAW,GAAG,GAAKD,EAAc,IAAMA,EAAc,GAE5E,EAEaE,EAAwBR,GAAiC,CAEpE,IAAMI,EAAQJ,EAAI,SAAS,EAAE,MAAM,GAAG,EACtC,OAAOI,EAAM,CAAC,EAAIA,EAAM,CAAC,EAAE,OAAS,CACtC,EAEO,SAASK,EAAmBC,EAAwB,CACzD,IAAMC,EAAQ,CACZ,GACA,WACA,UACA,UACA,WACA,aACF,EACMC,EAAY,IAElB,GAAIF,EAAS,IACX,OAAOA,EAAO,SAAS,EAGzB,IAAMG,EAAO,KAAK,KAAKH,CAAM,EACvBV,EAAM,KAAK,IAAIU,CAAM,EACrBI,EAAM,KAAK,MAAM,KAAK,MAAMd,CAAG,EAAI,CAAC,EAEpCe,GADU,KAAK,MAAOf,EAAM,KAAK,IAAI,IAAMc,CAAG,EAAK,EAAE,EAAI,IACrC,eAAe,EAEzC,OAAQD,EAAO,EAAI,IAAM,IAAME,EAAY,IAAMJ,EAAMG,CAAG,CAC5D,CClDO,IAAME,EAAqBC,GAA2B,CAC3DA,GAAQ,IACR,IAAMC,EAAI,KAAK,MAAMD,EAAO,IAAI,EAC1BE,EAAI,KAAK,MAAOF,EAAO,GAAM,EAAE,EAC/BG,EAAI,KAAK,MAAMH,EAAO,EAAE,EAE9B,MAAO,CAACC,EAAGC,EAAGC,CAAC,CACjB","names":["src_exports","__export","decimal_default","commify","cutNumber","getPrecisionByNumber","numberToHumanStyle","timeConvertString","zero","__toCommonJS","import_dayjs","import_decimal","Decimal","decimal_default","cutNumber","num","lenght","zero","commify","parts","numberPart","decimalPart","thousands","getPrecisionByNumber","numberToHumanStyle","number","units","delimiter","sign","exp","formatted","timeConvertString","time","h","m","s"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import s from"decimal.js-light";s.set({rounding:s.ROUND_DOWN});var
|
|
1
|
+
import{default as y}from"dayjs";import s from"decimal.js-light";s.set({rounding:s.ROUND_DOWN});var u=s,m=(t,o)=>{},p=new s(0),d=t=>{var o=t.toString().split(".");let n=o[0],r=o[1],e=/\B(?=(\d{3})+(?!\d))/g;return n.replace(e,",")+(r?"."+r:"")},g=t=>{let o=t.toString().split(".");return o[1]?o[1].length:0};function f(t){let o=["","thousand","million","billion","trillion","quadrillion"],n=",";if(t<1e3)return t.toString();let r=Math.sign(t),e=Math.abs(t),i=Math.floor(Math.log10(e)/3),a=(Math.round(e/Math.pow(1e3,i)*10)/10).toLocaleString();return(r<0?"-":"")+a+" "+o[i]}var x=t=>{t/=1e3;let o=Math.floor(t/3600),n=Math.floor(t/60%60),r=Math.floor(t%60);return[o,n,r]};export{u as Decimal,d as commify,m as cutNumber,y as dayjs,g as getPrecisionByNumber,f as numberToHumanStyle,x as timeConvertString,p as zero};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/decimal.ts","../src/dateTime.ts"],"sourcesContent":["import Decimal from \"decimal.js-light\";\n\nDecimal.set({\n rounding: Decimal.ROUND_DOWN,\n});\n\nexport default Decimal;\n\nexport const cutNumber = (num: number | string, lenght: number) => {};\n\nexport const zero = new Decimal(0);\n\nexport const commify = (num: number | string): string => {\n var parts = num.toString().split(\".\");\n const numberPart = parts[0];\n const decimalPart = parts[1];\n const thousands = /\\B(?=(\\d{3})+(?!\\d))/g;\n return (\n numberPart.replace(thousands, \",\") + (decimalPart ? \".\" + decimalPart : \"\")\n );\n};\n\nexport const getPrecisionByNumber = (num: number | string): number => {\n // if(Math.floor(num) === num) return 0;\n const parts = num.toString().split(\".\");\n return parts[1] ? parts[1].length : 0;\n};\n\nexport function numberToHumanStyle(number: number): string {\n const units = [\n \"\",\n \"thousand\",\n \"million\",\n \"billion\",\n \"trillion\",\n \"quadrillion\",\n ];\n const delimiter = \",\";\n\n if (number < 1000) {\n return number.toString();\n }\n\n const sign = Math.sign(number);\n const num = Math.abs(number);\n const exp = Math.floor(Math.log10(num) / 3);\n const rounded = Math.round((num / Math.pow(1000, exp)) * 10) / 10;\n const formatted = rounded.toLocaleString();\n\n return (sign < 0 ? \"-\" : \"\") + formatted + \" \" + units[exp];\n}\n","export const timeConvertString = (time: number): number[] => {\n
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/decimal.ts","../src/dateTime.ts"],"sourcesContent":["export { default as dayjs } from \"dayjs\";\n\nexport { default as Decimal } from \"./decimal\";\nexport * from \"./decimal\";\nexport * from \"./dateTime\";\n","import Decimal from \"decimal.js-light\";\n\nDecimal.set({\n rounding: Decimal.ROUND_DOWN,\n});\n\nexport default Decimal;\n\nexport const cutNumber = (num: number | string, lenght: number) => {};\n\nexport const zero = new Decimal(0);\n\nexport const commify = (num: number | string): string => {\n var parts = num.toString().split(\".\");\n const numberPart = parts[0];\n const decimalPart = parts[1];\n const thousands = /\\B(?=(\\d{3})+(?!\\d))/g;\n return (\n numberPart.replace(thousands, \",\") + (decimalPart ? \".\" + decimalPart : \"\")\n );\n};\n\nexport const getPrecisionByNumber = (num: number | string): number => {\n // if(Math.floor(num) === num) return 0;\n const parts = num.toString().split(\".\");\n return parts[1] ? parts[1].length : 0;\n};\n\nexport function numberToHumanStyle(number: number): string {\n const units = [\n \"\",\n \"thousand\",\n \"million\",\n \"billion\",\n \"trillion\",\n \"quadrillion\",\n ];\n const delimiter = \",\";\n\n if (number < 1000) {\n return number.toString();\n }\n\n const sign = Math.sign(number);\n const num = Math.abs(number);\n const exp = Math.floor(Math.log10(num) / 3);\n const rounded = Math.round((num / Math.pow(1000, exp)) * 10) / 10;\n const formatted = rounded.toLocaleString();\n\n return (sign < 0 ? \"-\" : \"\") + formatted + \" \" + units[exp];\n}\n","export const timeConvertString = (time: number): number[] => {\n time /= 1000;\n const h = Math.floor(time / 3600);\n const m = Math.floor((time / 60) % 60);\n const s = Math.floor(time % 60);\n // return result = h + \"小时\" + m + \"分钟\" + s + \"秒\";\n return [h, m, s];\n};\n"],"mappings":"AAAA,OAAoB,WAAXA,MAAwB,QCAjC,OAAOC,MAAa,mBAEpBA,EAAQ,IAAI,CACV,SAAUA,EAAQ,UACpB,CAAC,EAED,IAAOC,EAAQD,EAEFE,EAAY,CAACC,EAAsBC,IAAmB,CAAC,EAEvDC,EAAO,IAAIL,EAAQ,CAAC,EAEpBM,EAAWH,GAAiC,CACvD,IAAII,EAAQJ,EAAI,SAAS,EAAE,MAAM,GAAG,EACpC,IAAMK,EAAaD,EAAM,CAAC,EACpBE,EAAcF,EAAM,CAAC,EACrBG,EAAY,wBAClB,OACEF,EAAW,QAAQE,EAAW,GAAG,GAAKD,EAAc,IAAMA,EAAc,GAE5E,EAEaE,EAAwBR,GAAiC,CAEpE,IAAMI,EAAQJ,EAAI,SAAS,EAAE,MAAM,GAAG,EACtC,OAAOI,EAAM,CAAC,EAAIA,EAAM,CAAC,EAAE,OAAS,CACtC,EAEO,SAASK,EAAmBC,EAAwB,CACzD,IAAMC,EAAQ,CACZ,GACA,WACA,UACA,UACA,WACA,aACF,EACMC,EAAY,IAElB,GAAIF,EAAS,IACX,OAAOA,EAAO,SAAS,EAGzB,IAAMG,EAAO,KAAK,KAAKH,CAAM,EACvBV,EAAM,KAAK,IAAIU,CAAM,EACrBI,EAAM,KAAK,MAAM,KAAK,MAAMd,CAAG,EAAI,CAAC,EAEpCe,GADU,KAAK,MAAOf,EAAM,KAAK,IAAI,IAAMc,CAAG,EAAK,EAAE,EAAI,IACrC,eAAe,EAEzC,OAAQD,EAAO,EAAI,IAAM,IAAME,EAAY,IAAMJ,EAAMG,CAAG,CAC5D,CClDO,IAAME,EAAqBC,GAA2B,CAC3DA,GAAQ,IACR,IAAMC,EAAI,KAAK,MAAMD,EAAO,IAAI,EAC1BE,EAAI,KAAK,MAAOF,EAAO,GAAM,EAAE,EAC/BG,EAAI,KAAK,MAAMH,EAAO,EAAE,EAE9B,MAAO,CAACC,EAAGC,EAAGC,CAAC,CACjB","names":["default","Decimal","decimal_default","cutNumber","num","lenght","zero","commify","parts","numberPart","decimalPart","thousands","getPrecisionByNumber","numberToHumanStyle","number","units","delimiter","sign","exp","formatted","timeConvertString","time","h","m","s"]}
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orderly.network/utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"keywords": [],
|
|
8
|
-
"
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
9
11
|
"license": "ISC",
|
|
10
12
|
"devDependencies": {
|
|
11
13
|
"@babel/core": "^7.22.9",
|
|
@@ -16,7 +18,7 @@
|
|
|
16
18
|
"jest": "^29.6.1",
|
|
17
19
|
"tsup": "^7.1.0",
|
|
18
20
|
"typescript": "^5.1.6",
|
|
19
|
-
"tsconfig": "0.0.
|
|
21
|
+
"tsconfig": "0.0.7"
|
|
20
22
|
},
|
|
21
23
|
"dependencies": {
|
|
22
24
|
"dayjs": "^1.11.9",
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @orderly.network/utils@0.0.1 build /Users/leo/orderly/orderly-web/packages/utils
|
|
3
|
-
> tsup
|
|
4
|
-
|
|
5
|
-
CLI Building entry: src/index.ts
|
|
6
|
-
CLI Using tsconfig: tsconfig.json
|
|
7
|
-
CLI tsup v7.1.0
|
|
8
|
-
CLI Using tsup config: /Users/leo/orderly/orderly-web/packages/utils/tsup.config.ts
|
|
9
|
-
CLI Target: es6
|
|
10
|
-
CLI Cleaning output folder
|
|
11
|
-
CJS Build start
|
|
12
|
-
ESM Build start
|
|
13
|
-
ESM dist/index.mjs 1.39 KB
|
|
14
|
-
ESM dist/index.mjs.map 2.67 KB
|
|
15
|
-
ESM ⚡️ Build success in 29ms
|
|
16
|
-
CJS dist/index.js 3.20 KB
|
|
17
|
-
CJS dist/index.js.map 2.89 KB
|
|
18
|
-
CJS ⚡️ Build success in 31ms
|
|
19
|
-
DTS Build start
|
|
20
|
-
DTS ⚡️ Build success in 792ms
|
|
21
|
-
DTS dist/index.d.ts 504.00 B
|
|
22
|
-
DTS dist/index.d.mts 504.00 B
|
package/CHANGELOG.md
DELETED
package/__test__/decimal.test.ts
DELETED
package/babel.config.js
DELETED
package/src/dateTime.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export const timeConvertString = (time: number): number[] => {
|
|
2
|
-
time /= 1000;
|
|
3
|
-
const h = Math.floor(time / 3600);
|
|
4
|
-
const m = Math.floor((time / 60) % 60);
|
|
5
|
-
const s = Math.floor(time % 60);
|
|
6
|
-
// return result = h + "小时" + m + "分钟" + s + "秒";
|
|
7
|
-
return [h, m, s];
|
|
8
|
-
};
|
package/src/decimal.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import Decimal from "decimal.js-light";
|
|
2
|
-
|
|
3
|
-
Decimal.set({
|
|
4
|
-
rounding: Decimal.ROUND_DOWN,
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
export default Decimal;
|
|
8
|
-
|
|
9
|
-
export const cutNumber = (num: number | string, lenght: number) => {};
|
|
10
|
-
|
|
11
|
-
export const zero = new Decimal(0);
|
|
12
|
-
|
|
13
|
-
export const commify = (num: number | string): string => {
|
|
14
|
-
var parts = num.toString().split(".");
|
|
15
|
-
const numberPart = parts[0];
|
|
16
|
-
const decimalPart = parts[1];
|
|
17
|
-
const thousands = /\B(?=(\d{3})+(?!\d))/g;
|
|
18
|
-
return (
|
|
19
|
-
numberPart.replace(thousands, ",") + (decimalPart ? "." + decimalPart : "")
|
|
20
|
-
);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const getPrecisionByNumber = (num: number | string): number => {
|
|
24
|
-
// if(Math.floor(num) === num) return 0;
|
|
25
|
-
const parts = num.toString().split(".");
|
|
26
|
-
return parts[1] ? parts[1].length : 0;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export function numberToHumanStyle(number: number): string {
|
|
30
|
-
const units = [
|
|
31
|
-
"",
|
|
32
|
-
"thousand",
|
|
33
|
-
"million",
|
|
34
|
-
"billion",
|
|
35
|
-
"trillion",
|
|
36
|
-
"quadrillion",
|
|
37
|
-
];
|
|
38
|
-
const delimiter = ",";
|
|
39
|
-
|
|
40
|
-
if (number < 1000) {
|
|
41
|
-
return number.toString();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const sign = Math.sign(number);
|
|
45
|
-
const num = Math.abs(number);
|
|
46
|
-
const exp = Math.floor(Math.log10(num) / 3);
|
|
47
|
-
const rounded = Math.round((num / Math.pow(1000, exp)) * 10) / 10;
|
|
48
|
-
const formatted = rounded.toLocaleString();
|
|
49
|
-
|
|
50
|
-
return (sign < 0 ? "-" : "") + formatted + " " + units[exp];
|
|
51
|
-
}
|
package/src/index.ts
DELETED
package/tsconfig.json
DELETED
package/tsup.config.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "tsup";
|
|
2
|
-
|
|
3
|
-
export default defineConfig((options) => ({
|
|
4
|
-
entry: ["src/index.ts"],
|
|
5
|
-
splitting: false,
|
|
6
|
-
minify: !options.watch,
|
|
7
|
-
format: ["cjs", "esm"],
|
|
8
|
-
target: "es6",
|
|
9
|
-
sourcemap: true,
|
|
10
|
-
clean: true,
|
|
11
|
-
dts: true,
|
|
12
|
-
}));
|