Comparing version 3.0.1 to 3.0.2
@@ -5,6 +5,9 @@ /*** | ||
* | ||
* @param {string} value Value with tabs | ||
* @param {number} [tabSize=4] Tab size | ||
* @returns {string} Value with spaces | ||
* @param {string} value | ||
* Value with tabs. | ||
* @param {number} [tabSize=4] | ||
* Tab size. | ||
* @returns {string} | ||
* Value with spaces. | ||
*/ | ||
export function detab(value: string, tabSize?: number | undefined): string |
13
index.js
@@ -7,8 +7,11 @@ const search = /[\t\n\r]/g | ||
* | ||
* @param {string} value Value with tabs | ||
* @param {number} [tabSize=4] Tab size | ||
* @returns {string} Value with spaces | ||
* @param {string} value | ||
* Value with tabs. | ||
* @param {number} [tabSize=4] | ||
* Tab size. | ||
* @returns {string} | ||
* Value with spaces. | ||
*/ | ||
export function detab(value, tabSize = 4) { | ||
/** @type {string[]} */ | ||
/** @type {Array<string>} */ | ||
const result = [] | ||
@@ -28,3 +31,3 @@ let start = 0 | ||
if (value.charCodeAt(end) === 9) { | ||
if (value.codePointAt(end) === 9) { | ||
const add = tabSize - ((column + end - index + 1) % tabSize) | ||
@@ -31,0 +34,0 @@ result.push(value.slice(start, end), ' '.repeat(add)) |
{ | ||
"name": "detab", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "Detab: tabs -> spaces", | ||
@@ -31,21 +31,18 @@ "license": "MIT", | ||
], | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@types/tape": "^4.0.0", | ||
"@types/node": "^18.0.0", | ||
"c8": "^7.0.0", | ||
"prettier": "^2.0.0", | ||
"remark-cli": "^10.0.0", | ||
"remark-cli": "^11.0.0", | ||
"remark-preset-wooorm": "^9.0.0", | ||
"rimraf": "^3.0.0", | ||
"tape": "^5.0.0", | ||
"type-coverage": "^2.0.0", | ||
"typescript": "^4.0.0", | ||
"xo": "^0.44.0" | ||
"xo": "^0.52.0" | ||
}, | ||
"scripts": { | ||
"prepack": "npm run build && npm run format", | ||
"build": "rimraf \"*.d.ts\" && tsc && type-coverage", | ||
"build": "tsc --build --clean && tsc --build && type-coverage", | ||
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix", | ||
"test-api": "node test.js", | ||
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js", | ||
"test-api": "node --conditions development test.js", | ||
"test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api", | ||
"test": "npm run build && npm run format && npm run test-coverage" | ||
@@ -52,0 +49,0 @@ }, |
@@ -8,11 +8,31 @@ # detab | ||
Detab: tabs → spaces. | ||
Replace tabs with spaces. | ||
## Contents | ||
* [What is this?](#what-is-this) | ||
* [When should I use this?](#when-should-i-use-this) | ||
* [Install](#install) | ||
* [Use](#use) | ||
* [API](#api) | ||
* [`detab(value[, size=4])`](#detabvalue-size4) | ||
* [Types](#types) | ||
* [Compatibility](#compatibility) | ||
* [Contribute](#contribute) | ||
* [Security](#security) | ||
* [License](#license) | ||
## What is this? | ||
This package can turn a string with tabs into a string with spaces. | ||
## When should I use this? | ||
You can use this package if *you* want to define how big the tab size is. | ||
## Install | ||
This package is ESM only: Node 12+ is needed to use it and it must be `import`ed | ||
instead of `require`d. | ||
This package is [ESM only][esm]. | ||
In Node.js (version 14.14+, 16.0+), install with [npm][]: | ||
[npm][]: | ||
```sh | ||
@@ -22,2 +42,16 @@ npm install detab | ||
In Deno with [`esm.sh`][esmsh]: | ||
```js | ||
import {detab} from 'https://esm.sh/detab@3' | ||
``` | ||
In browsers with [`esm.sh`][esmsh]: | ||
```html | ||
<script type="module"> | ||
import {detab} from 'https://esm.sh/detab@3?bundle' | ||
</script> | ||
``` | ||
## Use | ||
@@ -52,3 +86,3 @@ | ||
This package exports the following identifiers: `detab`. | ||
This package exports the identifier `detab`. | ||
There is no default export. | ||
@@ -61,2 +95,22 @@ | ||
## Types | ||
This package is fully typed with [TypeScript][]. | ||
It exports no additional types. | ||
## Compatibility | ||
This package is at least compatible with all maintained versions of Node.js. | ||
As of now, that is Node.js 14.14+ and 16.0+. | ||
It also works in Deno and modern browsers. | ||
## Contribute | ||
Yes please! | ||
See [How to Contribute to Open Source][contribute]. | ||
## Security | ||
This package is safe. | ||
## License | ||
@@ -86,4 +140,12 @@ | ||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c | ||
[esmsh]: https://esm.sh | ||
[typescript]: https://www.typescriptlang.org | ||
[contribute]: https://opensource.guide/how-to-contribute/ | ||
[license]: license | ||
[author]: https://wooorm.com |
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
7029
8
50
147