Simple CLI tool to debug a Node.js based Aplication.
π Homepage
npm i duckerdbg --save
Ducker Debug can perform multiple debugging and utility functions. To use it in your application you just need to require it.
const ducker = require('./index')
Base function of this package, it logs a message to the console by either using a custom word or by leaving it empty, by printing the name of the calling function.
- word - String - String to print into the console. Leave empty to show the calling method's name
- debug - Boolean - Flag to indicate if the user requires a stack trace to be printed or not
- level - Number - Level of stack trace to be printed into the console
- detailed - Boolean - Flag to indicate if the full information of each step in the stack trace is required to be printed into the console
ducker.quack()
// π¦ {Quack} >
ducker.quack('wow',true,3)
// π¦ {Quack} > wow
// βββββββββββ¬βββββββββββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββ¬βββββββββ¬βββββββ
// β (index) β fileName β functionName β column β line β
// βββββββββββΌβββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββΌβββββββββΌβββββββ€
// β 0 β '/Users/xxxx/Projects/ducker/index.js' β 'printStack' β 32 β 54 β
// β 1 β '/Users/xxxx/Projects/ducker/index.js' β 'Object.quack' β 9 β 43 β
// β 2 β '/Users/xxxx/Projects/ducker/test.js' β 'Object.<anonymous>' β 8 β 25 β
// βββββββββββ΄βββββββββββββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββ΄βββββββββ΄βββββββ
This method gives a detailed look at any object that is passed to it.
- value - Any - Any value or combination of values to be analyzed
ducker.check(4)
/**
* This value is of type number
-> Its value is 4
*/
ducker.check([1,2,['wow',true,[{'a' : 2}]]])
/*
This value is of type object
-> Array type
Arr[0]
This value is of type number
-> Its value is 1
Arr[1]
This value is of type number
-> Its value is 2
Arr[2]
This value is of type object
-> Array type
Arr[0]
This value is of type string
-> Its value is wow
Arr[1]
This value is of type boolean
-> Its value is true
Arr[2]
This value is of type object
-> Array type
Arr[0]
This value is of type object
βββββββββββ¬ββββββ¬ββββββββ¬βββββββββββ
β (index) β Key β Value β Type β
βββββββββββΌββββββΌββββββββΌβββββββββββ€
β 0 β 'a' β 2 β 'number' β
βββββββββββ΄ββββββ΄ββββββββ΄βββββββββββ
*/
These methods are used to profile an application. All is needed from them is to be placed at any point between two blocks of code.
ducker.go()
ducker.check([1,2,['wow',true,[{'a' : 2}]]])
ducker.stop()
/*
...
π¦ {Quack}: 6.111ms
*/
This method allows you to make simple tests on sync or async code using an equality assertion. (Expected value is equal to Actual value)
- testable - Function - Reference to the function to be tested. Must return any time of value
- args - [Any] - Array of values to be passed to the testable function. These can be of any type.
- expectedResult - Any - Value to be tested against the result of the previous function
- debug - Boolean - Flag to indicate if the user requires a stack trace to be printed or not
- level - Number - Level of stack trace to be printed into the console
- detailed - Boolean - Flag to indicate if the full information of each step in the stack trace is required to be printed into the console
function sum (a,b) {
return a + b
}
ducker.test(sum,[2,2],4)
/*
π¦ {Quack}
Function name: sum
--Result
Function Result: 4
Expected Result: 4
Test successful!
*/
ducker.test(sum,[2,2],2)
/*
π¦ {Quack}
Function name: sum
--Result
Function Result: 4
Expected Result: 2
Test failed!
*/
This method allows you to rename an object's keynames. You only need to pass down the method and an object specifying the new name of the keys.
- object - Object - This is the original object to be modified
- changes - Object - This is a map with the required changes to the keys in the original object
A new object with the same values for the changed keynames.
const user = { 'name' : 'Johny', 'age': 23}
const changes = {'name': 'firstName'}
ducker.rename(user,changes)
// {'firstName' : 'Johny', 'age' : 23}
This method allows you to analyze an object. Fit for the console.table() function to be better analyzed.
- object - Object - The object to be analyzed by xray
console.log(ducker.xray({ 'name' : 'Johny', 'age': 23}))
/*
[ { Key: 'name', Value: 'Johny', Type: 'string' },
{ Key: 'age', Value: 23, Type: 'number' } ]
*/
console.table(ducker.xray({ 'name' : 'Johny', 'age': 23}))
/*
βββββββββββ¬βββββββββ¬ββββββββββ¬βββββββββββ
β (index) β Key β Value β Type β
βββββββββββΌβββββββββΌββββββββββΌβββββββββββ€
β 0 β 'name' β 'Johny' β 'string' β
β 1 β 'age' β 23 β 'number' β
βββββββββββ΄βββββββββ΄ββββββββββ΄βββββββββββ
*/
This method returns a random number.
- floating - Boolean - Flag to determine if the number to be returned should be a floating number or an integer
- min - Number - Minimum limit to generate a number
- max - Number - Maximum limit to generate a number
ducker.random()
// 8874205820570765
ducker.random(true,4,10)
// 5.868581947768592
This method creates an object with fake data based on an user provided schema.
This method only retrieves a schema as an object and can recognize multiple data types such as:
- name
- avatar
- date of birth (dob)
- phone
- address (street,suite,city,zipcode,geo)
- website
- company (name,catchPhrase,bs)
- age
- number
- job
- blood
- color
- ip
- password
- title
- word
- sentence
- paragraphs
ducker.fake({
name: 'name',
email: 'email',
username: 'username',
email: 'email',
sentence: 'sentence',
paragraphs: 'paragraphs',
bloodT: 'blood',
color: 'color',
person : {
name : 'name',
age: 'age',
}
})
/*
{ name: 'Beryl',
email: '[email protected]',
username: 'Beryl61',
sentence: 'Aut voluptatum sit qui minus nam.',
paragraphs:
'Dolores aut dolorum consequatur. Sunt praesentium quam voluptatibus harum voluptas. Aut debitis cupiditate a explicabo quae earum.\n \rSit aperiam assumenda veniam sit tenetur et ad odio odit. Quia at commodi odio voluptatum. Voluptatem est ratione. Nam repellendus dicta magni ipsam quasi ut nesciunt. Tempora consectetur cum ipsum consequatur inventore. Voluptas consequatur nulla dolorum est tempore excepturi.\n \rDolore et aut eos ut nisi aliquid qui aut. Voluptatem optio possimus sed deleniti consequatur qui odit. Corporis qui qui inventore saepe id doloremque. Repellat consectetur accusantium magnam repellendus praesentium. Assumenda dignissimos consequatur nemo exercitationem minima. Illo maxime enim placeat voluptas maxime ad voluptatibus doloremque hic.',
bloodT: { type: 'O', rh: '-' },
color: 'lime',
person: { name: 'Dale', age: 48 } }
*/
This method takes an error message and creates an usable link to search for it on Stack Overflow.
- error - Error - Non empty message retrieved from a try-catch block
try {
JSON.parse({"foo": 1,})
} catch(e){
console.log(e)
ducker.stackoverflow(e)
}
/*
π¦ {Quack}
Check on SO for Error > Unexpected token o in JSON at position 1
http://stackoverflow.com/search?q=[js]+unexpected+token+o+in+json+at+position+1
*/
This method takes a simple sentence and converts it into an usable string to search on a web browser.
- query - String - Non empty message
- website - String - google, duckduckgo, youtube, stackoverflow, bing, yahoo
ducker.searchable('Another one biTEs tHe duST','youtube')
// https://www.youtube.com/results?search_query=another+one+bites+the+dust
π€ Fernando Martin Garcia Del Angel
- Github: @a01334390
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Give a βοΈ if this project helped you!
Copyright Β© 2019 Fernando Martin Garcia Del Angel.
This project is Apache-2.0 licensed.
This README was generated with β€οΈ by readme-md-generator