Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/padolsey-archive/prettyprint.js
An in-browser JavaScript variable dumper, similar in functionality to ColdFusion's cfdump tag.
https://github.com/padolsey-archive/prettyprint.js
Last synced: 11 days ago
JSON representation
An in-browser JavaScript variable dumper, similar in functionality to ColdFusion's cfdump tag.
- Host: GitHub
- URL: https://github.com/padolsey-archive/prettyprint.js
- Owner: padolsey-archive
- Created: 2009-06-05T17:30:54.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2019-09-24T16:06:52.000Z (about 5 years ago)
- Last Synced: 2024-10-11T13:44:08.088Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 248 KB
- Stars: 655
- Watchers: 31
- Forks: 103
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
prettyPrint.js
===© [James Padolsey](http://james.padolsey.com)
*prettyPrint.js* is an in-browser JavaScript variable dumper, similar in functionality to ColdFusion's cfdump tag.
First, a preview:
Preview:
---![prettyPrint.js preview](http://img132.imageshack.us/img132/5890/prettyprintpreview.png)
Features:
---* Entirely independent. It requires NO StyleSheets or images.
* Handles infinitely nested objects.
* All native JavaScript types are supported plus DOM nodes/elements!
* Protects against circular/repeated references.
* Allows you to specify the depth to which the object will be printed.
* Better browser users benefit from gradient column-headers! Thanks to HTML5 andCANVAS
!
* Allows low-level CSS customisation (if such a thing exists).Usage:
---Download prettyPrint.js and include it in your document:
Whenever you want to pretty-print an object of any type simple call prettyPrint:
prettyPrint( myObject );
That, on its own, won't do anything though; prettyPrint returns a table which you can handle in any way you desire. For example, if you wanted to insert the table at the very top of the document:var tbl = prettyPrint( myObject );
document.body.insertBefore( tbl, document.body.firstChild );
Or, appending it to the document:document.body.appendChild(tbl);
Configuration:
---Custom settings can be passed (as an object) as the second argument to the prettyPrint() function:
prettyPrint(myFoo, {
// Config
maxArray: 20, // Set max for array display (default: infinity)
expanded: false, // Expanded view (boolean) (default: true),
maxDepth: 5 // Max member depth (when displaying objects) (default: 3)
})tip: Scroll to line ~679 of prettyprint.js for more configuration options.