Socket
Socket
Sign inDemoInstall

detab

Package Overview
Dependencies
1
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.3 to 2.0.4

43

index.js

@@ -7,5 +7,3 @@ 'use strict'

var tab = 0x09
var lineFeed = 0x0a
var carriageReturn = 0x0d
var search = /[\t\n\r]/g

@@ -15,34 +13,35 @@ // Replace tabs with spaces, being smart about which column the tab is at and

function detab(value, size) {
var string = typeof value === 'string'
var length = string && value.length
var tabSize = size || 4
var result = []
var start = 0
var index = -1
var index = 0
var column = -1
var tabSize = size || 4
var results = []
var code
var add
var match
var end
if (!string) {
if (typeof value !== 'string') {
throw new Error('detab expected string')
}
while (++index < length) {
code = value.charCodeAt(index)
while (index < value.length) {
search.lastIndex = index
match = search.exec(value)
end = match ? match.index : value.length
if (code === tab) {
add = tabSize - ((column + 1) % tabSize)
column += add
results.push(value.slice(start, index) + repeat(' ', add))
start = index + 1
} else if (code === lineFeed || code === carriageReturn) {
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
} else {
column++
}
index = end + 1
}
results.push(value.slice(start))
result.push(value.slice(start))
return results.join('')
return result.join('')
}
{
"name": "detab",
"version": "2.0.3",
"version": "2.0.4",
"description": "Detab: tabs -> spaces",

@@ -30,13 +30,13 @@ "license": "MIT",

"devDependencies": {
"browserify": "^16.0.0",
"browserify": "^17.0.0",
"nyc": "^15.0.0",
"prettier": "^1.0.0",
"remark-cli": "^7.0.0",
"remark-preset-wooorm": "^6.0.0",
"tape": "^4.0.0",
"tinyify": "^2.0.0",
"xo": "^0.25.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 --write \"**/*.js\" && xo --fix",
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"build-bundle": "browserify . -s detab -o detab.js",

@@ -62,3 +62,6 @@ "build-mangle": "browserify . -s detab -p tinyify -o detab.min.js",

"detab.js"
]
],
"rules": {
"unicorn/prefer-type-error": "off"
}
},

@@ -65,0 +68,0 @@ "remarkConfig": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc