Skip to content

Commit

Permalink
Merge pull request #18 from openearth/feat/DGDS-96--see-all-locations
Browse files Browse the repository at this point in the history
Feat/dgds 96  see all locations
  • Loading branch information
CindyvdVries authored Apr 26, 2019
2 parents 0b0c559 + 1eb8fde commit 47b53e8
Show file tree
Hide file tree
Showing 188 changed files with 514 additions and 277 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const baseConfig = require('./.eslintrc.js')
const prodRules = {
rules: {
'no-console': 'error',
'no-unused-vars': 'error'
}
'no-unused-vars': 'error',
},
}

module.exports = merge(baseConfig, prodRules)
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,6 @@ dist

# Service worker
sw.*

# Git templates
.gitmessage
116 changes: 0 additions & 116 deletions api-mock/locations/wd.json

This file was deleted.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=1.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=10.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=100.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=101.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=102.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=103.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=104.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=105.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=106.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=107.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=108.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=109.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=11.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=110.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=111.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=112.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=113.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=114.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=115.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=116.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=117.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=118.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=119.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=12.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=120.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=121.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=122.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=123.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=124.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=125.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=126.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=127.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=128.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=129.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=13.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=130.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=131.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=132.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=133.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=134.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=135.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=136.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=137.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=138.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=139.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=14.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=140.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=141.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=142.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=143.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=144.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=145.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=146.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=147.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=148.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=149.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=15.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=150.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=151.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=152.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=153.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=154.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=155.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=156.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=157.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=158.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=159.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=16.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=160.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=161.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=162.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=163.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=164.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=165.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=166.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=167.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=168.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=169.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=17.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=170.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=171.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=172.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=173.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=174.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=175.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=18.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=19.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=2.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=20.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=21.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=22.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=23.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=24.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=25.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=26.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=27.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=28.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=29.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=3.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=30.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=31.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=32.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=33.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=34.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=35.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=36.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=37.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=38.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=39.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=4.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=40.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=41.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=42.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=43.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=44.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=45.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=46.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=47.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=48.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=49.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=5.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=50.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=51.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=52.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=53.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=54.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=55.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=56.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=57.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=58.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=59.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=6.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=60.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=61.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=62.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=63.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=64.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=65.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=66.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=67.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=68.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=69.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=7.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=70.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=71.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=72.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=73.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=74.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=75.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=76.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=77.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=78.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=79.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=8.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=80.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=81.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=82.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=83.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=84.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=85.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=86.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=87.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=88.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=89.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=9.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=90.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=91.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=92.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=93.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=94.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=95.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=96.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=97.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=98.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api-mock/locations/wl-page=99.json

Large diffs are not rendered by default.

116 changes: 0 additions & 116 deletions api-mock/locations/wl.json

This file was deleted.

10 changes: 9 additions & 1 deletion api-mock/redirect-middleware.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
const path = require('path')

module.exports = function(req, res, next) {
if (req.path === '/timeseries') {
res.redirect(`${req.path}/${req.query.locationCode}/${req.query.datasetId}`)
} else if (req.path === '/locations') {
res.redirect(`${req.path}/${req.query.datasetId}`)
const paginated = req.query.page ? `-page=${req.query.page}` : '-page=1'
res.sendFile(
path.join(
__dirname,
`${req.path}/${req.query.datasetId}${paginated}.json`,
),
)
} else {
next()
}
Expand Down
86 changes: 86 additions & 0 deletions lib/load-locations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import times from 'lodash/fp/times'
import pipe from 'lodash/fp/pipe'
import get from 'lodash/fp/get'
import map from 'lodash/fp/map'
import flatten from 'lodash/fp/flatten'
import identity from 'lodash/fp/identity'
import getFromApi from './request/get'

const delay = ms => new Promise(resolve => setTimeout(_ => resolve(), ms))
const plus = a => b => a + b
const plusOne = plus(1)

const load = parameters => _page => {
const page = _page > 1 ? { page: _page } : {}
return getFromApi('locations', { ...parameters, ...page })
}

// prettier-ignore
const batch = size => arr =>
arr.reduce((list, item, index) => {
const listLastIndex = Math.max(list.length - 1, 0)

index % size
? list[listLastIndex].push(item)
: list.push([item])

return list
}, [])

/**
* Calls a callback with the results object from the locations endpoint
*
* @param {Object} parameters Parameters for the get request
* @param {Function} callback The callback to be called with the results
*/
export default async function loadLocations(parameters, callback) {
const loadPage = load(parameters)
const firstPageResponse = await loadPage(1)
const { paging, results } = firstPageResponse
const { totalObjectCount } = paging
const resultLength = results.length
const totalPages = Math.ceil(totalObjectCount / resultLength)
const totalAdditionalPages = totalPages - 1
const handleResponse = pipe([get('results'), callback])

const loadAdditionalPages = ({
offset,
batchSize,
totalPages,
callback,
delayPerBatch,
}) =>
pipe([
times(identity),
map(plusOne),
map(plus(offset)),
batch(batchSize),
map(arr => fn => Promise.all(arr.map(fn))),
loadBatchesSequential({ callback, delayPerBatch }),
])(totalPages)

const loadBatchesSequential = ({ callback, delayPerBatch }) => batches => {
return new Promise(async (resolve, reject) => {
let results = []
for (const batch of batches) {
await delay(delayPerBatch)
const responses = await batch(loadPage)
results = [...results, ...responses.map(callback)]
}
resolve(results)
})
}

const promises = [
Promise.resolve([handleResponse(firstPageResponse)]),
loadAdditionalPages({
callback: handleResponse,
offset: 1,
batchSize: 10,
delayPerBatch: 500,
totalPages: totalAdditionalPages,
}),
]

return Promise.all(promises).then(flatten)
}
25 changes: 25 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import includes from 'lodash/includes'
import get from 'lodash/get'
import curry from 'lodash/curry'
import clone from 'lodash/clone'
import filter from 'lodash/filter'
import matches from 'lodash/matches'
import moment from 'moment'
Expand Down Expand Up @@ -110,3 +111,27 @@ export const mapAsync = curry((fn, items) => Promise.all(items.map(fn)))
export const filterBy = curry((source, collection) =>
filter(collection, matches(source)),
)

/**
* Clones an object and return it frozen
*
* @param {Object} object The object to freeze
*
* @example
* const a = {b: 1}
* freeze(a) // Returns a frozen clone of a
*/
export const freeze = object => Object.freeze(clone(object))

/**
* Executes the then method with the provided callback on a promise
*
* @param {Function} callback The callback to execute once the promise resolves
* @param {Promise} promise The promise to resolve
*
* @example
* const promise = Promise.resolve('foo')
* const log = console.log
* then(log, promise) // "foo"
*/
export const then = curry((callback, promise) => promise.then(callback))
Loading

0 comments on commit 47b53e8

Please sign in to comment.