SI | Content | Description |
---|---|---|
1. | const sql = connection.format("SELECT * FROM table WHERE foo = ?", ["bar"]); console.log(sql); | Build the query before execution |
2. | "debug-test": "mocha --inspect-brk -t 1500" //Add above line to package.json and run npm run debug-test | Debug test in local |
3. | Merge objects with key value, values being integer, sum the values | |
_ = require('lodash');
//Merge the array and sum values corresponding to same carrier //Example: x={ abc: 1, abd: 5 }, y= { abd: 2, abe: 5 } =>{abc: 1,abd: 7, abe: 5 } merged = _.mergeWith({ ...x }, { ...y }, (a, b) => { a = a && _.isNumber(parseInt(a)) ? parseInt(a) : 0; b = b && _.isNumber(parseInt(b)) ? parseInt(b) : 0; return a+b; }); |
I have been using PHP, Javascript, Jquery with codeignitor since 2009. I used to use and make many custom functions for development purpose of which some are noteworthy and may be useful for others also. I would like to share and discuss such custom functions with all enthusiasts.
Wednesday, January 30, 2019
Node
Subscribe to:
Posts (Atom)