This commit is contained in:
45
node_modules/detab/index.js
generated
vendored
Normal file
45
node_modules/detab/index.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = detab
|
||||
|
||||
var repeat = require('repeat-string')
|
||||
|
||||
var search = /[\t\n\r]/g
|
||||
|
||||
// Replace tabs with spaces, being smart about which column the tab is at and
|
||||
// which size should be used.
|
||||
function detab(value, size) {
|
||||
var tabSize = size || 4
|
||||
var result = []
|
||||
var start = 0
|
||||
var index = 0
|
||||
var column = -1
|
||||
var add
|
||||
var match
|
||||
var end
|
||||
|
||||
if (typeof value !== 'string') {
|
||||
throw new Error('detab expected string')
|
||||
}
|
||||
|
||||
while (index < value.length) {
|
||||
search.lastIndex = index
|
||||
match = search.exec(value)
|
||||
end = match ? match.index : value.length
|
||||
|
||||
if (value.charCodeAt(end) === 9) {
|
||||
add = tabSize - ((column + end - index + 1) % tabSize)
|
||||
result.push(value.slice(start, end), repeat(' ', add))
|
||||
column += end - index + add
|
||||
start = end + 1
|
||||
} else {
|
||||
column = -1
|
||||
}
|
||||
|
||||
index = end + 1
|
||||
}
|
||||
|
||||
result.push(value.slice(start))
|
||||
|
||||
return result.join('')
|
||||
}
|
||||
22
node_modules/detab/license
generated
vendored
Normal file
22
node_modules/detab/license
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2015 Titus Wormer <tituswormer@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
71
node_modules/detab/package.json
generated
vendored
Normal file
71
node_modules/detab/package.json
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
{
|
||||
"name": "detab",
|
||||
"version": "2.0.4",
|
||||
"description": "Detab: tabs -> spaces",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"detab",
|
||||
"tab",
|
||||
"space",
|
||||
"tab-size",
|
||||
"size"
|
||||
],
|
||||
"repository": "wooorm/detab",
|
||||
"bugs": "https://github.com/wooorm/detab/issues",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"repeat-string": "^1.5.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^17.0.0",
|
||||
"nyc": "^15.0.0",
|
||||
"prettier": "^2.0.0",
|
||||
"remark-cli": "^9.0.0",
|
||||
"remark-preset-wooorm": "^8.0.0",
|
||||
"tape": "^5.0.0",
|
||||
"tinyify": "^3.0.0",
|
||||
"xo": "^0.34.0"
|
||||
},
|
||||
"scripts": {
|
||||
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
|
||||
"build-bundle": "browserify . -s detab -o detab.js",
|
||||
"build-mangle": "browserify . -s detab -p tinyify -o detab.min.js",
|
||||
"build": "npm run build-bundle && npm run build-mangle",
|
||||
"test-api": "node test",
|
||||
"test-coverage": "nyc --reporter lcov tape test.js",
|
||||
"test": "npm run format && npm run build && npm run test-coverage"
|
||||
},
|
||||
"prettier": {
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"singleQuote": true,
|
||||
"bracketSpacing": false,
|
||||
"semi": false,
|
||||
"trailingComma": "none"
|
||||
},
|
||||
"xo": {
|
||||
"prettier": true,
|
||||
"esnext": false,
|
||||
"ignores": [
|
||||
"detab.js"
|
||||
],
|
||||
"rules": {
|
||||
"unicorn/prefer-type-error": "off"
|
||||
}
|
||||
},
|
||||
"remarkConfig": {
|
||||
"plugins": [
|
||||
"preset-wooorm"
|
||||
]
|
||||
}
|
||||
}
|
||||
78
node_modules/detab/readme.md
generated
vendored
Normal file
78
node_modules/detab/readme.md
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
# detab
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
|
||||
Detab: tabs → spaces.
|
||||
|
||||
## Install
|
||||
|
||||
[npm][]:
|
||||
|
||||
```sh
|
||||
npm install detab
|
||||
```
|
||||
|
||||
## Use
|
||||
|
||||
```js
|
||||
var detab = require('detab')
|
||||
|
||||
console.log(detab('\tfoo\nbar\tbaz'))
|
||||
console.log(detab('\tfoo\nbar\tbaz', 2))
|
||||
console.log(detab('\tfoo\nbar\tbaz', 8))
|
||||
```
|
||||
|
||||
Yields:
|
||||
|
||||
```text
|
||||
foo
|
||||
bar baz
|
||||
```
|
||||
|
||||
```text
|
||||
foo
|
||||
bar baz
|
||||
```
|
||||
|
||||
```text
|
||||
foo
|
||||
bar baz
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `detab(value[, size=4])`
|
||||
|
||||
Replace tabs with spaces in `value` (`string`), being smart about which column
|
||||
the tab is at and which `size` (`number`, default: `4`) should be used.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
|
||||
<!-- Definitions -->
|
||||
|
||||
[build-badge]: https://img.shields.io/travis/wooorm/detab.svg
|
||||
|
||||
[build]: https://travis-ci.org/wooorm/detab
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/detab.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/wooorm/detab
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/detab.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/detab
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/detab.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=detab
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[license]: license
|
||||
|
||||
[author]: https://wooorm.com
|
||||
Reference in New Issue
Block a user