Skip to content

Commit

Permalink
use own isFunction, isPlainObject´ and isSymbol checks (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
timche authored Jul 26, 2018
1 parent 8ae339c commit 2802c9a
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 17 deletions.
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@
},
"dependencies": {
"invariant": "^2.2.1",
"is-function": "^1.0.1",
"is-plain-object": "^2.0.4",
"is-symbol": "^1.0.1",
"lodash.camelcase": "^4.3.0",
"lodash.curry": "^4.1.1",
"reduce-reducers": "^0.1.0"
Expand Down
4 changes: 2 additions & 2 deletions src/combineActions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import invariant from 'invariant';
import isFunction from 'is-function';
import isSymbol from 'is-symbol';
import isFunction from './utils/isFunction';
import isSymbol from './utils/isSymbol';
import isEmpty from './utils/isEmpty';
import toString from './utils/toString';
import isString from './utils/isString';
Expand Down
2 changes: 1 addition & 1 deletion src/createAction.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import isFunction from 'is-function';
import invariant from 'invariant';
import isFunction from './utils/isFunction';
import identity from './utils/identity';
import isNull from './utils/isNull';

Expand Down
4 changes: 2 additions & 2 deletions src/createActions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import isPlainObject from 'is-plain-object';
import isFunction from 'is-function';
import invariant from 'invariant';
import isPlainObject from './utils/isPlainObject';
import isFunction from './utils/isFunction';
import identity from './utils/identity';
import isArray from './utils/isArray';
import isString from './utils/isString';
Expand Down
4 changes: 2 additions & 2 deletions src/handleAction.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import invariant from 'invariant';
import isFunction from 'is-function';
import isPlainObject from 'is-plain-object';
import isFunction from './utils/isFunction';
import isPlainObject from './utils/isPlainObject';
import identity from './utils/identity';
import isNil from './utils/isNil';
import isUndefined from './utils/isUndefined';
Expand Down
2 changes: 1 addition & 1 deletion src/handleActions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import reduceReducers from 'reduce-reducers';
import isPlainObject from 'is-plain-object';
import invariant from 'invariant';
import isPlainObject from './utils/isPlainObject';
import isMap from './utils/isMap';
import ownKeys from './utils/ownKeys';
import flattenReducerMap from './utils/flattenReducerMap';
Expand Down
2 changes: 1 addition & 1 deletion src/utils/flattenActionMap.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import isPlainObject from 'is-plain-object';
import isPlainObject from './isPlainObject';
import flattenWhenNode from './flattenWhenNode';

export default flattenWhenNode(isPlainObject);
2 changes: 1 addition & 1 deletion src/utils/flattenReducerMap.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import isPlainObject from 'is-plain-object';
import isPlainObject from './isPlainObject';
import isMap from './isMap';
import hasGeneratorInterface from './hasGeneratorInterface';
import flattenWhenNode from './flattenWhenNode';
Expand Down
1 change: 1 addition & 0 deletions src/utils/isFunction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default value => typeof value === 'function';
10 changes: 10 additions & 0 deletions src/utils/isPlainObject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default value => {
if (typeof value !== 'object' || value === null) return false;

let proto = value;
while (Object.getPrototypeOf(proto) !== null) {
proto = Object.getPrototypeOf(proto);
}

return Object.getPrototypeOf(value) === proto;
};
4 changes: 4 additions & 0 deletions src/utils/isSymbol.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default value =>
typeof value === 'symbol' ||
(typeof value === 'object' &&
Object.prototype.toString.call(value) === '[object Symbol]');
4 changes: 0 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3456,10 +3456,6 @@ is-fullwidth-code-point@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f"

is-function@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-function/-/is-function-1.0.1.tgz#12cfb98b65b57dd3d193a3121f5f6e2f437602b5"

is-generator-fn@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-generator-fn/-/is-generator-fn-1.0.0.tgz#969d49e1bb3329f6bb7f09089be26578b2ddd46a"
Expand Down

0 comments on commit 2802c9a

Please sign in to comment.