Skip to content

Commit

Permalink
Add has as a dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Nov 25, 2016
1 parent 4a25aa5 commit d3982ce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
11 changes: 4 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict';

var afinn = require('afinn-111');
var has = require('has');
var emoji = require('./data/emoji.json');

module.exports = polarity;
polarity.inject = inject;
polarity.polarities = {};

var polarities = polarity.polarities;
var has = Object.prototype.hasOwnProperty;

inject(afinn);
inject(emoji);
Expand Down Expand Up @@ -55,20 +55,17 @@ function inject(values) {
var value;

for (value in values) {
/* istanbul ignore else */
if (has.call(values, value)) {
polarities[value] = values[value];
}
polarities[value] = values[value];
}
}

/* Get the polarity of a word. */
function getPolarity(value, inject) {
if (has.call(polarities, value)) {
if (has(polarities, value)) {
return polarities[value];
}

if (inject && has.call(inject, value)) {
if (inject && has(inject, value)) {
return inject[value];
}

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"data/emoji.json"
],
"dependencies": {
"afinn-111": "^1.1.0"
"afinn-111": "^1.1.0",
"has": "^1.0.1"
},
"devDependencies": {
"browserify": "^13.1.1",
Expand Down

0 comments on commit d3982ce

Please sign in to comment.