Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simple-stringify

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-stringify

stringify json on top attr

  • 1.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

simple-stringify

Build Status Coverage Status npm Github Releases

Simple way stringify json for log.

Installation

$ npm install simple-stringify

API

const stringify = require('simple-stringify');
const data = {
  no: 123,
  mobile: null,
  addresss: undefined,
  disabled: false,
  name: 'tree.xie',
  keywords: [
    'koa',
    'framework',
    'albi',
  ],
  infos: {
    url : 'https://github.com/vicanso/albi/issues',
    email: 'vicansocanbico@gmail.com'
  },
};
// no=123 mobile=null addresss=undefined disabled=false name="tree.xie" keywords=[] infos={}
stringify.json(data);

divider

The divider for stringify, default is ' '.

const stringify = require('simple-stringify');
stringify.divider = ',';

isSecret

Determine if it is confidential by key. If return true, the value will be ***.

const stringify = require('simple-stringify');
stringify.isSecret = key => key === 'password';
// account="tree.xie" password="***"
stringify.json({
  password: '123456',
});

json

Stringify json data

  • level format level, default is stringify.maxLevel
const stringify = require('simple-stringify');
const data = {
  no: 123,
  mobile: null,
  addresss: undefined,
  disabled: false,
  name: 'tree.xie',
  keywords: [
    'koa',
    'framework',
    'albi',
  ],
  infos: {
    url : 'https://github.com/vicanso/albi/issues',
    email: 'vicansocanbico@gmail.com'
  },
};
// no=123 mobile=null addresss=undefined disabled=false name="tree.xie" keywords=[] infos={}
stringify.json(data);

// no=123 mobile=null addresss=undefined disabled=false name="tree.xie" keywords=[0="koa" 1="framework" 2="albi"] infos={url="https://github.com/vicanso/albi/issues" email="vicansocanbico@gmail.com"}
stringify.json(data, 2);

maxLevel

Set stringify max level, default is 1

const stringify = require('simple-stringify');
stringify.maxLevel = 2;
const data = {
  no: 123,
  mobile: null,
  addresss: undefined,
  disabled: false,
  name: 'tree.xie',
  keywords: [
    'koa',
    'framework',
    'albi',
  ],
  infos: {
    url : 'https://github.com/vicanso/albi/issues',
    email: 'vicansocanbico@gmail.com'
  },
};
// no=123 mobile=null addresss=undefined disabled=false name="tree.xie" keywords=[0="koa" 1="framework" 2="albi"] infos={url="https://github.com/vicanso/albi/issues" email="vicansocanbico@gmail.com"}
stringify.json(data);

Benchmarks

JSON.stringify 1000000 times, use:2438ms
simple-stringify json 1000000 times, use:1684ms

License

MIT

Keywords

FAQs

Package last updated on 30 Nov 2017

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