import { memoize } from 'lodash' import { simplifyWasm } from '../../lib/simplify-wasm/index.js' import { dataSelector } from './data/index.js' async function numberOfNodes(dataset, tol, highQual) { let data = await dataSelector(dataset) return await simplifyWasm(data, tol, highQual).then(arr => arr.length) } const memNumberOfNodes = memoize(numberOfNodes, (...args) => args.join('|')) export async function simplifyMapper({ dataset, tolRange, highQual }) { let items = tolRange.map(tol => memNumberOfNodes(dataset, tol, highQual)) return await Promise.all(items) }