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

progressive-json

v0.5.0

Published

Retrieve JSON progressively

Downloads

4

Readme

Progressive-json ci nycrc config on GitHub

A Javascript library that processes JSON data progressively. Instead of making you wait until the file transfer has completed, it provides you with continual snapshots of the object as data arrives from the remote server:

Growing JSON

Progressive retrieval helps improve preceived load time. This library also lets you download a JSON file incrementally using HTTP range requests, making it practical to host data-driven app on static website providers like GitHub Pages.

Feature set

How it works

Progress-JSON does not actually perform any JSON parsing on its own. All it does is monitoring the byte stream for certain characters:

Special characters

Shown in black are these special characters: right and left curlies, right and left brackets, comma, double quotation mark, and backslash. Shown with a green background are the locations where the JSON structure can be safely cleaved: immediately before a comma and immediately after a curly or square bracket.

Supposed we want to stop parsing after the first item in results. We want to cleave the structure at the spot indicated by the arrow. To make the fragment syntactically correct, we just need to append ] }. We know that because we've been monitoring the appearances of different brackets. To make the next fragment syntactically correctly, we need to prepend it with { "": [.

Actual JSON parsing is done by JSON.parse().

Partial JSON Demonstration

Progressive-json does not make use of every possible cleave points. Only objects specified by you through the partial option will show up partially complete. The project demo site shows you how this is done:

Initial view

Initially, partial is set to "results". That means the root level object and object.results can be partial. If you change partial to "results.#", you'll see the following:

Partial objects

Now items inside the array can be partial too (# in the object path indicates array item). If we want the list of films in the character object to be partial, we would specify "results.#.films". If we want all the lists to be partial, we would specify "results.#.*".

The chunk size is set to a unrealistic small size of 16 for demonstration purpose. Make it bigger (5K ~ 10K) to get a better sense of how an object would be divided in actual usage.

Examples

API reference

Client-side:

Server-side:

Server-side functions are found in "progressive-json/server".