npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nyc-bytes

v2.2.0

Published

A node.js module for working with NYC's BYTES of the BIG APPLE datasets.

Downloads

23

Readme

node-nyc-bytes

A node.js module for working with NYC's BYTES of the BIG APPLE datasets.

nyc-bytes automatically downloads, extracts, and exposes a stream of objects from any of the supported datasets. Most datasets return object representations of the records. MapPluto returns GeoJSON Polygons converted from New York - Long Island State Plane Coordinate System (NAD83) to standard Latitude/Longitude (WGS84) for easy mapping use. Requires Node v12 or above.

Currently Supported Datasets

  • PLUTO
  • MapPluto (requires ogr2ogr)
  • NYC Zoning Tax Lot Database
  • PAD (Property Address Directory)

Dependencies

This library uses 7z to unzip datasets. It must be installed and the command 7za must be available in your environment's PATH for it to work.

Usage

npm install nyc-bytes

Each dataset is exposed as a singleton object that must be initialized. This ensures that the underlying files are downloaded, extracted, and ready for use. Initializing the dataset returns a Promise that returns once the dataset has finished initializing.

const Bytes = require('nyc-bytes');

const dataset = Bytes.Pluto;
// or const dataset = Bytes.MapPluto;
// or const dataset = Bytes.ZoningTaxLot;
// or const dataset = Bytes.PAD;
dataset.init().then(() => {
  console.log('Dataset ready.');
  const stream = dataset.stream();
  // do something with stream
}).catch((err) => {
  console.error(err);
});

dataset.stream([options])

The dataset's underlying data is accessible like any other standard node stream.

const stream = dataset.stream();
stream.on('readable', () => {
  const record = stream.read();
  // do something with the record
});
stream.on('end', () => {
  console.log('finished');
});

You can also use the stream in flowing mode by attaching a data event listener.

const stream = dataset.stream();
stream.on('data', (record) => {
  // do something with the record
});
stream.on('end', () => {
  console.log('finished');
});

Lastly, you can also pipe the stream like you would any other readable stream.

const stream = dataset.stream();
const writableStream = somehowGetWritableStream();
stream.pipe(writableStream);

options

  • table - default: 'BOTH' - Which table ('BBL'|'ADR') to return (only applicable to PAD dataset)
  • sanitize - default: true - Removes extra whitespaces. (only applicable to PAD dataset) Ex.
"EAST   45 STREET               "

becomes

"EAST 45 STREET"

Todo

  • Add datasets - open an issue to suggest a dataset you'd like to see.