Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "jsonlit", | ||
"type": "module", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Template literal tag function that JSON.stringify(expressions)", | ||
@@ -38,7 +38,5 @@ "main": "./cjs/jsonlit.js", | ||
"devDependencies": { | ||
"prettier": "^2.7.1", | ||
"typescript": "^4.8.4" | ||
}, | ||
"dependencies": { | ||
"tslib": "^2.4.0" | ||
}, | ||
"keywords": [ | ||
@@ -45,0 +43,0 @@ "json", |
@@ -1,17 +0,17 @@ | ||
export function jsonLit (strings:string[], ...args:any[]) { | ||
let totalElements = strings.length + args.length | ||
let intertwined = new Array(totalElements) | ||
export function jsonLit(strings: TemplateStringsArray, ...args: any[]) { | ||
let totalElements = strings.length + args.length; | ||
let intertwined = new Array(totalElements); | ||
for (let i = 0, j = 0; i < args.length; j += 2, i++) { | ||
intertwined[j] = strings[i] | ||
if(Array.isArray(args[i])){ | ||
intertwined[j + 1] = JSON.stringify(args[i]) | ||
} else { | ||
intertwined[j + 1] = JSON.stringify(args[i], null, 2) | ||
} | ||
for (let i = 0, j = 0; i < args.length; j += 2, i++) { | ||
intertwined[j] = strings[i]; | ||
if (Array.isArray(args[i])) { | ||
intertwined[j + 1] = JSON.stringify(args[i]); | ||
} else { | ||
intertwined[j + 1] = JSON.stringify(args[i], null, 2); | ||
} | ||
} | ||
intertwined[totalElements - 1] = strings[strings.length - 1] | ||
intertwined[totalElements - 1] = strings[strings.length - 1]; | ||
return intertwined.join('') | ||
return intertwined.join(''); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
0
5449
2
- Removedtslib@^2.4.0
- Removedtslib@2.8.1(transitive)