/* @flow */

import { Parks } from "trailz";
import { fromJson as parkFromJson, Json as ParkJson } from "./park";

export type Json = Array<ParkJson>;

export function fromJson(json: Json): Parks {
  var parks = [];
  json.map(parkFromJson)
    .forEach((el) => {
      if (el.success === 1) {
        parks.push(el.result);
      }
    });
  return parks;
}

/* @flow */

import { Parks } from "trailz";
import { fromJson as parkFromJson, Json as ParkJson } from "./park";

export type Json = Array<ParkJson>;

export function fromJson(json: Json): Parks {
  return json.map(parkFromJson)
    .filter(result => result.success === 1)
    .map(result => result.result);
}

Replace imperative `forEach` with `map`/`filter`
Replace imperative `forEach` with `map`/`filter`
