diff --git a/package-lock.json b/package-lock.json index 86fa0de..a1d4fd1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1933,12 +1933,6 @@ "@types/babel-types": "*" } }, - "@types/bluebird": { - "version": "3.5.29", - "resolved": "https://registry.npmjs.org/@types/bluebird/-/bluebird-3.5.29.tgz", - "integrity": "sha512-kmVtnxTuUuhCET669irqQmPAez4KFnFVKvpleVRyfC3g+SHD1hIkFZcWLim9BVcwUBLO59o8VZE4yGCmTif8Yw==", - "dev": true - }, "@types/body-parser": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.1.tgz", @@ -2076,6 +2070,12 @@ "integrity": "sha512-Il2DtDVRGDcqjDtE+rF8iqg1CArehSK84HZJCT7AMITlyXRBpuPhqGLDQMowraqqu1coEaimg4ZOqggt6L6L+A==", "dev": true }, + "@types/lodash": { + "version": "4.14.147", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.147.tgz", + "integrity": "sha512-+0zY1Axql6ru5T85Rh6aR6Zr0xT7c0USLqsHv01b3ID//dOrV3OvpXJGjm69+4QpxoZ0oMNEfmW1ltwXe2WVzQ==", + "dev": true + }, "@types/mime": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@types/mime/-/mime-2.0.1.tgz", @@ -2266,12 +2266,6 @@ "@types/superagent": "*" } }, - "@types/underscore": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/@types/underscore/-/underscore-1.9.3.tgz", - "integrity": "sha512-SwbHKB2DPIDlvYqtK5O+0LFtZAyrUSw4c0q+HWwmH1Ve3KMQ0/5PlV3RX97+3dP7yMrnNQ8/bCWWvQpPl03Mug==", - "dev": true - }, "@types/uuid": { "version": "3.4.6", "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-3.4.6.tgz", @@ -3396,11 +3390,6 @@ "inherits": "~2.0.0" } }, - "bluebird": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.3.tgz", - "integrity": "sha512-/qKPUQlaW1OyR51WeCPBvRnAlnZFUJkCSG5HzGnuIqhgyJtF+T94lFnn33eiazjRm2LAHVy2guNnaq48X9SJuw==" - }, "bn.js": { "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", @@ -12654,11 +12643,6 @@ } } }, - "seamless-immutable": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/seamless-immutable/-/seamless-immutable-7.1.4.tgz", - "integrity": "sha512-XiUO1QP4ki4E2PHegiGAlu6r82o5A+6tRh7IkGGTVg/h+UoeX4nFBeCGPOhb4CYjvkqsfm/TUtvOMYC1xmV30A==" - }, "semver": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", @@ -14029,11 +14013,6 @@ "debug": "^2.2.0" } }, - "underscore": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", - "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" - }, "unicode-canonical-property-names-ecmascript": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz", diff --git a/package.json b/package.json index addc991..995fde1 100644 --- a/package.json +++ b/package.json @@ -51,11 +51,9 @@ "author": "Jerko Steiner", "license": "MIT", "dependencies": { - "bluebird": "^3.3.4", "classnames": "^2.2.5", "config": "^3.0.0", "express": "^4.13.3", - "prop-types": "^15.5.10", "pug": "^2.0.0-rc.2", "react": "^16.6.3", "react-dom": "^16.6.3", @@ -64,11 +62,9 @@ "redux-logger": "^3.0.6", "redux-promise-middleware": "^5.1.1", "redux-thunk": "^2.2.0", - "seamless-immutable": "^7.1.2", "simple-peer": "^9.1.2", "socket.io": "^2.2.0", "socket.io-client": "^2.2.0", - "underscore": "^1.8.3", "uuid": "^3.3.2" }, "devDependencies": { @@ -78,12 +74,12 @@ "@babel/polyfill": "^7.4.4", "@babel/preset-env": "^7.5.0", "@babel/preset-react": "^7.0.0", - "@types/bluebird": "^3.5.29", "@types/classnames": "^2.2.9", "@types/config": "0.0.36", "@types/debug": "^4.1.5", "@types/express": "^4.17.2", "@types/jest": "^24.0.23", + "@types/lodash": "^4.14.147", "@types/node": "^12.12.7", "@types/react": "^16.9.11", "@types/react-dom": "^16.9.4", @@ -97,7 +93,6 @@ "@types/socket.io": "^2.1.4", "@types/socket.io-client": "^1.4.32", "@types/supertest": "^2.0.8", - "@types/underscore": "^1.9.3", "@types/uuid": "^3.4.6", "@typescript-eslint/eslint-plugin": "^2.7.0", "@typescript-eslint/parser": "^2.7.0", @@ -116,6 +111,7 @@ "eslint-plugin-standard": "^4.0.0", "jest": "^24.9.0", "jest-cli": "^24.8.0", + "lodash": "^4.17.15", "node-sass": "^4.13.0", "nodemon": "^1.18.8", "react-transition-group": "^2.5.1", diff --git a/src/client/actions/NotifyActions.ts b/src/client/actions/NotifyActions.ts index fb9d14f..3b10653 100644 --- a/src/client/actions/NotifyActions.ts +++ b/src/client/actions/NotifyActions.ts @@ -1,6 +1,6 @@ +import uniqueId from 'lodash/uniqueId' +import { Dispatch } from 'redux' import * as constants from '../constants' -import { Dispatch } from 'redux' -import _ from 'underscore' import { ThunkResult } from '../store' const TIMEOUT = 5000 @@ -16,7 +16,7 @@ export type NotifyType = 'info' | 'warning' | 'error' function notify(dispatch: Dispatch, type: NotifyType, args: string[]) { const string = args[0] || '' const message = format(string, Array.prototype.slice.call(args, 1)) - const id = _.uniqueId('notification') + const id = uniqueId('notification') const payload: Notification = { id, type, message } setTimeout(() => { diff --git a/src/client/actions/PeerActions.ts b/src/client/actions/PeerActions.ts index 70539ba..502dcbb 100644 --- a/src/client/actions/PeerActions.ts +++ b/src/client/actions/PeerActions.ts @@ -3,7 +3,7 @@ import * as NotifyActions from '../actions/NotifyActions' import * as StreamActions from '../actions/StreamActions' import * as constants from '../constants' import Peer from 'simple-peer' -import _ from 'underscore' +import forEach from 'lodash/forEach' import _debug from 'debug' import { play, iceServers } from '../window' import { Dispatch, GetState } from '../store' @@ -215,7 +215,7 @@ export const sendMessage = (message: Message) => const { peers } = getState() debug('Sending message type: %s to %s peers.', message.type, Object.keys(peers).length) - _.each(peers, (peer, userId) => { + forEach(peers, (peer, userId) => { switch (message.type) { case 'file': dispatch(ChatActions.addMessage({ diff --git a/src/client/actions/SocketActions.ts b/src/client/actions/SocketActions.ts index 7fb67c4..f164465 100644 --- a/src/client/actions/SocketActions.ts +++ b/src/client/actions/SocketActions.ts @@ -1,7 +1,7 @@ import * as NotifyActions from '../actions/NotifyActions' import * as PeerActions from '../actions/PeerActions' import * as constants from '../constants' -import _ from 'underscore' +import keyBy from 'lodash/keyBy' import _debug from 'debug' import { SignalData } from 'simple-peer' import { Dispatch, GetState } from '../store' @@ -62,8 +62,8 @@ class SocketHandler { stream, })(dispatch, getState)) - const newUsersMap = _.indexBy(users, 'id') - _.keys(peers) + const newUsersMap = keyBy(users, 'id') + Object.keys(peers) .filter(id => !newUsersMap[id]) .forEach(id => peers[id].destroy()) } diff --git a/src/client/components/App.tsx b/src/client/components/App.tsx index a80e7d6..ae32a06 100644 --- a/src/client/components/App.tsx +++ b/src/client/components/App.tsx @@ -1,6 +1,6 @@ +import map from 'lodash/map' import React from 'react' import Peer from 'simple-peer' -import _ from 'underscore' import { Message } from '../actions/ChatActions' import { Alert, Notification } from '../actions/NotifyActions' import { TextMessage } from '../actions/PeerActions' @@ -99,7 +99,7 @@ export default class App extends React.PureComponent { mirrored /> - {_.map(peers, (_, userId) => ( + {map(peers, (_, userId) => (