Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework @turf/random #994

Closed
DenisCarriere opened this issue Oct 3, 2017 · 2 comments
Closed

Rework @turf/random #994

DenisCarriere opened this issue Oct 3, 2017 · 2 comments

Comments

@DenisCarriere
Copy link
Member

DenisCarriere commented Oct 3, 2017

Rework @turf/random

Looking at the @turf/random module and it seems like it could use a revamp for the next major release (v5.0).

Reasons for rework

  • geojson-random dependency doesn't include ES modules
  • Make it behave exactly like geojson-random.
  • Extend lineString & Position support.
  • Each random method will have it's own dedicated JSDocs (at the moment it's all grouped and causes confusion).

Before

import random from '@turf/random';

const bbox = [-70, 40, -60, 60]
const points = random('point', 100, {bbox})

Proposed

import * as random from '@turf/random';

const bbox = [-70, 40, -60, 60]
const points = random.point(100, {bbox})

Alternate ES module import

This allows tree shaking to exclude any source code which isn't relevant to the random.point method.

import { point as randomPoint } from '@turf/random';

const bbox = [-70, 40, -60, 60]
const points = randomPoint(100, {bbox})
@DenisCarriere
Copy link
Member Author

DenisCarriere commented Oct 3, 2017

⚠️ Change to proposal

To prevent any method name duplication from @turf/helpers (point, lineString, polygon).

Going to change the method names to randomPoint, randomLineString & randomPolygon that way it's easier to expose them in @turf/turf without manually defining them with as.

import { randomPoint } from '@turf/random';

const bbox = [-70, 40, -60, 60]
const points = randomPoint(100, {bbox})

@stebogit
Copy link
Collaborator

stebogit commented Nov 8, 2017

Reworked via #995

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants