Skip to content

Commit

Permalink
Use has instead of unreliable hasOwnProperty check.
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Aug 3, 2015
1 parent d6b897d commit fd66deb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions index.js
@@ -1,6 +1,8 @@
/*jslint node: true */
'use strict';

var has = require('has');

var listify = function listify(list) {
if (!Array.isArray(list)) {
throw new TypeError('requires an array');
Expand All @@ -10,8 +12,8 @@ var listify = function listify(list) {
if (!options) {
options = {};
}
var separator = options.hasOwnProperty('separator') ? options.separator : ', ';
var finalWord = options.hasOwnProperty('finalWord') ? options.finalWord : 'and';
var separator = has(options, 'separator') ? options.separator : ', ';
var finalWord = has(options, 'finalWord') ? options.finalWord : 'and';
if (finalWord.length > 0) {
finalWord += ' ';
}
Expand Down
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -28,7 +28,9 @@
"bugs": {
"url": "https://github.com/ljharb/listify/issues"
},
"dependencies": {},
"dependencies": {
"has": "^1.0.1"
},
"devDependencies": {
"tape": "^4.0.1",
"covert": "^1.1.0",
Expand Down

0 comments on commit fd66deb

Please sign in to comment.