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

@fnet/object-from-schema

v0.1.3

Published

The **@fnet/object-from-schema** project is a functional utility designed to generate a JSON object based on the parameters defined in a provided JSON schema. The utility, interestingly, supports custom attributes as well, like `subtype`, which can be use

Downloads

10

Readme

@fnet/object-from-schema

The @fnet/object-from-schema project is a functional utility designed to generate a JSON object based on the parameters defined in a provided JSON schema. The utility, interestingly, supports custom attributes as well, like subtype, which can be used for enhanced input types.

Functionality

The main function of the project takes a JSON schema as an argument and then prompts the user to input the values based on the schema. The schema can either be a direct object or a URL/local file path, which is then loaded parsed accordingly. The user prompt supports enhanced input types where users can input their responses. If the schema includes required fields, these are highlighted for the user. It also has provisions for setting default values and indicates optional fields where input is not mandatory.

Apart from the main functionality, @fnet/object-from-schema includes a few other extensions.

Object Inputs

If the value type in the JSON schema is recognized as an object, it is sent back to run through the collectInputsForSchema function again. This allows for the generation of nested objects.

SubTypes

A specific attribute subtype is checked when reading each property of the object. If this is set to 'password', the input type in the prompt for that field will become a password field, which conceals characters input by the user for that particular property.

Process OneOf

An intermediary function processes oneOf instances in the schema. If a schema option from oneOf is selected, it's treated as the new schema, and its required fields and other properties are added to the generated object.

Load Schema

This function is used to check whether the schema provided is a direct object, URL, or a local file path. If it is an object, it gets returned outright. If it is a URL or file path, the content from the source is loaded, parsed into a schema, and then returned. However, if the type of source is neither an object nor a string (URL/file-path), an error is thrown.

In summary, @fnet/object-from-schema is a comprehensive JSON object generator utility that is capable of accepting a variety of schemas, supports custom attributes for enhanced input types, and actively prompts user input. This project simplifies the process of generating JSON objects based on pre-defined schemas, saving time and ensuring precision.