Skip to content
This repository has been archived by the owner on Feb 20, 2022. It is now read-only.

Commit

Permalink
⚡ Use lodash.find instead of lodash
Browse files Browse the repository at this point in the history
80kb module download instead of 4.8MB #18

Signed-off-by: Thibault Maekelbergh <thibault.maekelbergh@student.howest.be>
  • Loading branch information
Thibault Maekelbergh committed Nov 21, 2016
1 parent a74ec2f commit 32d4715
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"presets": [
["es2015", {"loose": true, "modules": false}]
]
},
"test": {
"presets": ["es2015"],
"plugins": ["transform-async-to-generator"]
}
}
}
23 changes: 23 additions & 0 deletions __mocks__/composedFetch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const statusResult = {
name: `delivered`,
status: `active`,
label: {
main: `pickedUp`,
detail: `inPostPoint`,
},
knownProcessStep: `PICKED_UP_IN_POST_POINT_INTERNATIONAL`,
};

const composedFetch = id => {
return new Promise((resolve, reject) => {
process.nextTick(() =>
statusResult[status] === `active`
? resolve(statusResult)
: reject({
error: `no active step found for ${id}`,
})
);
});
};

export default composedFetch;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@
},
"dependencies": {
"axios": "^0.15.2",
"lodash": "^4.17.2"
"lodash.find": "^4.6.0"
}
}
3 changes: 0 additions & 3 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ const plugins = [
}),
commonjs({
include: `node_modules/**`,
namedExports: {
'node_modules/lodash/lodash.js': [`find`],
},
}),
bundleSize(),
];
Expand Down
2 changes: 1 addition & 1 deletion src/lib/methods/events.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { find } from 'lodash';
import find from 'lodash.find';
import composedFetch from '../composedFetch';

export const droppedOffBySender = id => composedFetch(id)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/methods/getStatus.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { find } from 'lodash';
import find from 'lodash.find';
import composedFetch from '../composedFetch';

export default id => composedFetch(id)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/methods/postalPoint.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { find } from 'lodash';
import find from 'lodash.find';
import composedFetch from '../composedFetch';

export const sourcePostalPoint = id => {
Expand Down
6 changes: 5 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2356,6 +2356,10 @@ lodash.defaults@^3.1.2:
lodash.assign "^3.0.0"
lodash.restparam "^3.0.0"

lodash.find@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.find/-/lodash.find-4.6.0.tgz#cb0704d47ab71789ffa0de8b97dd926fb88b13b1"

lodash.isarguments@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a"
Expand Down Expand Up @@ -2384,7 +2388,7 @@ lodash@4.16.6:
version "4.16.6"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.16.6.tgz#d22c9ac660288f3843e16ba7d2b5d06cca27d777"

lodash@^4.0.0, lodash@^4.17.2, lodash@^4.2.0, lodash@^4.3.0:
lodash@^4.0.0, lodash@^4.2.0, lodash@^4.3.0:
version "4.17.2"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.2.tgz#34a3055babe04ce42467b607d700072c7ff6bf42"

Expand Down

0 comments on commit 32d4715

Please sign in to comment.