New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mapbox-file-sniff

Package Overview
Dependencies
Maintainers
66
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mapbox-file-sniff

Detects type of spatial file

  • 0.5.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
66
Created
Source

Mapbox File Sniff Build Status

Node module that returns spatial filetype.

Install

With npm:

npm install -g mapbox-file-sniff

Javascript example

var filesniffer = require('mapbox-file-sniff');
var buffer = fs.readFileSync('path/to/data/file.geojson');

filesniffer.sniff(buffer, function(err, filetype){
	console.log(filetype); // => 'geojson'
});

filesniffer.waft(buffer, function(err, protocol) {
  console.log(protocol); // 'omnivore:'
});

filesniffer.quaff('path/to/data/file.geojson', true, function(err, protocol) {
  console.log(protocol); // => 'geojson'
});

CLI example

$ mapbox-file-type path/to/data/file.geojson
# geojson
$ mapbox-file-protocol path/to/data/file.geojson
# omnivore:
  • buffer: Buffer object of file contents (at least length 300)

API

sniff(buffer, callback)

Returns a string for the following filetypes:

  • Zipped shapefile: zip
  • Unziped shapefile: shp
  • GPX: gpx
  • KML: kml
  • GeoJSON: geojson
  • GeoTIFF: tif
  • Mbtiles: mbtiles
  • TileJSON: tilejson
  • Serialtiles: serialtiles
  • tm2z: tm2z
  • csv: csv

waft(buffer, callback)

Returns a string for the following tilelive protocols:

quaff(filepath, protocol, callback)

A wrapper around waft and sniff that lets you pass in a file path (read as a buffer) and protocol to either return the protocol (waft) or the file type (sniff).

Tests

Full test suite:

npm test

Run an individual test:

tape test/name.of.test.js

Keywords

FAQs

Package last updated on 08 Oct 2016

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