Skip to content
This repository has been archived by the owner on Mar 7, 2018. It is now read-only.

Commit

Permalink
Extract makeMap and makeSet to utils
Browse files Browse the repository at this point in the history
  • Loading branch information
c-w committed Jul 5, 2017
1 parent f4566be commit 8d4e1e3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
19 changes: 2 additions & 17 deletions src/resolvers-cassandra/Tiles/queries.js
@@ -1,26 +1,11 @@
'use strict';

const Promise = require('promise');
const geotile = require('geotile');
const cassandraConnector = require('../../clients/cassandra/CassandraConnector');
const featureServiceClient = require('../../clients/locations/FeatureServiceClient');
const withRunTime = require('../shared').withRunTime;
const geotile = require('geotile');

function makeMap(iterable, keyFunc, valueFunc) {
const map = {};
iterable.forEach(item => {
const key = keyFunc(item);
const value = valueFunc(item);
map[key] = value;
});
return map;
}

function makeSet(iterable, func) {
const set = new Set();
iterable.forEach(item => set.add(func(item)));
return set;
}
const { makeMap, makeSet } = require('../../utils/collections');

function makeDefaultFilters(args) {
let params = [];
Expand Down
20 changes: 20 additions & 0 deletions src/utils/collections.js
@@ -0,0 +1,20 @@
function makeMap(iterable, keyFunc, valueFunc) {
const map = {};
iterable.forEach(item => {
const key = keyFunc(item);
const value = valueFunc(item);
map[key] = value;
});
return map;
}

function makeSet(iterable, func) {
const set = new Set();
iterable.forEach(item => set.add(func(item)));
return set;
}

module.exports = {
makeMap: makeMap,
makeSet: makeSet
};

0 comments on commit 8d4e1e3

Please sign in to comment.