Skip to content

showMe is a function that makes an object to a human readable string.

License

Notifications You must be signed in to change notification settings

will-v-king/javascript-showMe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

javascript-showMe

showMe is a function that makes JSON object to a human readable string.

typeOf is a function that checks the type of JSON object or return the name of the type.

getStr is a function that return a description string of JSON object by burning computer's memory.

getString is a function that retrun a description string of JSON object by burning computer's CPU.

Example

showMe

/*
*params
    "functionName": true(when object is a function only show its name and "function()");
    "maxDepth": 1(means only scan one level of the object 's elements, return a '...' to replace the deeper level's);
    "newWindow": true,(show message in a new Browser window)
*/
showMe([{
    	a: 'b'
	,b: 1
	,c: [function() {
		return 'e';
	}]
}]); === alert('[{a:"b",b:1,c:[function (){return \'e\';}]}]');

showMe([{
	a: 'b'
	,b: 1
	,c: [function() {
		return 'e';
	}]
}], {
	'functionNameOnly': true
	,'burning': 'CPU'
	,'newWindow': false
}); === alert('[{a:"b",b:1,c:[function()]}]');

showMe([{
	a: 'b'
	,b: 1
	,c: [function() {
		return 'e';
	}]
}], {
	functionNameOnly: false
	,maxDepth: 1
	,burning: 'CPU'
	,newWindow: true
}); === function() {
	win = window.open('', '', '');
	win.document.write('[{a:[object String],b:[object Number],c:[object Array]}]');
} ()

notice: if stack overflow please try to use burnig: 'CPU' ,and set the maxDepth low;

typeOf

/*
* typeOf({},['object','string']) == true;
*
* typeOf({},'object) == true;
*
* typeOf({}) == 'Object'
*
* typeOf(null, 'Object') == false;
*
* typeOf(function(){},'function') == true;
*
* typeOf(undefined, 'undefined') == true;
*
* typeOf(null,'null') == true;
*
* typeOf() == 'undefined';
*
* typeOf(NaN) == 'NaN';
*/

getStr

(Recursion)
getStr([1, "a", function(){var a = {a: 1};}, true, {b: 2}]); === '[1, "a", function(){var a = {a: 1};}, true, {b: 2}]';

getString

(Iteration)
getString([1, "a", function(){var a = {a: 1};}, true, {b: 2}]); === '[1, "a", function(){var a = {a: 1};}, true, {b: 2}]';

About

showMe is a function that makes an object to a human readable string.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published