Skip to content

remove lodash dependencies #307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
"transform-object-rest-spread"
],
"env": {
"es": {
"plugins": [
"./build/use-lodash-es"
]
},
"commonjs": {
"presets": [
"env"
Expand Down
12 changes: 0 additions & 12 deletions build/use-lodash-es.js

This file was deleted.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@
"xo": "^0.20.3"
},
"dependencies": {
"camelcase": "^5.0.0",
"invariant": "^2.2.1",
"lodash": "^4.13.1",
"lodash-es": "^4.17.4",
"is-function": "^1.0.1",
"is-plain-object": "^2.0.4",
"is-symbol": "^1.0.1",
"lodash.curry": "^4.1.1",
"reduce-reducers": "^0.1.0"
},
"xo": {
Expand Down
10 changes: 5 additions & 5 deletions src/combineActions.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import isString from 'lodash/isString';
import isFunction from 'lodash/isFunction';
import isEmpty from 'lodash/isEmpty';
import toString from 'lodash/toString';
import isSymbol from 'lodash/isSymbol';
import invariant from 'invariant';
import isFunction from 'is-function';
import isSymbol from 'is-symbol';
import isEmpty from './utils/isEmpty';
import toString from './utils/toString';
import isString from './utils/isString';
import { ACTION_TYPE_DELIMITER } from './constants';

function isValidActionType(type) {
Expand Down
6 changes: 3 additions & 3 deletions src/createAction.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import identity from 'lodash/identity';
import isFunction from 'lodash/isFunction';
import isNull from 'lodash/isNull';
import isFunction from 'is-function';
import invariant from 'invariant';
import identity from './utils/identity';
import isNull from './utils/isNull';

export default function createAction(
type,
Expand Down
16 changes: 8 additions & 8 deletions src/createActions.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import identity from 'lodash/identity';
import isPlainObject from 'lodash/isPlainObject';
import isArray from 'lodash/isArray';
import last from 'lodash/last';
import isString from 'lodash/isString';
import isFunction from 'lodash/isFunction';
import isNil from 'lodash/isNil';
import isPlainObject from 'is-plain-object';
import isFunction from 'is-function';
import invariant from 'invariant';
import identity from './utils/identity';
import isArray from './utils/isArray';
import isString from './utils/isString';
import isNil from './utils/isNil';
import getLastElement from './utils/getLastElement';
import camelCase from './utils/camelCase';
import arrayToObject from './utils/arrayToObject';
import flattenActionMap from './utils/flattenActionMap';
Expand All @@ -14,7 +14,7 @@ import createAction from './createAction';
import { DEFAULT_NAMESPACE } from './constants';

export default function createActions(actionMap, ...identityActions) {
const options = isPlainObject(last(identityActions))
const options = isPlainObject(getLastElement(identityActions))
? identityActions.pop()
: {};
invariant(
Expand Down
2 changes: 1 addition & 1 deletion src/createCurriedAction.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import curry from 'lodash/curry';
import curry from 'lodash.curry';
import createAction from './createAction';

export default (type, payloadCreator) =>
Expand Down
16 changes: 8 additions & 8 deletions src/handleAction.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import isFunction from 'lodash/isFunction';
import isPlainObject from 'lodash/isPlainObject';
import identity from 'lodash/identity';
import isNil from 'lodash/isNil';
import isUndefined from 'lodash/isUndefined';
import includes from 'lodash/includes';
import invariant from 'invariant';
import isFunction from 'is-function';
import isPlainObject from 'is-plain-object';
import identity from './utils/identity';
import isNil from './utils/isNil';
import isUndefined from './utils/isUndefined';
import toString from './utils/toString';
import { ACTION_TYPE_DELIMITER } from './constants';

export default function handleAction(type, reducer = identity, defaultState) {
const types = type.toString().split(ACTION_TYPE_DELIMITER);
const types = toString(type).split(ACTION_TYPE_DELIMITER);
invariant(
!isUndefined(defaultState),
`defaultState for reducer handling ${types.join(', ')} should be defined`
Expand All @@ -26,7 +26,7 @@ export default function handleAction(type, reducer = identity, defaultState) {

return (state = defaultState, action) => {
const { type: actionType } = action;
if (!actionType || !includes(types, actionType.toString())) {
if (!actionType || !types.includes(toString(actionType))) {
return state;
}

Expand Down
6 changes: 3 additions & 3 deletions src/handleActions.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import isPlainObject from 'lodash/isPlainObject';
import isMap from 'lodash/isMap';
import reduceReducers from 'reduce-reducers';
import isPlainObject from 'is-plain-object';
import invariant from 'invariant';
import handleAction from './handleAction';
import isMap from './utils/isMap';
import ownKeys from './utils/ownKeys';
import flattenReducerMap from './utils/flattenReducerMap';
import handleAction from './handleAction';

function get(key, x) {
return isMap(x) ? x.get(key) : x[key];
Expand Down
2 changes: 1 addition & 1 deletion src/utils/camelCase.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import camelCase from 'lodash/camelCase';
import camelCase from 'camelcase';

const namespacer = '/';

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 'lodash/isPlainObject';
import isPlainObject from 'is-plain-object';
import flattenWhenNode from './flattenWhenNode';

export default flattenWhenNode(isPlainObject);
4 changes: 2 additions & 2 deletions src/utils/flattenReducerMap.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import isPlainObject from 'lodash/isPlainObject';
import isMap from 'lodash/isMap';
import isPlainObject from 'is-plain-object';
import isMap from './isMap';
import hasGeneratorInterface from './hasGeneratorInterface';
import flattenWhenNode from './flattenWhenNode';

Expand Down
2 changes: 1 addition & 1 deletion src/utils/flattenWhenNode.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import isMap from 'lodash/isMap';
import { DEFAULT_NAMESPACE, ACTION_TYPE_DELIMITER } from '../constants';
import isMap from './isMap';
import ownKeys from './ownKeys';

function get(key, x) {
Expand Down
1 change: 1 addition & 0 deletions src/utils/getLastElement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default array => array[array.length - 1];
1 change: 1 addition & 0 deletions src/utils/identity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default value => value;
1 change: 1 addition & 0 deletions src/utils/isArray.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default value => Array.isArray(value);
1 change: 1 addition & 0 deletions src/utils/isEmpty.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default value => value.length === 0;
1 change: 1 addition & 0 deletions src/utils/isMap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default value => value instanceof Map;
1 change: 1 addition & 0 deletions src/utils/isNil.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default value => value === null || value === undefined;
1 change: 1 addition & 0 deletions src/utils/isNull.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default value => value === null;
1 change: 1 addition & 0 deletions src/utils/isString.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default value => typeof value === 'string';
1 change: 1 addition & 0 deletions src/utils/isUndefined.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default value => value === undefined;
2 changes: 1 addition & 1 deletion src/utils/ownKeys.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import isMap from 'lodash/isMap';
import isMap from './isMap';

export default function ownKeys(object) {
if (isMap(object)) {
Expand Down
1 change: 1 addition & 0 deletions src/utils/toString.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default value => value.toString();
2 changes: 1 addition & 1 deletion src/utils/unflattenActionCreators.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import isEmpty from 'lodash/isEmpty';
import { DEFAULT_NAMESPACE } from '../constants';
import isEmpty from './isEmpty';
import camelCase from './camelCase';

export default function unflattenActionCreators(
Expand Down
16 changes: 12 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,10 @@ camelcase@^4.0.0, camelcase@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd"

camelcase@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.0.0.tgz#03295527d58bd3cd4aa75363f35b2e8d97be2f42"

caniuse-lite@^1.0.30000792:
version "1.0.30000833"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000833.tgz#98e84fcdb4399c6fa0b0fd41490d3217ac7802b4"
Expand Down Expand Up @@ -3362,6 +3366,10 @@ 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 Expand Up @@ -4254,10 +4262,6 @@ locate-path@^2.0.0:
p-locate "^2.0.0"
path-exists "^3.0.0"

lodash-es@^4.17.4:
version "4.17.10"
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.10.tgz#62cd7104cdf5dd87f235a837f0ede0e8e5117e05"

lodash._baseassign@^3.0.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz#8c38a099500f215ad09e59f1722fd0c52bfe0a4e"
Expand Down Expand Up @@ -4301,6 +4305,10 @@ lodash.camelcase@^4.1.1:
version "4.3.0"
resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6"

lodash.curry@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/lodash.curry/-/lodash.curry-4.1.1.tgz#248e36072ede906501d75966200a86dab8b23170"

lodash.get@^4.4.2:
version "4.4.2"
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
Expand Down