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

stac-js

Package Overview
Dependencies
Maintainers
0
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stac-js

JS drop-in classes with utilities for STAC

  • 0.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
0
Weekly downloads
 
Created
Source

stac-js

Simple drop-in JavaScript classes with utilities for working with data from STAC objects in a read-only manner. It is basically just a wrapper/facade on top of a single STAC object deserialized from JSON. It doesn't handle relationships between files, actually this library is completely unaware of any files and doesn't even handle loading them from HTTP or a file system. As such the library works in principle both in the browser and in NodeJS. This library won't help you if you want to create or update a STAC catalog (like PySTAC would).

  • Package version: 0.1.4
  • STAC versions: >= 0.6.0 (through stac-migrate).
  • Documentation: https://m-mohr.github.io/stac-js/latest/

Usage

Automatically instantiate the right class through the factory:

import create from 'stac-js';
// const create = import('stac-js'); // Import for NodeJS

const stac = {
  stac_version: "1.1.0",
  type: "Collection",
  id: "example",
  // ...
};
const obj = create(stac); // Migrates data to the latest version

Directly instantiate Asset, Catalog, Collection, CollectionCollection, Item or ItemCollection through the class constructors:

import { Collection } from 'stac-js'; // or Catalog or Item
// const { Collection } = import('stac-js'); // Import for NodeJS

const stac = {
  stac_version: "1.1.0",
  type: "Collection",
  id: "example",
  // ...
};
const obj = new Collection(stac); // Does NOT migrate to the latest version

You can then use the object, check whether it's STAC and call some methods, for example:

import { STAC } from 'stac-js';
// const { STAC } = import('stac-js'); // Import for NodeJS

if (obj instanceof STAC) {
  obj.isCollection();
  obj.getBoundingBox();
  obj.getTemporalExtent();
  obj.getThumbnails();
  obj.getItemLinks();
  obj.getDefaultGeoTIFF();
  // ...
}

The classes are drop-in replacements, which means you can still access the objects as before:

console.log(stac.id === obj.id);

To better visualize the available classes (blue), interfaces (yellow) and the inheritance, please consult the simplified class diagram below:

Class diagram for stac-js

Note: This library is purely written based on ES6 classes and doesn't do any transpiling etc. If you use this library, your environment either needs to support ES6 classes or you need to take measures yourself to transpile back to whatever is supported by your environment (e.g. through Babel for the browser).

Keywords

FAQs

Package last updated on 27 Jan 2025

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