Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

turf-meta

Package Overview
Dependencies
Maintainers
7
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

turf-meta

meta and functional programming helpers for turf modules

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12K
decreased by-43.77%
Maintainers
7
Weekly downloads
 
Created
Source

turf-meta

build status

Functional helpers for Turf modules.

Why? Because many turf modules have a similar pattern of running some operation over every coordinate or property object, etc. This module unifies those patterns into one structure and make sure that turf is able to handle unusual structures (geometry roots, null geometries, geometrycollections, and so on). It's also quite fast - it uses monomorphic functions as much as possible and avoids copying data unnecessarily.

coordEach(layer, callback)

Lazily iterate over coordinates in any GeoJSON object, similar to Array.forEach.

  • layer (Object): any GeoJSON object
  • callback (Function): a method that takes (value)
var point = { type: 'Point', coordinates: [0, 0] };
coordEach(point, function(coords) {
  // coords is equal to [0, 0]
});

coordReduce(layer, callback, memo)

Lazily reduce coordinates in any GeoJSON object into a single value, similar to how Array.reduce works. However, in this case we lazily runthe reduction, so an array of all coordinates is unnecessary.

  • layer (Object): any GeoJSON object
  • callback (Function): a method that takes (memo, value) and returns a new memo
  • memo (``): the starting value of memo: can be any type.

propEach(layer, callback)

Lazily iterate over property objects in any GeoJSON object, similar to Array.forEach.

  • layer (Object): any GeoJSON object
  • callback (Function): a method that takes (value)
var point = { type: 'Feature', geometry: null, properties: { foo: 1 } };
propEach(point, function(props) {
  // props is equal to { foo: 1}
});

propReduce(layer, callback, memo)

Lazily reduce properties in any GeoJSON object into a single value, similar to how Array.reduce works. However, in this case we lazily runthe reduction, so an array of all properties is unnecessary.

  • layer (Object): any GeoJSON object
  • callback (Function): a method that takes (memo, coord) and returns a new memo
  • memo (``): the starting value of memo: can be any type.

Keywords

FAQs

Package last updated on 05 Feb 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc