From ab221a465be185dca9b457ae3eaf938b400e4b5c Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Wed, 8 Apr 2015 16:32:46 +0200 Subject: [PATCH] Use lodash.foreach instead of native implementation. --- packages/xo-collection/package.json | 2 +- packages/xo-collection/src/index.js | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/xo-collection/package.json b/packages/xo-collection/package.json index c80b2adb9..a677e4c4c 100644 --- a/packages/xo-collection/package.json +++ b/packages/xo-collection/package.json @@ -22,6 +22,7 @@ ], "dependencies": { "babel-runtime": "^5", + "lodash.foreach": "^3.0.2", "make-error": "^0.3.0" }, "devDependencies": { @@ -29,7 +30,6 @@ "chai": "*", "dirty-chai": "^1.2.0", "event-to-promise": "^0.3.2", - "lodash.foreach": "^3.0.2", "mocha": "*", "sinon": "^1.14.1", "standard": "*" diff --git a/packages/xo-collection/src/index.js b/packages/xo-collection/src/index.js index f7ce7e225..b04b32478 100644 --- a/packages/xo-collection/src/index.js +++ b/packages/xo-collection/src/index.js @@ -1,5 +1,6 @@ -import {EventEmitter} from 'events' +import forEach from 'lodash.foreach' import makeError from 'make-error' +import {EventEmitter} from 'events' export const BufferAlreadyFlushed = makeError('BufferAlreadyFlushed') export const DuplicateItem = makeError('DuplicateItem') @@ -50,7 +51,7 @@ export default class Collection extends EventEmitter { data[this._buffer[key]][key] = this._items[key] } - ['add', 'update', 'remove'].forEach(action => { + forEach(['add', 'update', 'remove'], action => { const items = data[action] if (isNotEmpty(items)) { @@ -194,11 +195,11 @@ export default class Collection extends EventEmitter { } clear () { - for (let key in this._items) { + forEach(this._items, key => { delete this._items[key] this._size-- this._touch('remove', key) - } + }) return this }