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

strfy-js

v3.0.1

Published

kinda like JSON.stringify, but for generating JSON that is meant for JS objects

Downloads

1,124

Readme

strfy-js

Stringify JSON as JavaScript 🌴

strfy-js is a custom JavaScript serialization library designed to extend the capabilities of JSON serialization. This library is particularly useful for generating JavaScript objects directly from JSON, enabling developers to work with JSON data more effectively within JavaScript environments.

Features

  • 🛠️ Extended Serialization: Converts JSON to JavaScript objects, supporting output, such as properties without quotes, not typically handled by standard JSON.

  • ⚙️ Customizable: Offers various options to customize the output, making it suitable for different use cases. Tailor the serialization process to meet your specific requirements.

  • ⚡ Lightweight and Fast: Optimized for performance, making it a practical choice for applications that require fast serialization of large amounts of data. Ideal for handling high-load environments efficiently.

Installation

To install strfy-js, use npm or yarn:

npm install strfy-js
# or
yarn add strfy-js

Usage

Import jsStringify from strfy-js and use it to serialize JavaScript objects:

import { jsStringify } from 'strfy-js';

const obj = {
  "$schema": "schema.json",
  "chain_id": "cosmos-1",
  "logo_URIs": {
    "png": "cosmos.png"
  },
  "binaries": {
    "linux/amd64": "cosmos-bin.tar.gz"
  }
};

const options = {
    space: 2,
    camelCase: true,
    quotes: 'single'
};

console.log(jsStringify(obj, options));
// OUTPUT:
{
  $schema: 'schema.json',
  chainId: 'cosmos-1',
  logoURIs: {
    png: 'cosmos.png'
  },
  binaries: {
    "linux/amd64": 'cosmos-bin.tar.gz'
  }
}

Options

jsStringify accepts the following options in the StringifyOptions interface:

  • space (optional): Specifies the number of spaces to use for indentation, defaults to 0.
  • replacer (optional): A function that alters the behavior of the stringification process by filtering and transforming the values.
  • quotes (optional): Determines the type of quotes around strings. Can be 'single', 'double', or determined automatically to avoid escapes.
  • inlineArrayLimit (optional): Allows arrays to be serialized inline if they have fewer elements than the specified limit.
  • camelCase (optional): When set to true, object keys are transformed into camelCase.
  • camelCaseFn (optional): A custom function that can be provided to convert object keys into camelCase using a custom transformation logic.

Contributing

Contributions are welcome! Please fork the repository and submit a pull request with your enhancements. For major changes, please open an issue first to discuss what you would like to change.

License

This project is licensed under the MIT License - see the LICENSE file for details.