This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.post((req, res) => { | |
| const user = db.getUserByName(req.headers.name); | |
| const user = db.getUserByName(req.query.name); | |
| const user = db.getUserByName(req.path.name); | |
| const user = db.getUserByName(req.body.name); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @param val {*} | |
| * @returns {Boolean} | |
| */ | |
| function isNothing(val) { | |
| return val === undefined || val === null; | |
| } | |
| /** | |
| * @param val {*} | |
| * @return {Number} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var schemaLoaded = kefir.fromEvents(app, 'server:schema').take(1); | |
| var serverListening = kefir.fromEvents(app, 'server:running').take(1); | |
| return kefir.merge([schemaLoaded, serverListening]).toPromise(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const http = require('http'); | |
| // Swagger-like API description | |
| const api = { | |
| '/users': { | |
| 'get': { | |
| 'parameters': { | |
| 'role': { | |
| 'in': 'query' | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let x = 1; | |
| let sum = (a, b) => a + b + x | |
| sum(1, 2); // 4 | |
| x = 2; | |
| sum(1, 2); // 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Bacon = require('baconjs'); | |
| var Rx = require('rx'); | |
| var Kefir = require('kefir'); | |
| var EE = require('events').EventEmitter; | |
| var ee = new EE; | |
| var sum = function (prev, cur) {return prev+cur}; | |
| Bacon.fromEvent(ee, 'event1').scan(0, sum).onValue(console.log); // 0, 4, 9 | |
| Rx.Observable.fromEvent(ee, 'event1').reduce(sum, 0).subscribe(console.log); // doesn't work |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var row = "word".split(""); | |
| // splice modifies original array | |
| function pull (row, i) { | |
| var arr = []; | |
| row.forEach(function (item, j) { | |
| if (i!=j) arr.push(item); | |
| }); | |
| return arr; | |
| } |
NewerOlder