http = require 'http'
module.exports = class Request
get: (url) ->
new Promise (resolve, reject)->
req = http.get url, (res) ->
body = ''
res.on 'data', (chunk) ->
body += chunk.toString()
res.on 'end', ->
resolve body
req.on 'error', reject
require(ваш_модуль).get(ваш_url)
.then (страница)->
.catch (ошибка)->
window.Function = (function(Function){
return function(){
var fn = Function.apply(window, arguments);
return function(){
console.log('run');
return fn.apply(this, arguments);
}
}
})(Function);
Function('console.log(1)')() // => run 1
io.sockets.on('connection', function (socket) {
socket.on('disconnect', function () {
// ...
});
});
function controller($scope, socket){
socket.emit('getFoo', 42, function(data){
$scope.foo = data
});
}
function taskFirst(k, v, next) {
console.log(k, v);
next(null, 'ok1');
}
function taskSecond(k, v, next) {
console.log(k, v);
next(null, 'ok2');
}
function run() {
var g1 = "Something";
var g2 = "Something";
var g3 = "Something";
var g4 = "Something";
async.series([
taskFirst.bind(null, g1, g2),
taskSecond.bind(null, g3, g4)
], function(error, result){
}
);
}
var Parent=function(){
this.par='par';};
Parent.prototype.parProto='parProto';
var Child=function(){
Parent.apply(this);
this.chld='chld';};
Child.prototype=Object.create(Parent.prototype);
Child.prototype.chldProto='chldProto';
var Current=function(){
Child.apply(this);}
Current.prototype=Object.create(Child.prototype);
var inst=new Current;