Socket
Socket
Sign inDemoInstall

stringify-object-lite

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    stringify-object-lite

An extremely light-weight function to recursively stringifying objects without adding slashes and other types of url-encoding. clocks in at only 628 bytes minified


Version published
Weekly downloads
1
Maintainers
1
Install size
6.12 kB
Created
Weekly downloads
 

Readme

Source

stringify-object-lite

An extremely light-weight function to recursively stringify objects without adding slashes and other types of url-encoding. Clocks in at only 628 bytes minified with no dependencies.

Installation

npm install --save stringify-object-lite;
or
yarn add stringify-object-lite

Usage

For ES6 and up
import stringifyObjectLite from 'stringify-object-lite';
For ES5
var stringifyObjectLite = require("stringify-object-lite");

To stringify the following object:

var obj = {
  a: "A string",
  b: "Another string",
  c: ["an", "array", "of", "strings", "and", 1, "int"],
  nested: {
    a1: "nested",
    b2: "object of strings",
    c3: {
      andA: "deeply",
      nested: "object"
    }
  }
}

Simply pass your object to the provided function:

stringifyObjectLite(obj)

It will output the following as a single-line string (I've beautified this example for better legibility):

{
    a: "A string",
    b: "Another string",
    c: ["an", "array", "of", "strings", "and", "1", "int"],
    nested: {
        a1: "nested",
        b2: "object of strings",
        c3: {
            andA: "deeply",
            nested: "object",
        },
    },
}

FAQs

Last updated on 02 Jun 2017

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc