humanize-list
Advanced tools
Comparing version 1.0.0 to 1.0.1
30
index.js
@@ -1,37 +0,37 @@ | ||
'use strict'; | ||
'use strict' | ||
module.exports = function humanizeList(list, options) { | ||
module.exports = function humanizeList (list, options) { | ||
if (!Array.isArray(list)) { | ||
throw new TypeError('humanize-list expected an array'); | ||
throw new TypeError('humanize-list expected an array') | ||
} | ||
options = options || {}; | ||
options.conjunction = options.conjunction || 'and'; | ||
options = options || {} | ||
options.conjunction = options.conjunction || 'and' | ||
var listLength = list.length; | ||
var listLength = list.length | ||
if (listLength === 1) { | ||
return list[0]; | ||
return list[0] | ||
} | ||
if (options.skipConjunction) { | ||
return list.join(', '); | ||
return list.join(', ') | ||
} | ||
var humanizedList = ''; | ||
var humanizedList = '' | ||
for (var i = 0; i < listLength; i++) { | ||
if (i === listLength - 1) { | ||
if (options.oxfordComma) { | ||
humanizedList += ','; | ||
humanizedList += ',' | ||
} | ||
humanizedList += ' ' + options.conjunction + ' '; | ||
humanizedList += ' ' + options.conjunction + ' ' | ||
} else if (i !== 0) { | ||
humanizedList += ', '; | ||
humanizedList += ', ' | ||
} | ||
humanizedList += list[i]; | ||
humanizedList += list[i] | ||
} | ||
return humanizedList; | ||
}; | ||
return humanizedList | ||
} |
@@ -5,3 +5,4 @@ { | ||
"author": "John Otander", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"license": "MIT", | ||
"main": "index.js", | ||
@@ -12,9 +13,5 @@ "directories": { | ||
"scripts": { | ||
"test": "mocha test", | ||
"hint": "jshint . --exclude-path=node_modules" | ||
"test": "ava" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/johnotander/humanize-list.git" | ||
}, | ||
"repository": "johnotander/humanize-list", | ||
"keywords": [ | ||
@@ -29,11 +26,6 @@ "humanize", | ||
], | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/johnotander/humanize-list/issues" | ||
}, | ||
"homepage": "https://github.com/johnotander/humanize-list", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"mocha": "*" | ||
"ava": "^0.8.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
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
51
5306
2
1
1