Skip to content

Commit 770cb04

Browse files
committed
Add helpers and remove lodash dependency
1 parent 3c1de62 commit 770cb04

File tree

5 files changed

+63
-15
lines changed

5 files changed

+63
-15
lines changed

configure/request-next.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
'use strict';
22

33
var core = require('../'),
4+
helpers = require('../lib/helpers'),
45
isArray = Array.isArray,
5-
isFunction = require('lodash.isfunction'),
6-
isObjectLike = require('lodash.isobjectlike');
6+
isFunction = helpers.isFunction,
7+
isObjectLike = helpers.isObjectLike;
78

89

910
module.exports = function (options) {

configure/request2.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
'use strict';
22

33
var core = require('../'),
4+
helpers = require('../lib/helpers'),
45
isArray = Array.isArray,
5-
isFunction = require('lodash.isfunction'),
6-
isObjectLike = require('lodash.isobjectlike');
6+
isFunction = helpers.isFunction,
7+
isObjectLike = helpers.isObjectLike;
78

89

910
module.exports = function (options) {

lib/helpers.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
'use strict';
2+
3+
var
4+
asyncTag = '[object AsyncFunction]',
5+
funcTag = '[object Function]',
6+
genTag = '[object GeneratorFunction]',
7+
proxyTag = '[object Proxy]',
8+
nullTag = '[object Null]',
9+
stringTag = '[object String]',
10+
undefinedTag = '[object Undefined]';
11+
12+
function baseGetTag(value) {
13+
if (value === undefined) {
14+
return undefinedTag;
15+
}
16+
17+
if (value === null) {
18+
return nullTag;
19+
}
20+
21+
return Object.prototype.toString.call(value);
22+
}
23+
24+
function isObject(value) {
25+
var type = typeof value;
26+
return value !== undefined && value !== null && (type === 'object' || type === 'function');
27+
}
28+
29+
function isFunction(value) {
30+
if (!isObject(value)) {
31+
return false;
32+
}
33+
34+
var tag = baseGetTag(value);
35+
return tag === funcTag || tag === genTag || tag === asyncTag || tag === proxyTag;
36+
}
37+
38+
function isObjectLike(value) {
39+
return value !== undefined && value !== null && typeof value === 'object';
40+
}
41+
42+
function isString(value) {
43+
return typeof value === 'string' ||
44+
!Array.isArray(value) && isObjectLike(value) && baseGetTag(value) === stringTag;
45+
}
46+
47+
module.exports = {
48+
isFunction: isFunction,
49+
isString: isString,
50+
isObjectLike: isObjectLike
51+
};

lib/plumbing.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
'use strict';
22

33
var errors = require('./errors.js'),
4-
isFunction = require('lodash.isfunction'),
5-
isObjectLike = require('lodash.isobjectlike'),
6-
isString = require('lodash.isstring'),
7-
isUndefined = require('lodash.isundefined');
4+
helpers = require('./helpers'),
5+
isFunction = helpers.isFunction,
6+
isObjectLike = helpers.isObjectLike,
7+
isString = helpers.isString;
88

99

1010
module.exports = function (options) {
@@ -19,7 +19,7 @@ module.exports = function (options) {
1919
throw new TypeError(errorText + '.PromiseImpl');
2020
}
2121

22-
if (!isUndefined(options.constructorMixin) && !isFunction(options.constructorMixin)) {
22+
if (options.constructorMixin !== undefined && !isFunction(options.constructorMixin)) {
2323
throw new TypeError(errorText + '.PromiseImpl');
2424
}
2525

package.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@
3232
"engines": {
3333
"node": ">=0.10.0"
3434
},
35-
"dependencies": {
36-
"lodash.isfunction": "^3.0.9",
37-
"lodash.isobjectlike": "^4.0.0",
38-
"lodash.isstring": "^4.0.1",
39-
"lodash.isundefined": "^3.0.1"
40-
},
4135
"peerDependencies": {
4236
"request": "^2.34"
4337
},
@@ -54,6 +48,7 @@
5448
"gulp-istanbul": "~1.0.0",
5549
"gulp-mocha": "~2.2.0",
5650
"lodash.flatten": "^4.4.0",
51+
"lodash.isfunction": "^3.0.9",
5752
"node-version": "~1.0.0",
5853
"publish-please": "~2.4.1",
5954
"request": "^2.34.0",

0 commit comments

Comments
 (0)