guess-json-indent
Advanced tools
Comparing version 1.5.0 to 2.0.0
export default function guessJsonIndent(jsonString){ | ||
const guessJsonIndent=(jsonString)=>{ | ||
const firstIndex=skipWhitespaces(jsonString,0); | ||
@@ -9,3 +9,3 @@ | ||
{ | ||
return; | ||
return | ||
} | ||
@@ -16,12 +16,14 @@ | ||
if(secondIndex===undefined){ | ||
return; | ||
return | ||
} | ||
return getIndent(jsonString,firstIndex,secondIndex); | ||
} | ||
return getIndent(jsonString,firstIndex,secondIndex) | ||
}; | ||
export default guessJsonIndent; | ||
const skipWhitespaces=function(jsonString,startIndex){ | ||
const skipWhitespaces=(jsonString,startIndex)=>{ | ||
for(let index=startIndex;index<jsonString.length;index+=1){ | ||
@@ -31,3 +33,3 @@ const character=jsonString[index]; | ||
if(!isJsonWhitespace(character)){ | ||
return index; | ||
return index | ||
} | ||
@@ -39,21 +41,17 @@ } | ||
const isJsonWhitespace=function(character){ | ||
return( | ||
const isJsonWhitespace=(character)=> | ||
character===" "|| | ||
character==="\t"|| | ||
character==="\n"|| | ||
character==="\r"); | ||
character==="\r"; | ||
}; | ||
const isJsonObjectOrArray=(character)=> | ||
character==="{"||character==="["; | ||
const isJsonObjectOrArray=function(character){ | ||
return character==="{"||character==="["; | ||
}; | ||
const getIndent=function(jsonString,firstIndex,secondIndex){ | ||
const getIndent=(jsonString,firstIndex,secondIndex)=>{ | ||
let indent; | ||
@@ -65,15 +63,15 @@ | ||
if(character==="\r"){ | ||
return; | ||
return | ||
} | ||
if(character==="\n"){ | ||
return normalizeIndent(indent); | ||
return normalizeIndent(indent) | ||
} | ||
if(indent===undefined){ | ||
indent=character; | ||
indent=character | ||
}else if(indent[0]===character){ | ||
indent+=character; | ||
indent+=character | ||
}else{ | ||
return; | ||
return | ||
} | ||
@@ -86,9 +84,8 @@ } | ||
const normalizeIndent=function(indent){ | ||
const normalizeIndent=(indent)=>{ | ||
if(indent===undefined){ | ||
return 0; | ||
return 0 | ||
} | ||
return indent[0]===" "?indent.length:indent; | ||
}; | ||
//# sourceMappingURL=main.js.map | ||
return indent[0]===" "?indent.length:indent | ||
}; |
{ | ||
"name": "guess-json-indent", | ||
"version": "1.5.0", | ||
"version": "2.0.0", | ||
"type": "module", | ||
"exports": { | ||
"types": "./build/types/main.d.ts", | ||
"types": "./build/src/main.d.ts", | ||
"default": "./build/src/main.js" | ||
}, | ||
"main": "./build/src/main.js", | ||
"types": "./build/types/main.d.ts", | ||
"types": "./build/src/main.d.ts", | ||
"files": [ | ||
"build/src/**/*.{js,json}", | ||
"build/types/**/*.d.ts" | ||
"build/src/**/*.{js,json,d.ts}", | ||
"!build/src/**/*.test.js", | ||
"!build/src/{helpers,fixtures}" | ||
], | ||
@@ -50,16 +51,15 @@ "sideEffects": false, | ||
"directories": { | ||
"lib": "src", | ||
"test": "test" | ||
"lib": "src" | ||
}, | ||
"devDependencies": { | ||
"@ehmicky/dev-tasks": "^1.0.102", | ||
"detect-indent": "^7.0.0", | ||
"@ehmicky/dev-tasks": "^2.0.80", | ||
"detect-indent": "^7.0.1", | ||
"detect-indentation": "^5.20.0", | ||
"detect-json-indent": "^0.0.3", | ||
"spyd": "^0.6.0", | ||
"test-each": "^5.5.0" | ||
"spyd": "^0.6.1", | ||
"test-each": "^6.0.0" | ||
}, | ||
"engines": { | ||
"node": ">=14.18.0" | ||
"node": ">=16.17.0" | ||
} | ||
} |
[![Node](https://img.shields.io/badge/-Node.js-808080?logo=node.js&colorA=404040&logoColor=66cc33)](https://www.npmjs.com/package/guess-json-indent) | ||
[![Browsers](https://img.shields.io/badge/-Browsers-808080?logo=firefox&colorA=404040)](https://unpkg.com/guess-json-indent?module) | ||
[![TypeScript](https://img.shields.io/badge/-Typed-808080?logo=typescript&colorA=404040&logoColor=0096ff)](/types/main.d.ts) | ||
[![TypeScript](https://img.shields.io/badge/-Typed-808080?logo=typescript&colorA=404040&logoColor=0096ff)](/src/main.d.ts) | ||
[![Codecov](https://img.shields.io/badge/-Tested%20100%25-808080?logo=codecov&colorA=404040)](https://codecov.io/gh/ehmicky/guess-json-indent) | ||
[![Minified size](https://img.shields.io/bundlephobia/minzip/guess-json-indent?label&colorA=404040&colorB=808080&logo=webpack)](https://bundlephobia.com/package/guess-json-indent) | ||
[![Twitter](https://img.shields.io/badge/-Twitter-808080.svg?logo=twitter&colorA=404040)](https://twitter.com/intent/follow?screen_name=ehmicky) | ||
[![Mastodon](https://img.shields.io/badge/-Mastodon-808080.svg?logo=mastodon&colorA=404040&logoColor=9590F9)](https://fosstodon.org/@ehmicky) | ||
[![Medium](https://img.shields.io/badge/-Medium-808080.svg?logo=medium&colorA=404040)](https://medium.com/@ehmicky) | ||
@@ -37,7 +37,10 @@ | ||
This package works in both Node.js >=14.18.0 and | ||
[browsers](https://raw.githubusercontent.com/ehmicky/dev-tasks/main/src/tasks/build/browserslist). | ||
It is an ES module and must be loaded using | ||
This package works in both Node.js >=16.17.0 and | ||
[browsers](https://raw.githubusercontent.com/ehmicky/dev-tasks/main/src/browserslist). | ||
This is an ES module. It must be loaded using | ||
[an `import` or `import()` statement](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c), | ||
not `require()`. | ||
not `require()`. If TypeScript is used, it must be configured to | ||
[output ES modules](https://www.typescriptlang.org/docs/handbook/esm-node.html), | ||
not CommonJS. | ||
@@ -109,4 +112,4 @@ # API | ||
<!-- | ||
<table><tr><td align="center"><a href="https://twitter.com/ehmicky"><img src="https://avatars2.githubusercontent.com/u/8136211?v=4" width="100px;" alt="ehmicky"/><br /><sub><b>ehmicky</b></sub></a><br /><a href="https://github.com/ehmicky/guess-json-indent/commits?author=ehmicky" title="Code">💻</a> <a href="#design-ehmicky" title="Design">🎨</a> <a href="#ideas-ehmicky" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/ehmicky/guess-json-indent/commits?author=ehmicky" title="Documentation">📖</a></td></tr></table> | ||
<table><tr><td align="center"><a href="https://fosstodon.org/@ehmicky"><img src="https://avatars2.githubusercontent.com/u/8136211?v=4" width="100px;" alt="ehmicky"/><br /><sub><b>ehmicky</b></sub></a><br /><a href="https://github.com/ehmicky/guess-json-indent/commits?author=ehmicky" title="Code">💻</a> <a href="#design-ehmicky" title="Design">🎨</a> <a href="#ideas-ehmicky" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/ehmicky/guess-json-indent/commits?author=ehmicky" title="Documentation">📖</a></td></tr></table> | ||
--> | ||
<!-- ALL-CONTRIBUTORS-LIST:END --> |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
10797
114
130
1