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

analyst.js

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

analyst.js

Lightweight client library for making requests to Analyst Server

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-88.89%
Maintainers
1
Weekly downloads
 
Created
Source

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

parametertypedescription
LLeafletPass in an instance of Leaflet so that it doesn't need to be packaged as a dependency.
optionsObjectOptions object.
[options.baseUrl]Stringoptional: The base url, will set the tile and api urls if they are left unset
[options.apiUrl]Stringoptional:
[options.tileUrl]Stringoptional:
[options.connectivityType]Stringoptional:
[options.timeLimit]Numberoptional: Defaults to 3600
[options.showPoints]Booleanoptional: Defaults to false
[options.showIso]Booleanoptional: Defaults to true
[options.requestOptions]Objectoptional: Pass in default request options to be used.
[options.tileLayerOptions]Objectoptional: 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

parametertypedescription
keyStringKey for accessing the single point layer tiles.
[comparisonKey]Stringoptional: 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

parametertypedescription
pointLatLng
graphIdStringGraph ID to use for this request.
[shapefileId]Stringoptional: Shapefile ID to be used with this request, can be omitted for a vector request.
[options]Objectoptional: 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

parametertypedescription
pointLatLng
optionsObject
comparisonOptionsObject

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

parametertypedescription
clientCredentialsString

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

parametertypedescription
keyStringYour API key
secretStringYour API secret
refreshbooleanif 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

Keywords

FAQs

Package last updated on 26 Oct 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