Skip to content

Commit

Permalink
refactor: Use @types/lodash.groupBy (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
carnesen authored and JustinBeckwith committed Oct 20, 2018
1 parent 91c4874 commit 3834348
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/google-cloud-dns/src/zone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {promisifyAll} from '@google-cloud/promisify';
import * as extend from 'extend';
const flatten = require('lodash.flatten');
import * as fs from 'fs';
const groupBy = require('lodash.groupby');
import groupBy = require('lodash.groupby');
import * as is from 'is';
import {teenyRequest} from 'teeny-request';
const zonefile = require('dns-zonefile');
Expand Down Expand Up @@ -427,12 +427,12 @@ class Zone extends ServiceObject {
if (!config || (!config.add && !config.delete)) {
throw new Error('Cannot create a change with no additions or deletions.');
}
const groupByType = (changes: RecordObject[]) => {
changes = groupBy(changes, 'type');
const changesArray: Array<{}> = [];
const groupByType = (recordsIn: RecordObject[]) => {
const recordsByType = groupBy(recordsIn, 'type');
const recordsOut: RecordObject[] = [];
// tslint:disable-next-line:forin
for (const recordType in changes) {
const recordsByName = groupBy(changes[recordType], 'name');
for (const recordType in recordsByType) {
const recordsByName = groupBy(recordsByType[recordType], 'name');
// tslint:disable-next-line:forin
for (const recordName in recordsByName) {
const records = recordsByName[recordName];
Expand All @@ -442,10 +442,10 @@ class Zone extends ServiceObject {
templateRecord.rrdatas =
flatten(records.map((x: RecordObject) => x.rrdatas));
}
changesArray.push(templateRecord);
recordsOut.push(templateRecord);
}
}
return changesArray;
return recordsOut;
};
const body = extend(
{
Expand Down

0 comments on commit 3834348

Please sign in to comment.