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

@base2/pretty-print-object

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@base2/pretty-print-object - npm Package Compare versions

Comparing version 0.0.6 to 1.0.0

8

dist/index.d.ts

@@ -1,2 +0,2 @@

interface StringifyObjectOptions {
interface PrettyPrintOptions {
/**

@@ -36,5 +36,5 @@ * Preferred indentation.

}
export declare function stringify(input: any): string;
export declare function stringify(input: any, options: StringifyObjectOptions): string;
export declare function stringify(input: any, options: StringifyObjectOptions, pad: string): string;
export declare function prettyPrint(input: any): string;
export declare function prettyPrint(input: any, options: PrettyPrintOptions): string;
export declare function prettyPrint(input: any, options: PrettyPrintOptions, pad: string): string;
export {};

@@ -50,9 +50,9 @@ "use strict";

/**
* Stringify an object
* pretty print an object
*
* @param input the object to stringify
* @param options
* @param input the object to pretty print
* @param options the formatting options, transforms, and filters
* @param pad the padding string
*/
function stringify(input, options, pad) {
function prettyPrint(input, options, pad) {
if (pad === void 0) { pad = ''; }

@@ -76,6 +76,6 @@ // sensible option defaults

tokens = {
newLine: '@@__STRINGIFY_OBJECT_NEW_LINE__@@',
newLineOrSpace: '@@__STRINGIFY_OBJECT_NEW_LINE_OR_SPACE__@@',
pad: '@@__STRINGIFY_OBJECT_PAD__@@',
indent: '@@__STRINGIFY_OBJECT_INDENT__@@'
newLine: '@@__PRETTY_PRINT_NEW_LINE__@@',
newLineOrSpace: '@@__PRETTY_PRINT_NEW_LINE_OR_SPACE__@@',
pad: '@@__PRETTY_PRINT_PAD__@@',
indent: '@@__PRETTY_PRINT_INDENT__@@'
};

@@ -121,3 +121,3 @@ }

var eol = input.length - 1 === i ? tokens.newLine : ',' + tokens.newLineOrSpace;
var value = stringify(el, combinedOptions, pad + combinedOptions.indent);
var value = prettyPrint(el, combinedOptions, pad + combinedOptions.indent);
if (combinedOptions.transform) {

@@ -144,4 +144,4 @@ value = combinedOptions.transform(input, i, value);

var isClassic = !isSymbol && /^[a-z$_][a-z$_0-9]*$/i.test(el.toString());
var key = isSymbol || isClassic ? el : stringify(el, combinedOptions);
var value = stringify(input[el], combinedOptions, pad + combinedOptions.indent);
var key = isSymbol || isClassic ? el : prettyPrint(el, combinedOptions);
var value = prettyPrint(input[el], combinedOptions, pad + combinedOptions.indent);
if (combinedOptions.transform) {

@@ -163,3 +163,3 @@ value = combinedOptions.transform(input, el, value);

}
exports.stringify = stringify;
exports.prettyPrint = prettyPrint;
//# sourceMappingURL=index.js.map
{
"name": "@base2/pretty-print-object",
"version": "0.0.6",
"version": "1.0.0",
"description": "Convert an object or array into a formatted string",

@@ -5,0 +5,0 @@ "repository": {

# Pretty print object
[![License][license-image]][license-url] ![coverage-badge-green]
> Stringify an object/array like JSON.stringify just without all the double-quotes
> Convert an object or array into a formatted string

@@ -23,15 +23,15 @@ This is a fork of [stringify-object], modified to inline the dependencies and make it compatible with ES5 out of the box.

```js
const stringifyObject = require('@base2/pretty-print-object');
import { prettyPrint } from '@base2/pretty-print-object';
const obj = {
foo: 'bar',
'arr': [1, 2, 3],
nested: {
hello: "world"
}
foo: 'bar',
'arr': [1, 2, 3],
nested: {
hello: "world"
}
};
const pretty = stringifyObject(obj, {
indent: ' ',
singleQuotes: false
const pretty = prettyPrint(obj, {
indent: ' ',
singleQuotes: false
});

@@ -42,11 +42,11 @@

{
foo: "bar",
arr: [
1,
2,
3
],
nested: {
hello: "world"
}
foo: "bar",
arr: [
1,
2,
3
],
nested: {
hello: "world"
}
}

@@ -59,3 +59,3 @@ */

### stringifyObject(input, [options])
### prettyPrint(input, [options])

@@ -104,17 +104,17 @@ Circular references will be replaced with `"[Circular]"`.

```js
const stringifyObject = require('@base2/pretty-print-object');
import { prettyPrint } from '@base2/pretty-print-object';
const obj = {
user: 'becky',
password: 'secret'
user: 'becky',
password: 'secret'
};
const pretty = stringifyObject(obj, {
transform: (obj, prop, originalResult) => {
if (prop === 'password') {
return originalResult.replace(/\w/g, '*');
}
const pretty = prettyPrint(obj, {
transform: (obj, prop, originalResult) => {
if (prop === 'password') {
return originalResult.replace(/\w/g, '*');
}
return originalResult;
}
return originalResult;
}
});

@@ -125,4 +125,4 @@

{
user: 'becky',
password: '******'
user: 'becky',
password: '******'
}

@@ -142,16 +142,16 @@ */

```js
const stringifyObject = require('@base2/pretty-print-object');
import { prettyPrint } from '@base2/pretty-print-object';
const obj = {
foo: 'bar',
'arr': [1, 2, 3],
nested: {
hello: "world"
}
foo: 'bar',
'arr': [1, 2, 3],
nested: {
hello: "world"
}
};
const pretty = stringifyObject(obj, {
indent: ' ',
singleQuotes: false,
inlineCharacterLimit: 12
const pretty = prettyPrint(obj, {
indent: ' ',
singleQuotes: false,
inlineCharacterLimit: 12
});

@@ -162,7 +162,7 @@

{
foo: "bar",
arr: [1, 2, 3],
nested: {
hello: "world"
}
foo: "bar",
arr: [1, 2, 3],
nested: {
hello: "world"
}
}

@@ -169,0 +169,0 @@ */

Sorry, the diff of this file is not supported yet

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