JAVASCRIPT
Dump/Profiling Utilities
All samples are using Ink.requireModules
, please read how to use it at Ink.requireModules section
Function name | Description |
---|---|
.alertDump(param) | Alert a variable's structure. |
.printDump(param, [target]) | Prints variable structure. |
.returnDump(param) | Get a variable's structure. |
.windowDump(param) | Prints the variable structure to a new window. |
Alert a variable's structure.
param
Variable to be dumped.Code
Ink.requireModules(['Ink.Util.Dumper_1'], function(Dumper) {
var obj = {
name: 'John',
age: 33,
hasGlasses: true,
cars: ['Audi', 'BMW', 'Ferrari'],
pets: {
cat: 'Max',
dog: 'Rex'
}
};
Dumper.alertDump(obj);
// will alert the object content
/*
Object
{
[name] => John
[age] => 33
[hasGlasses] => true
[cars] => Array
{
[0] => Audi
[1] => BMW
[2] => Ferrari
}
[pets] => Object
{
[cat] => Max
[dog] => Rex
}
}
*/
});
Prints variable structure.
param
Variable to be dumped.target
Element to print the dump on.Code
<div id="dump_container">
</div>
<script>
Ink.requireModules(['Ink.Util.Dumper_1'], function(Dumper) {
var obj = {
name: 'John',
age: 33,
hasGlasses: true,
cars: ['Audi', 'BMW', 'Ferrari'],
pets: {
cat: 'Max',
dog: 'Rex'
}
};
Dumper.printDump(obj, 'dump_container');
// will print to <div id="dump_container"> the object content
});
</script>
Get a variable's structure.
param
Variable to get the structure.Code
<div id="dump_content"></div>
<script>
Ink.requireModules(['Ink.Util.Dumper_1'], function(Dumper) {
var obj = {
name: 'John',
age: 33,
hasGlasses: true,
cars: ['Audi', 'BMW', 'Ferrari'],
pets: {
cat: 'Max',
dog: 'Rex'
}
};
var dump = Dumper.returnDump(obj);
Ink.i('dump_content').appendChild(document.createTextNode(dump));
});
</script>
Prints the variable structure to a new window.
param
Variable to be dumped.Code
Ink.requireModules(['Ink.Util.Dumper_1'], function(Dumper) {
var obj = {
name: 'John',
age: 33,
hasGlasses: true,
cars: ['Audi', 'BMW', 'Ferrari'],
pets: {
cat: 'Max',
dog: 'Rex'
}
};
Dumper.windowDump(obj);
// will open a window with the object content
/*
Object
{
[name] => John
[age] => 33
[hasGlasses] => true
[cars] => Array
{
[0] => Audi
[1] => BMW
[2] => Ferrari
}
[pets] => Object
{
[cat] => Max
[dog] => Rex
}
}
*/
});