@visulima/fmt
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -0,1 +1,9 @@ | ||
## @visulima/fmt [1.0.1](https://github.com/visulima/visulima/compare/@visulima/fmt@1.0.0...@visulima/fmt@1.0.1) (2024-01-19) | ||
### Bug Fixes | ||
* changed wrong typing ([e11089e](https://github.com/visulima/visulima/commit/e11089eba1045f0db46866a5093df3bd8b111aaf)) | ||
* updated all deps, updated test based on eslint errors ([909f8f3](https://github.com/visulima/visulima/commit/909f8f384804d7ef140354ab44f867532dbc9847)) | ||
## @visulima/fmt 1.0.0 (2023-12-13) | ||
@@ -2,0 +10,0 @@ |
@@ -1,2 +0,2 @@ | ||
declare const format: (fmt: NonNullable<Record<string, any> | string>, arguments_?: any[], options?: Options) => string; | ||
declare const format: (fmt: Record<string, any> | string, arguments_?: any[], options?: Options) => string; | ||
declare const build: (options?: Options) => (f: NonNullable<Record<string, any> | string>, arguments_?: any[], formatOptions?: Omit<Options, "formatters">) => string; | ||
@@ -3,0 +3,0 @@ type FormatterFunction = (argument: any) => string; |
'use strict'; | ||
var p=e=>{try{return JSON.stringify(e)}catch{return '"[Circular]"'}},u="%".codePointAt(0),g="s".codePointAt(0),d="d".codePointAt(0),h="f".codePointAt(0),b="i".codePointAt(0),A="O".codePointAt(0),k="o".codePointAt(0),F="j".codePointAt(0),P=(e,n=[],s={})=>{if(typeof e!="string"&&typeof e!="object"||e===null)throw new TypeError(`fmt must be a string or object, got ${e===null?"null":typeof e}`);let c=s.stringify??p,f=1;if(typeof e=="object"){let t=n.length+f;if(t===1)return "{}";let l=Array.from({length:t});l[0]=c(e);for(let a=1;a<t;a++)l[a]=c(n[a-f]);return l.join(" ")}if(n.length===0)return e;let i="",r=1-f,o=-1;for(let t=0;t<e.length;){if(e.codePointAt(t)===u&&t+1<e.length){o=o>-1?o:0;let l=e.codePointAt(t+1);if(l===void 0){++r;break}switch(l){case d:case h:{if(r>=n.length||n[r]==null)break;o<t&&(i+=e.slice(o,t)),i+=Number(n[r]).toString(),o=t+2,t++;break}case b:{if(r>=n.length||n[r]==null)break;o<t&&(i+=e.slice(o,t)),i+=Math.floor(Number(n[r])).toString(),o=t+2,t++;break}case A:case k:case F:{if(r>=n.length||n[r]===void 0)break;o<t&&(i+=e.slice(o,t));let a=n[r],y=typeof a;if(y==="string"){i+=`'${a}'`,o=t+2;break}if(y==="function"){i+=a.name?`[Function: ${a.name}]`:"[Function: <anonymous>]",o=t+2;break}i+=c(a),o=t+2,t++;break}case g:{if(r>=n.length)break;o<t&&(i+=e.slice(o,t)),i+=typeof n[r]=="object"?c(n[r]):String(n[r]),o=t+2,t++;break}case u:{o<t&&(i+=e.slice(o,t)),i+="%",o=t+2,t++,r--;break}}typeof s.formatters?.[l]=="function"&&(i+=s.formatters[l](n[r]),o=t+2),++r;}++t;}return o===-1?e:(o<e.length&&(i+=e.slice(o)),i)},O=(e={})=>{let n={};return typeof e.formatters=="object"&&Object.entries(e.formatters).forEach(([s,c])=>{if(s.length===0)throw new Error(`Formatter %${s} has no characters`);if(s.length>1)throw new Error(`Formatter %${s} has more than one character`);if(typeof c!="function")throw new TypeError(`Formatter for %${s} is not a function`);let f=s.codePointAt(0);if(f===void 0)throw new Error(`${s}.codePointAt(0) failed to return a value, please report this issue`);n[f]=c;}),(s,c=[],f={})=>P(s,c,{...f,formatters:n})}; | ||
var p=e=>{try{return JSON.stringify(e)}catch{return '"[Circular]"'}},u="%".codePointAt(0),g="s".codePointAt(0),d="d".codePointAt(0),h="f".codePointAt(0),b="i".codePointAt(0),A="O".codePointAt(0),k="o".codePointAt(0),F="j".codePointAt(0),P=(e,r=[],s={})=>{if(typeof e!="string"&&typeof e!="object"||e===null)throw new TypeError(`fmt must be a string or object, got ${e===null?"null":typeof e}`);let c=s.stringify??p,f=1;if(typeof e=="object"){let t=r.length+f;if(t===1)return "{}";let l=Array.from({length:t});l[0]=c(e);for(let a=1;a<t;a++)l[a]=c(r[a-f]);return l.join(" ")}if(r.length===0)return e;let i="",n=1-f,o=-1;for(let t=0;t<e.length;){if(e.codePointAt(t)===u&&t+1<e.length){o=o>-1?o:0;let l=e.codePointAt(t+1);if(l===void 0){++n;break}switch(l){case d:case h:{if(n>=r.length||r[n]==null)break;o<t&&(i+=e.slice(o,t)),i+=Number(r[n]).toString(),o=t+2,t++;break}case b:{if(n>=r.length||r[n]==null)break;o<t&&(i+=e.slice(o,t)),i+=Math.floor(Number(r[n])).toString(),o=t+2,t++;break}case A:case k:case F:{if(n>=r.length||r[n]===void 0)break;o<t&&(i+=e.slice(o,t));let a=r[n],y=typeof a;if(y==="string"){i+=`'${a}'`,o=t+2;break}if(y==="function"){i+=a.name?`[Function: ${a.name}]`:"[Function: <anonymous>]",o=t+2;break}i+=c(a),o=t+2,t++;break}case g:{if(n>=r.length)break;o<t&&(i+=e.slice(o,t)),i+=typeof r[n]=="object"?c(r[n]):String(r[n]),o=t+2,t++;break}case u:{o<t&&(i+=e.slice(o,t)),i+="%",o=t+2,t++,n--;break}}typeof s.formatters?.[l]=="function"&&(i+=s.formatters[l](r[n]),o=t+2),++n;}++t;}return o===-1?e:(o<e.length&&(i+=e.slice(o)),i)},O=(e={})=>{let r={};return typeof e.formatters=="object"&&Object.entries(e.formatters).forEach(([s,c])=>{if(s.length===0)throw new Error(`Formatter %${s} has no characters`);if(s.length>1)throw new Error(`Formatter %${s} has more than one character`);if(typeof c!="function")throw new TypeError(`Formatter for %${s} is not a function`);let f=s.codePointAt(0);if(f===void 0)throw new Error(`${s}.codePointAt(0) failed to return a value, please report this issue`);r[f]=c;}),(s,c=[],f={})=>P(s,c,{...f,formatters:r})}; | ||
@@ -5,0 +5,0 @@ exports.build = O; |
{ | ||
"name": "@visulima/fmt", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Util.format-like string formatting utility.", | ||
@@ -80,26 +80,26 @@ "keywords": [ | ||
"devDependencies": { | ||
"@anolilab/eslint-config": "^15.0.2", | ||
"@anolilab/prettier-config": "^5.0.13", | ||
"@anolilab/semantic-release-preset": "^8.0.2", | ||
"@babel/core": "^7.23.5", | ||
"@rushstack/eslint-plugin-security": "^0.7.1", | ||
"@anolilab/eslint-config": "^15.0.3", | ||
"@anolilab/prettier-config": "^5.0.14", | ||
"@anolilab/semantic-release-preset": "^8.0.3", | ||
"@babel/core": "^7.23.7", | ||
"@rushstack/eslint-plugin-security": "^0.8.0", | ||
"@types/node": "18.18.8", | ||
"@vitest/coverage-v8": "^1.0.2", | ||
"@vitest/ui": "^1.0.2", | ||
"@vitest/coverage-v8": "^1.2.1", | ||
"@vitest/ui": "^1.2.1", | ||
"cross-env": "^7.0.3", | ||
"eslint": "^8.55.0", | ||
"eslint": "^8.56.0", | ||
"eslint-plugin-deprecation": "^2.0.0", | ||
"eslint-plugin-etc": "^2.0.3", | ||
"eslint-plugin-import": "npm:eslint-plugin-i@^2.29.0", | ||
"eslint-plugin-mdx": "^2.2.0", | ||
"eslint-plugin-vitest": "^0.3.10", | ||
"eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1", | ||
"eslint-plugin-mdx": "^3.1.5", | ||
"eslint-plugin-vitest": "^0.3.20", | ||
"eslint-plugin-vitest-globals": "^1.4.0", | ||
"prettier": "^3.1.0", | ||
"prettier": "^3.2.4", | ||
"quick-format-unescaped": "^4.0.4", | ||
"rimraf": "^5.0.5", | ||
"semantic-release": "^22.0.10", | ||
"semantic-release": "^23.0.0", | ||
"sort-package-json": "^2.6.0", | ||
"tsup": "^8.0.1", | ||
"typescript": "^5.3.3", | ||
"vitest": "^1.0.2" | ||
"vitest": "^1.2.1" | ||
}, | ||
@@ -106,0 +106,0 @@ "engines": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42589