This file contains 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
start() | |
async function start () { | |
const promises = [ | |
new Promise((resolve, reject) => setTimeout(() => reject(0), 1000)), | |
Promise.reject(1), | |
Promise.reject(2) | |
] | |
promises.forEach(p => p.catch(() => {})) // prevent unhandled |
This file contains 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
function createResponse(name) { | |
this.name = name, | |
this.sayHi = function() { | |
return 'Hi!'; | |
}, | |
this.getName = function() { | |
return this.name; | |
}, |
This file contains 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
process.stdin.resume() | |
process.stdin.on('data', function(data) { process.stdout.write(data) }) | |
process.stdout.on('error', function(err) { | |
if (err.code === 'EPIPE') process.exit() | |
else if (!process.stdout.listeners('error').length) process.emit('error', err) | |
}) |
This file contains 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 union = require('union'); | |
var flatiron = require('flatiron'); | |
var winston = require('winston'); | |
var ecstatic = require('ecstatic'); | |
app = new flatiron.App(); | |
app.use(flatiron.plugins.http); | |
app.http.before = [ | |
var union = require('union'); |
This file contains 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 union = require('union'); | |
var flatiron = require('flatiron'); | |
var winston = require('winston'); | |
var ecstatic = require('ecstatic'); | |
app = new flatiron.App(); | |
app.use(flatiron.plugins.http); | |
app.http.before = [ | |
function (req, res) { |
This file contains 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
'name must be unique': function(test) { | |
account.save(function(err) { | |
if (/duplicate/.test(err) || /unique/.test(err)) { | |
console.log(err.message) | |
test.done() | |
} | |
blueprints.generate('Account', function(err, anotherAccount) { | |
if (err) throw err | |
anotherAccount.name = account.name | |
anotherAccount.save(function(err) { |
This file contains 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
/** | |
* Module dependencies. | |
*/ | |
var express = require('express'); | |
var mongoose = require('mongoose'); | |
var fs = require('fs'); | |
var Schema = mongoose.Schema; | |
var db = mongoose.connect('mongodb://localhost/myapp'); |
This file contains 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
class API extends Backbone.Model | |
{} | |
fetchData: -> | |
// API call here | |