Skip to content

Commit

Permalink
Use is-string and is-callable modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jan 29, 2015
1 parent 3b42958 commit 0769199
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
23 changes: 3 additions & 20 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

var ObjectPrototype = Object.prototype;
var toStr = ObjectPrototype.toString;
var fnToStr = Function.prototype.toString;
var has = ObjectPrototype.hasOwnProperty;
var isArrowFunction = require('is-arrow-function');
var isDate = require('is-date-object');
var isGenerator = require('is-generator-function');
var isNumber = require('is-number-object');
var isRegex = require('is-regex');
var isString = require('is-string');
var isCallable = require('is-callable');

var getPrototypeOf = Object.getPrototypeOf;
if (!getPrototypeOf) {
Expand Down Expand Up @@ -43,24 +44,6 @@ var isBoolean = function isBoolean(value) {
}
};

var strToStr = String.prototype.valueOf;
var isString = function isString(value) {
try {
strToStr.call(value);
return true;
} catch (e) {
return false;
}
};
var isFunction = function (value) {
try {
fnToStr.call(value);
return true;
} catch (e) {
return false;
}
};

var isArray = Array.isArray || function (value) {
return toStr.call(value) === '[object Array]';
};
Expand Down Expand Up @@ -123,7 +106,7 @@ module.exports = function isEqual(value, other) {
var otherIsArrow = isArrowFunction(other);
if (valueIsArrow !== otherIsArrow) { return false; }

if (isFunction(value) || isFunction(other)) {
if (isCallable(value) || isCallable(other)) {
if (!isEqual(value.name, other.name)) { return false; }
if (!isEqual(value.length, other.length)) { return false; }

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
],
"dependencies": {
"is-arrow-function": "~2.0.1",
"is-callable": "~1.0.0",
"is-date-object": "~1.0.0",
"is-generator-function": "~1.0.2",
"is-number-object": "~1.0.0",
"is-regex": "~1.0.1"
"is-regex": "~1.0.1",
"is-string": "~1.0.0"
},
"devDependencies": {
"tape": "~3.4.0",
Expand Down

0 comments on commit 0769199

Please sign in to comment.