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
{ | |
"dependencies": { | |
"component/emitter": "1.1.3", | |
"component/domify": "1.3.1" | |
} | |
} |
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": "example", | |
"scripts": [ | |
"lib/index.js" | |
], | |
"styles": [ | |
"style.css" | |
], | |
"templates": [ | |
"lib/template.html" |
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
FROM debian:wheezy | |
RUN apt-get update \ | |
&& apt-get install -y build-essential \ | |
libncurses5-dev libgnome2-dev libgnomeui-dev \ | |
libgtk2.0-dev libatk1.0-dev libbonoboui2-dev \ | |
libcairo2-dev libx11-dev libxpm-dev libxt-dev python-dev \ | |
ruby-dev mercurial liblua5.2-dev lua5.2 \ | |
&& rm -rf /var/lib/apt/lists/* |
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 myModule = module.exports; | |
myModule.callbackMethod = supportPromise(function (arg1, arg2, cb) { | |
// 作一些事情 | |
asyncFunction(function () { | |
// 一些異步操作 | |
asyncFunction(function () { | |
// 執行完成 |
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 supportPromise = function (fn) { | |
return function () { | |
if (typeof arguments[arguments.length - 1] === 'function' | |
|| typeof Promise === 'undefined') { | |
return fn.apply(this, arguments); | |
} | |
var args = arguments; | |
return new Promise(function (resolve, reject) { |
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 myModule = module.exports; | |
// 修改前 | |
myModule.callbackMethod = function (arg1, arg2, cb) { | |
// 作一些事情 | |
asyncFunction(function () { | |
// 一些異步操作 | |
asyncFunction(function () { | |
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 Promise = require('native-or-bluebird'); | |
var callbackOrPromise = function (cb, fn) { | |
if (cb) { | |
return fn(cb); | |
} | |
return new Promise(function (resolve, reject) { | |
fn(function (err, res) { | |
err ? reject(err) : resolve(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
var callbackOrPromise = function (cb, fn) { | |
if (cb || typeof Promise === 'undefined') { | |
return fn(cb); | |
} | |
return new Promise(function (resolve, reject) { | |
fn(function (err, res) { | |
err ? reject(err) : resolve(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
var co = require('co'); | |
var prettyHrtime = require('pretty-hrtime'); | |
var jsdom = require('./jsdom'); | |
var templateEngine = require('./template-engine'); | |
var times = 100; | |
function *bench(fn) { | |
var i = 0; | |
var start = process.hrtime(); |
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
package main | |
import ( | |
"fmt" | |
"reflect" | |
) | |
func main() { | |
printUser("poying", 21) | |
printUser("poying 2.0") |