Skip to content

Commit

Permalink
fix(lodash): individual packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthieu Beteille committed Oct 20, 2017
1 parent 23ce741 commit 241b461
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
27 changes: 17 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"main": "dist/redux-data-fx.umd.js",
"module": "dist/redux-data-fx.es5.js",
"typings": "dist/types/redux-data-fx.d.ts",
"files": ["dist"],
"files": [
"dist"
],
"author": "Matthieu Béteille <[email protected]>",
"repository": {
"type": "git",
Expand All @@ -19,17 +21,15 @@
"scripts": {
"lint": "tslint -t codeFrame 'src/**/*.ts' 'test/**/*.ts'",
"prebuild": "rimraf dist",
"build":
"tsc && rollup -c rollup.config.ts && rimraf compiled && typedoc --out dist/docs --target es6 --theme minimal src",
"build": "tsc && rollup -c rollup.config.ts && rimraf compiled && typedoc --out dist/docs --target es6 --theme minimal src",
"start": "tsc -w & rollup -c rollup.config.ts -w",
"test": "jest",
"test:watch": "jest --watch",
"test:prod": "npm run lint && npm run test -- --coverage --no-cache",
"deploy-docs": "ts-node tools/gh-pages-publish",
"report-coverage": "cat ./coverage/lcov.info | coveralls",
"commit": "git-cz",
"semantic-release":
"semantic-release pre && npm publish && semantic-release post",
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"semantic-release-prepare": "ts-node tools/semantic-release-prepare",
"precommit": "lint-staged",
"prepush": "npm run test:prod && npm run build",
Expand All @@ -47,17 +47,23 @@
},
"validate-commit-msg": {
"types": "conventional-commit-types",
"helpMessage":
"Use \"npm run commit\" instead, we use conventional-changelog format :) (https://github.com/commitizen/cz-cli)"
"helpMessage": "Use \"npm run commit\" instead, we use conventional-changelog format :) (https://github.com/commitizen/cz-cli)"
}
},
"jest": {
"transform": {
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": ["ts", "tsx", "js"],
"coveragePathIgnorePatterns": ["/node_modules/", "/test/"],
"moduleFileExtensions": [
"ts",
"tsx",
"js"
],
"coveragePathIgnorePatterns": [
"/node_modules/",
"/test/"
],
"coverageThreshold": {
"global": {
"branches": 80,
Expand Down Expand Up @@ -101,7 +107,8 @@
"redux": "^3.7.2"
},
"dependencies": {
"@types/lodash.foreach": "^4.5.3",
"babel-polyfill": "^6.26.0",
"lodash": "^4.17.4"
"lodash.foreach": "^4.5.0"
}
}
4 changes: 1 addition & 3 deletions src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { isObject } from 'lodash'

export interface StateWithFx {
[key: string]: any
state: any
_fx: { [key: string]: any }
}

export function hasFX(s: any): s is StateWithFx {
return s && isObject(s._fx) && '_fx' in s && 'state' in s
return s && typeof s._fx === 'object' && '_fx' in s && 'state' in s
}
2 changes: 1 addition & 1 deletion src/redux-data-fx.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'babel-polyfill'
import { forEach, isObject } from 'lodash'
import forEach from 'lodash.foreach'
import { hasFX } from './helpers'
import {
StoreCreator,
Expand Down
8 changes: 4 additions & 4 deletions test/redux-data-fx.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { reduxDataFX, EnhancedStore } from '../src/redux-data-fx'
import { createStore, applyMiddleware } from 'redux'
import _ from 'lodash'
import forEach from 'lodash.foreach'

jest.setTimeout(1000)

Expand Down Expand Up @@ -98,7 +98,7 @@ function reducer(state: State = initialState, action: Action) {
const store = createStore(reducer, initialState, reduxDataFX)

store.registerFX('global', function(toStore, getState) {
_.forEach(toStore, (val, key) => (window[key] = val))
forEach(toStore, (val, key) => (window[key] = val))
})

store.registerFX('timeout', function(params, getState, dispatch) {
Expand All @@ -108,8 +108,8 @@ store.registerFX('timeout', function(params, getState, dispatch) {
})

store.registerFX('localStorage', function(params, getState, dispatch) {
if (params.set && _.isObject(params.set)) {
_.each(params.set, (value, key) => {
if (params.set) {
forEach(params.set, (value, key) => {
localStorage.setItem(key, value)
})
}
Expand Down

0 comments on commit 241b461

Please sign in to comment.