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 🙏

© 2026 – Pkg Stats / Ryan Hefner

analyst.js

v0.1.2

Published

Lightweight client library for making requests to Analyst Server

Readme

analyst.js

Lightweight client library for making requests to Analyst Server

Analyst(L, options, [options.baseUrl], [options.apiUrl], [options.tileUrl], [options.connectivityType], [options.timeLimit], [options.showPoints], [options.showIso], [options.requestOptions], [options.tileLayerOptions])

Create an instance of Analyst.js for use with single point requests.

Parameters

| parameter | type | description | | ---------------------------- | ------- | -------------------------------------------------------------------------------------- | | L | Leaflet | Pass in an instance of Leaflet so that it doesn't need to be packaged as a dependency. | | options | Object | Options object. | | [options.baseUrl] | String | optional: The base url, will set the tile and api urls if they are left unset | | [options.apiUrl] | String | optional: | | [options.tileUrl] | String | optional: | | [options.connectivityType] | String | optional: | | [options.timeLimit] | Number | optional: Defaults to 3600 | | [options.showPoints] | Boolean | optional: Defaults to false | | [options.showIso] | Boolean | optional: Defaults to true | | [options.requestOptions] | Object | optional: Pass in default request options to be used. | | [options.tileLayerOptions] | Object | optional: Pass in default tileLayerOptions to use. |

Example

const analyst = new Analyst(window.L, {
  apiUrl: 'http://localhost:3000/api',
  tileUrl: 'http://localhost:4000/tile',
  baseUrl: 'http://localhost:3000'
})

updateSinglePointLayer(key, [comparisonKey])

Update/create the single point layer for this Analyst.js instance.

Parameters

| parameter | type | description | | ----------------- | ------ | ------------------------------------------------- | | key | String | Key for accessing the single point layer tiles. | | [comparisonKey] | String | optional: Key for the layer to compare against. |

Example

analyst.updateSinglePointLayer(key).redraw()

Returns TileLayer, A Leaflet tile layer that pulls in the generated single point tiles.

shapefiles

Get all of the available shapefiles.

Example

analyst.shapefiles().then(function (shapefiles) {
  console.log(shapefiles)
})

Returns Promise, Resolves with a JSON list of shapefiles.

singlePointRequest(point, graphId, [shapefileId], [options])

Run a single point request and generate a tile layer.

Parameters

| parameter | type | description | | --------------- | ------ | ------------------------------------------------------------------------------------------- | | point | LatLng | | | graphId | String | Graph ID to use for this request. | | [shapefileId] | String | optional: Shapefile ID to be used with this request, can be omitted for a vector request. | | [options] | Object | optional: Options object. |

Example

analyst
  .singlePointRequest(marker.getLatLng())
  .then(function (data) {
    analyst.updateSinglePointLayer(data.key)
  })

Returns Promise, Resolves with an object containing the results data.

singlePointComparison(point, options, comparisonOptions)

Compare two scenarios.

Parameters

| parameter | type | description | | ------------------- | ------ | ----------- | | point | LatLng | | | options | Object | | | comparisonOptions | Object | |

Example

analyst
  .singlePointComparison(marker.getLatLng(), { graphId: 'graph1' }, { graphId: 'graph2' })
  .then(([res, cres]) => {
    analyst.updateSinglePointLayer(res.key, cres.key)
  })

Returns Promise, Resolves with an array containing [results, comparisonResults]

setClientCredentials(clientCredentials)

Set the client credentials for this analyst.js instance

Parameters

| parameter | type | description | | ------------------- | ------ | ----------- | | clientCredentials | String | |

obtainClientCredentials(key, secret, refresh)

Get client credentials for this instance, optionally keeping them up-to-date automatically. Note that using this function on the client side requires your API key and secret to be sent to the client, which is non-ideal; a better pattern would be to keep the API key/secret on the server and only retrieve client credentials there, and then deliver only the client credentials to the client. Client credentials have a limited time to live, so they are less sensitive than API keys.

Parameters

| parameter | type | description | | --------- | ------- | ----------------------------------------------------------------------------------------- | | key | String | Your API key | | secret | String | Your API secret | | refresh | boolean | if true (default), automatically update client credentials when they are about to expire. |

Returns h, client credentials. They will also be set as the client credentials for this analyst instance.

Installation

Requires nodejs.

$ npm install analyst.js

Tests

$ npm test