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

sdj-esm

v0.3.4

Published

Self Described JSON - ESM

Downloads

560

Readme

SDJ-ESM

Self-Described JSON - ESM JavaScript/TypeScript Library

What it is:

SDJ-ESM is an ESM library that reads and creates .json files which are a subset of standard json/text files. Unlike standard JSON, sdj files internalize a self-description of the data which it contains. By separating the description from the data; this allows customizable, consistent, and validatable structure.
With a single JSON schema, SDJ files can be used to describe, store, retrieve, and transmit nearly any type of data. The library transforms sdj data between immutable and mutable forms of sdj json/javascript/typescript objects.

What it Does:

  • TypeScript/JavaScript implementation/testing/instantiation of SDJ file type/JSON schema
  • Creates JS data objects and provides a range of methods for data reference of data elements/structure
  • Allows easy hydration/de-hydration between data/class/immutable states
  • Enforce type validation and data structure descriptions
  • Shared ESM module access for Node.js (+18.x) allowing same module to work FE or BE
  • Variable and customizable logging system that verifies/throws errors/logs
  • Extensibility via custom/shared/private Lexicon add-ons

How to get started:

Add the library via npm as a dependency. SDJ-ESM requires 'lodash-es' as a peer dependency.

npm install lodash-es
npm install @types/lodash-es --dev
npm install sdj-esm

-- Still work progress Example SDJ files and SDJ Editor coming soon --

Load in the JSON file:

Since JSON files are allowed by ES modules you can use the following syntax for local/static linked files.

import sdjFile from "./sdjfile.json"

const sdJson = new SdJson(sdjFile);

Or via fetch or another http loader, this would be a simple example:

let sdJson;

fetch("//(some location)/sdjfile.json")
  .then((response) => response.json())
  .then(json => {
    sdJson = new SdJson(json);
  })

Note; the SDJ Library is fault intolerant and will throw errors on invalid files/format. If you do not know if the file is a valid SDJ file, then you will need to wrap the creation in a Try...Catch. Or use standalone genJson(json) function for an error safe version.

About this library, Release Notes, about the SDJ project roadmap, and Copyright info.

Licensed under MPLv2.