Skip to content

Commit

Permalink
Remove lodash completely
Browse files Browse the repository at this point in the history
And few chore changes
  • Loading branch information
kamilkisiela committed Feb 6, 2017
1 parent a860eec commit e5ff672
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 14 deletions.
1 change: 0 additions & 1 deletion .gitignore
@@ -1,5 +1,4 @@
build/
coverage/
node_modules/
typings/
npm-debug.log
6 changes: 3 additions & 3 deletions .npmignore
@@ -1,9 +1,9 @@
build/tests/
src/
tests/
typings/
docs/
.travis.yml
global.d.ts
CHANGELOG.md
tsconfig.json
tsconfig.test.json
tslint.json
typings.json
15 changes: 15 additions & 0 deletions .vscode/settings.json
@@ -0,0 +1,15 @@
{
"editor.tabSize": 2,
"editor.rulers": [100],
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"editor.wrappingColumn": 100,
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
"node_modules/**": true,
"build": true,
"coverage": true
},
"typescript.tsdk": "node_modules/typescript/lib"
}
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,8 @@

### vNEXT

- Remove `lodash` completely

### v0.5.0

- Add `result()`, `currentResult()`, `variables`, `setOptions`, `setVariables` [PR #29](https://github.com/kamilkisiela/apollo-client-rxjs/pull/29)
Expand Down
4 changes: 0 additions & 4 deletions package.json
Expand Up @@ -41,17 +41,13 @@
"clean:coverage": "rimraf coverage/*",
"prepublish": "npm run clean && npm run build"
},
"dependencies": {
"lodash": "^4.17.2"
},
"peerDependencies": {
"apollo-client": "^0.7.2 || ^0.8.0",
"rxjs": "^5.0.0-beta.12 || ^5.0.0-rc.1 || ^5.0.0"
},
"devDependencies": {
"@types/chai": "^3.4.32",
"@types/isomorphic-fetch": "0.0.30",
"@types/lodash": "^4.14.34",
"@types/mocha": "^2.2.31",
"@types/node": "^6.0.38",
"@types/sinon": "^1.16.29",
Expand Down
1 change: 0 additions & 1 deletion rollup.config.js
Expand Up @@ -4,7 +4,6 @@ export default {
format: 'umd',
moduleName: 'apollo.rxjs',
globals: {
'lodash': '_',
'apollo-client': 'apollo',
'rxjs/Observable': 'Rx',
'rxjs/Observer': 'Rx',
Expand Down
4 changes: 2 additions & 2 deletions src/rxify.ts
Expand Up @@ -2,7 +2,7 @@ import { ApolloClient, ApolloQueryResult, ObservableQuery } from 'apollo-client'
import { observeOn } from 'rxjs/operator/observeOn';
import { AsyncAction } from 'rxjs/scheduler/AsyncAction';
import { AsyncScheduler } from 'rxjs/scheduler/AsyncScheduler';
import { isFunction } from 'lodash';
import { isObject } from './utils/helpers';

import { createWithObservableVariables } from './utils/variables';
import { RxObservableQuery } from './RxObservableQuery';
Expand All @@ -25,7 +25,7 @@ export function rxify(
}

// ApolloClient.watchQuery
if (isFunction(clientOrWatchQuery)) {
if (isObject(clientOrWatchQuery)) {
return wrapWatchQuery(clientOrWatchQuery);
}

Expand Down
16 changes: 16 additions & 0 deletions src/utils/helpers.ts
@@ -0,0 +1,16 @@
export function isObject(value): boolean {
const type = typeof value;
return value !== null && (type === 'object' || type === 'function');
}

export function omit(source: {}, ...fields: string[]): {} {
let result = {};

if (isObject(source)) {
result = Object.assign(result, source);
fields.forEach(field => delete result[field]);
}

return result;
}

4 changes: 2 additions & 2 deletions src/utils/variables.ts
Expand Up @@ -3,7 +3,7 @@ import { Observer } from 'rxjs/Observer';
import { switchMap } from 'rxjs/operator/switchMap';
import { combineLatest } from 'rxjs/observable/combineLatest';
import { ObservableQuery } from 'apollo-client';
import { assign, omit } from 'lodash';
import { omit } from './helpers';

import { ObservableQueryRef } from './ObservableQueryRef';
import { RxObservableQuery } from '../RxObservableQuery';
Expand All @@ -19,7 +19,7 @@ export function createWithObservableVariables(
const sub = switchMap.call(varObs, (newVariables => {
// prepare variables
const cleanOptions = omit(options, 'variables');
const newOptions = assign(cleanOptions, { variables: newVariables });
const newOptions = Object.assign(cleanOptions, { variables: newVariables });

observableQueryRef.setRef(mapFn(newOptions));

Expand Down
2 changes: 1 addition & 1 deletion tests/rxify.ts
Expand Up @@ -15,7 +15,7 @@ describe('rxify', () => {

it('should throw an error if not a function or ApolloClient', () => {
assert.throw(() => {
rxify({} as any);
rxify(42 as any);
}, 'ApolloClient');
});

Expand Down

0 comments on commit e5ff672

Please sign in to comment.