Skip to content

Commit 2802c9a

Browse files
authored
use own isFunction, isPlainObject´ and isSymbol checks (#312)
1 parent 8ae339c commit 2802c9a

12 files changed

+25
-17
lines changed

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@
6666
},
6767
"dependencies": {
6868
"invariant": "^2.2.1",
69-
"is-function": "^1.0.1",
70-
"is-plain-object": "^2.0.4",
71-
"is-symbol": "^1.0.1",
7269
"lodash.camelcase": "^4.3.0",
7370
"lodash.curry": "^4.1.1",
7471
"reduce-reducers": "^0.1.0"

src/combineActions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import invariant from 'invariant';
2-
import isFunction from 'is-function';
3-
import isSymbol from 'is-symbol';
2+
import isFunction from './utils/isFunction';
3+
import isSymbol from './utils/isSymbol';
44
import isEmpty from './utils/isEmpty';
55
import toString from './utils/toString';
66
import isString from './utils/isString';

src/createAction.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import isFunction from 'is-function';
21
import invariant from 'invariant';
2+
import isFunction from './utils/isFunction';
33
import identity from './utils/identity';
44
import isNull from './utils/isNull';
55

src/createActions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import isPlainObject from 'is-plain-object';
2-
import isFunction from 'is-function';
31
import invariant from 'invariant';
2+
import isPlainObject from './utils/isPlainObject';
3+
import isFunction from './utils/isFunction';
44
import identity from './utils/identity';
55
import isArray from './utils/isArray';
66
import isString from './utils/isString';

src/handleAction.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import invariant from 'invariant';
2-
import isFunction from 'is-function';
3-
import isPlainObject from 'is-plain-object';
2+
import isFunction from './utils/isFunction';
3+
import isPlainObject from './utils/isPlainObject';
44
import identity from './utils/identity';
55
import isNil from './utils/isNil';
66
import isUndefined from './utils/isUndefined';

src/handleActions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import reduceReducers from 'reduce-reducers';
2-
import isPlainObject from 'is-plain-object';
32
import invariant from 'invariant';
3+
import isPlainObject from './utils/isPlainObject';
44
import isMap from './utils/isMap';
55
import ownKeys from './utils/ownKeys';
66
import flattenReducerMap from './utils/flattenReducerMap';

src/utils/flattenActionMap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import isPlainObject from 'is-plain-object';
1+
import isPlainObject from './isPlainObject';
22
import flattenWhenNode from './flattenWhenNode';
33

44
export default flattenWhenNode(isPlainObject);

src/utils/flattenReducerMap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import isPlainObject from 'is-plain-object';
1+
import isPlainObject from './isPlainObject';
22
import isMap from './isMap';
33
import hasGeneratorInterface from './hasGeneratorInterface';
44
import flattenWhenNode from './flattenWhenNode';

src/utils/isFunction.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default value => typeof value === 'function';

src/utils/isPlainObject.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default value => {
2+
if (typeof value !== 'object' || value === null) return false;
3+
4+
let proto = value;
5+
while (Object.getPrototypeOf(proto) !== null) {
6+
proto = Object.getPrototypeOf(proto);
7+
}
8+
9+
return Object.getPrototypeOf(value) === proto;
10+
};

src/utils/isSymbol.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default value =>
2+
typeof value === 'symbol' ||
3+
(typeof value === 'object' &&
4+
Object.prototype.toString.call(value) === '[object Symbol]');

yarn.lock

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3456,10 +3456,6 @@ is-fullwidth-code-point@^2.0.0:
34563456
version "2.0.0"
34573457
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f"
34583458

3459-
is-function@^1.0.1:
3460-
version "1.0.1"
3461-
resolved "https://registry.yarnpkg.com/is-function/-/is-function-1.0.1.tgz#12cfb98b65b57dd3d193a3121f5f6e2f437602b5"
3462-
34633459
is-generator-fn@^1.0.0:
34643460
version "1.0.0"
34653461
resolved "https://registry.yarnpkg.com/is-generator-fn/-/is-generator-fn-1.0.0.tgz#969d49e1bb3329f6bb7f09089be26578b2ddd46a"

0 commit comments

Comments
 (0)