@visulima/humanizer 1.0.14 → 1.0.16
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/README.md
CHANGED
|
@@ -951,12 +951,12 @@ duration(5000, { language: ko });
|
|
|
951
951
|
|
|
952
952
|
### Bytes
|
|
953
953
|
|
|
954
|
-
-
|
|
954
|
+
- [pretty-bytes](https://github.com/sindresorhus/pretty-bytes) - Convert bytes to a human readable string: `1337` → `1.34 kB`
|
|
955
955
|
|
|
956
956
|
### Duration
|
|
957
957
|
|
|
958
|
-
-
|
|
959
|
-
-
|
|
958
|
+
- [HumanizeDuration](https://github.com/EvanHahn/HumanizeDuration.js) - 361000 becomes "6 minutes, 1 second"
|
|
959
|
+
- [pretty-ms](https://github.com/sindresorhus/pretty-ms) - Convert milliseconds to a human readable string: `1337000000` → `15d 11h 23m 20s`
|
|
960
960
|
|
|
961
961
|
## Supported Node.js Versions
|
|
962
962
|
|
|
@@ -971,8 +971,8 @@ If you would like to help take a look at the [list of issues](https://github.com
|
|
|
971
971
|
|
|
972
972
|
## Credits
|
|
973
973
|
|
|
974
|
-
-
|
|
975
|
-
-
|
|
974
|
+
- [Daniel Bannert](https://github.com/prisis)
|
|
975
|
+
- [All Contributors](https://github.com/visulima/visulima/graphs/contributors)
|
|
976
976
|
|
|
977
977
|
## License
|
|
978
978
|
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./packem_shared/parseBytes-BWae2sJX.cjs"),t=require("./packem_shared/duration-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./packem_shared/parseBytes-BWae2sJX.cjs"),t=require("./packem_shared/duration-CU5vEjtr.cjs");exports.formatBytes=e.formatBytes;exports.parseBytes=e.parseBytes;exports.duration=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var x=Object.defineProperty;var b=(r,t)=>x(r,"name",{value:t,configurable:!0});const M=require("../language/en.cjs"),P=require("../language/util/validate-duration-language.cjs");var _=Object.defineProperty,f=b((r,t)=>_(r,"name",{value:t,configurable:!0}),"g");const N=f((r,t)=>{t=t||-1;const e=new RegExp(`^-?\\d+(?:.\\d{0,${t}})?`).exec(r.toString());return e===null?r:Number.parseFloat(e[0])},"toFixed"),v=f(({unitCount:r,unitName:t},e,u)=>{let{spacer:g}=u;const{maxDecimalPoints:s}=u;let o=".";u.decimal!==void 0?o=u.decimal:e.decimal!==void 0&&(o=e.decimal);let n;"digitReplacements"in u?n=u.digitReplacements:"_digitReplacements"in e&&(n=e._digitReplacements);let i,m=r;s!==void 0&&(m=N(r,s));const c=m.toString();if(!e._hideCountIf2||r!==2)if(n){i="";for(const d of c)i+=d==="."?o:n[d]}else i=c.replace(".",o);else i="";const l=e[t];let a=l;return typeof l=="function"&&(a=l(r)),e._hideCountIf2&&r===2&&(g=""),e._numberFirst?a+g+i:i+g+a},"renderPiece"),w=f((r,t)=>{const{units:e}=t;if(e.length===0)return[];const{unitMeasures:u}=t,g=t.largest??Number.POSITIVE_INFINITY,s={};let o,n,i,m=r;for(n=0;n<e.length;n++){o=e[n];const l=u[o];i=n===e.length-1?m/l:Math.floor(m/l),s[o]=i,m-=i*l}if(t.round){let l=g;for(n=0;n<e.length;n++)if(o=e[n],i=s[o],i!==0&&(l--,l===0)){for(let a=n+1;a<e.length;a++){const d=e[a],h=s[d];s[o]+=h*u[d]/u[o],s[d]=0}break}for(n=e.length-1;n>=0;n--){if(o=e[n],i=s[o],i===0)continue;const a=Math.round(i);if(s[o]=a,n===0)break;const d=e[n-1],h=u[d],p=Math.floor(a*u[o]/h);if(p)s[d]+=p,s[o]=0;else break}}const c=[];for(n=0;n<e.length&&c.length<g;n++){if(o=e[n],i=s[o],i&&!t.round&&c.length===g-1){let l,a=0;for(l=n+1,e.length;l<e.length;l++){const d=e[l];a+=s[d]*(t.unitMeasures[d]/t.unitMeasures[o])}i+=a,t.maxDecimalPoints!==void 0&&(i=N(i,t.maxDecimalPoints))}i&&c.push({unitCount:i,unitName:o})}return c},"getPieces"),C=f((r,t,e)=>{const{language:u,units:g}=t;if(r.length===0){const l=g.at(-1);return v({unitCount:0,unitName:l},u,t)}const{conjunction:s,serialComma:o}=t;let n=", ";t.delimiter!==void 0?n=t.delimiter:u.delimiter!==void 0&&(n=u.delimiter);let i="";t.timeAdverb&&e!==0&&(i=u.future??"",e<0&&(i=u.past??""));const m=[];for(const l of r){const a=l;m.push(v(a,u,t))}let c;return!s||r.length===1?c=m.join(n):r.length===2?c=m.join(s):c=m.slice(0,-1).join(n)+(o?",":"")+s+m.at(-1),i&&(c=i.replace("%s",c)),c},"formatPieces"),I=f((r,t)=>{if(Number.isNaN(r))throw new TypeError("Expected a valid number");if(typeof r!="number")throw new TypeError("Expected a number");const e={conjunction:"",language:M.durationLanguage,round:!1,serialComma:!0,spacer:" ",timeAdverb:!1,unitMeasures:{d:864e5,h:36e5,m:6e4,mo:2629746e3,ms:1,s:1e3,w:6048e5,y:31556952e3},units:["w","d","h","m","s"],...t};P(e.language);const u=Math.abs(r),g=w(u,e);return C(g,e,r)},"duration");module.exports=I;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/humanizer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
4
4
|
"description": "Humanizer is a library for humanizing data in a human-readable form.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"visulima",
|
|
@@ -98,21 +98,21 @@
|
|
|
98
98
|
"devDependencies": {
|
|
99
99
|
"@anolilab/eslint-config": "^15.0.3",
|
|
100
100
|
"@anolilab/prettier-config": "^5.0.14",
|
|
101
|
-
"@anolilab/semantic-release-pnpm": "^1.1.
|
|
102
|
-
"@anolilab/semantic-release-preset": "^9.0.
|
|
103
|
-
"@arethetypeswrong/cli": "^0.
|
|
104
|
-
"@babel/core": "^7.
|
|
101
|
+
"@anolilab/semantic-release-pnpm": "^1.1.6",
|
|
102
|
+
"@anolilab/semantic-release-preset": "^9.0.3",
|
|
103
|
+
"@arethetypeswrong/cli": "^0.17.2",
|
|
104
|
+
"@babel/core": "^7.26.0",
|
|
105
105
|
"@rushstack/eslint-plugin-security": "^0.8.3",
|
|
106
|
-
"@secretlint/secretlint-rule-preset-recommend": "^
|
|
106
|
+
"@secretlint/secretlint-rule-preset-recommend": "^9.0.0",
|
|
107
107
|
"@types/ms": "^0.7.34",
|
|
108
108
|
"@types/node": "18.19.15",
|
|
109
|
-
"@visulima/packem": "1.
|
|
110
|
-
"@visulima/path": "1.
|
|
111
|
-
"@vitest/coverage-v8": "^2.1.
|
|
112
|
-
"@vitest/ui": "^2.1.
|
|
109
|
+
"@visulima/packem": "1.9.2",
|
|
110
|
+
"@visulima/path": "1.2.0",
|
|
111
|
+
"@vitest/coverage-v8": "^2.1.8",
|
|
112
|
+
"@vitest/ui": "^2.1.8",
|
|
113
113
|
"conventional-changelog-conventionalcommits": "8.0.0",
|
|
114
114
|
"cross-env": "^7.0.3",
|
|
115
|
-
"csv-parse": "^5.
|
|
115
|
+
"csv-parse": "^5.6.0",
|
|
116
116
|
"esbuild": "0.24.0",
|
|
117
117
|
"eslint": "8.57.0",
|
|
118
118
|
"eslint-plugin-deprecation": "^3.0.0",
|
|
@@ -122,15 +122,15 @@
|
|
|
122
122
|
"eslint-plugin-vitest": "^0.4.1",
|
|
123
123
|
"eslint-plugin-vitest-globals": "^1.5.0",
|
|
124
124
|
"ms": "^2.1.3",
|
|
125
|
-
"prettier": "^3.
|
|
125
|
+
"prettier": "^3.4.2",
|
|
126
126
|
"rimraf": "5.0.9",
|
|
127
127
|
"secretlint": "8.2.4",
|
|
128
128
|
"semantic-release": "24.0.0",
|
|
129
129
|
"typescript": "5.4.5",
|
|
130
|
-
"vitest": "^2.1.
|
|
130
|
+
"vitest": "^2.1.8"
|
|
131
131
|
},
|
|
132
132
|
"engines": {
|
|
133
|
-
"node": ">=18.* <=
|
|
133
|
+
"node": ">=18.* <=23.*"
|
|
134
134
|
},
|
|
135
135
|
"publishConfig": {
|
|
136
136
|
"access": "public",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var x=Object.defineProperty;var b=(o,t)=>x(o,"name",{value:t,configurable:!0});const M=require("../language/en.cjs"),P=require("../language/util/validate-duration-language.cjs");var _=Object.defineProperty,f=b((o,t)=>_(o,"name",{value:t,configurable:!0}),"g");const N=f((o,t)=>{t=t||-1;const e=new RegExp(`^-?\\d+(?:.\\d{0,${t}})?`).exec(o.toString());return e===null?o:Number.parseFloat(e[0])},"toFixed"),v=f(({unitCount:o,unitName:t},e,u)=>{let{spacer:g}=u;const{maxDecimalPoints:s}=u;let r=".";u.decimal!==void 0?r=u.decimal:e.decimal!==void 0&&(r=e.decimal);let n;"digitReplacements"in u?n=u.digitReplacements:"_digitReplacements"in e&&(n=e._digitReplacements);let i,m=o;s!==void 0&&(m=N(o,s));const c=m.toString();if(!e._hideCountIf2||o!==2)if(n){i="";for(const d of c)i+=d==="."?r:n[d]}else i=c.replace(".",r);else i="";const l=e[t];let a=l;return typeof l=="function"&&(a=l(o)),e._hideCountIf2&&o===2&&(g=""),e._numberFirst?a+g+i:i+g+a},"renderPiece"),w=f((o,t)=>{const{units:e}=t;if(e.length===0)return[];const{unitMeasures:u}=t,g=t.largest??Number.POSITIVE_INFINITY,s={};let r,n,i,m=o;for(n=0;n<e.length;n++){r=e[n];const l=u[r];i=n===e.length-1?m/l:Math.floor(m/l),s[r]=i,m-=i*l}if(t.round){let l=g;for(n=0;n<e.length;n++)if(r=e[n],i=s[r],i!==0&&(l--,l===0)){for(let a=n+1;a<e.length;a++){const d=e[a],h=s[d];s[r]+=h*u[d]/u[r],s[d]=0}break}for(n=e.length-1;n>=0;n--){if(r=e[n],i=s[r],i===0)continue;const a=Math.round(i);if(s[r]=a,n===0)break;const d=e[n-1],h=u[d],p=Math.floor(a*u[r]/h);if(p)s[d]+=p,s[r]=0;else break}}const c=[];for(n=0;n<e.length&&c.length<g;n++){if(r=e[n],i=s[r],i&&!t.round&&c.length===g-1){let l,a=0;for(l=n+1,e.length;l<e.length;l++){const d=e[l];a+=s[d]*(t.unitMeasures[d]/t.unitMeasures[r])}i+=a,t.maxDecimalPoints!==void 0&&(i=N(i,t.maxDecimalPoints))}i&&c.push({unitCount:i,unitName:r})}return c},"getPieces"),C=f((o,t,e)=>{const{language:u,units:g}=t;if(o.length===0){const l=g.at(-1);return v({unitCount:0,unitName:l},u,t)}const{conjunction:s,serialComma:r}=t;let n=", ";t.delimiter!==void 0?n=t.delimiter:u.delimiter!==void 0&&(n=u.delimiter);let i="";t.timeAdverb&&e!==0&&(i=u.future??"",e<0&&(i=u.past??""));const m=[];for(const l of o){const a=l;m.push(v(a,u,t))}let c;return!s||o.length===1?c=m.join(n):o.length===2?c=m.join(s):c=m.slice(0,-1).join(n)+(r?",":"")+s+m.at(-1),i&&(c=i.replace("%s",c)),c},"formatPieces"),I=f((o,t)=>{if(Number.isNaN(o))throw new TypeError("Expected a valid number");if(typeof o!="number")throw new TypeError("Expected a number");const e={conjunction:"",language:M.durationLanguage,round:!1,serialComma:!0,spacer:" ",timeAdverb:!1,unitMeasures:{d:864e5,h:36e5,m:6e4,mo:2629746e3,ms:1,s:1e3,w:6048e5,y:31556952e3},units:["w","d","h","m","s"],...t};P(e.language);const u=Math.abs(o),g=w(u,e);return C(g,e,o)},"duration");module.exports=I;
|