Inspired on this other gist
function hook(callback){
var oldWrite = process.stdout.write;
var output = { str : '' };
return {
restore : function(){| ;[Element].forEach(function(self){ | |
| self.prototype.eventListenerList = {}; | |
| self.prototype._addEventListener = self.prototype.addEventListener; | |
| self.prototype.addEventListener = function(type, handle, useCapture) { | |
| useCapture = useCapture === void 0 ? false : useCapture; | |
| var node = this; | |
| node._addEventListener(type, handle, useCapture); |
| var util = require('util') | |
| function hook_stdout(callback) { | |
| var old_write = process.stdout.write | |
| process.stdout.write = (function(write) { | |
| return function(string, encoding, fd) { | |
| write.apply(process.stdout, arguments) | |
| callback(string, encoding, fd) | |
| } |
Inspired on this other gist
function hook(callback){
var oldWrite = process.stdout.write;
var output = { str : '' };
return {
restore : function(){When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:
var Article = require('../../../models/article');Those suck for maintenance and they're ugly.
| 'use strict'; | |
| var gulp = require('./.'); | |
| gulp.task('js', function(done){ | |
| done(); | |
| }); | |
| gulp.task(function jsx(done){ | |
| done(); |
| var ansiJS = require('ansi-highlight'); | |
| var timer, exitCode; | |
| function format(type, str, fn){ | |
| var test, badge; | |
| try { | |
| test = (fn || function(){})() || 'passed'; | |
| } catch(err){ | |
| test = err; |
| #!/bin/sh | |
| # taked from TJ | |
| # https://github.com/visionmedia/commander.js/blob/master/test/run | |
| export NODE_ENV=test | |
| echo | |
| for file in $@; do | |
| printf " \033[90m${file#test/}\033[0m\n --- \n" |
| var fs = require('fs'); | |
| var path = require('path'); | |
| var fileList = fs.readdirSync( | |
| path.resolve(path.dirname(module.parent.filename), path.basename(__dirname)) | |
| ).slice(1); | |
| exports = module.exports = { }; | |
| fileList.forEach(function(fileName){ |
| var util = { }; | |
| document.addEventListener('keydown', function(e){ | |
| var key = util.key[e.which]; | |
| if( key ){ | |
| e.preventDefault(); | |
| } | |
| if( key === 'F1' ){ |
The browser field is provided by a module author as a hint to javascript bundlers or component tools when preparing modules for client side use.
Below are common terms used in the rest of the document
This is a non-dom based javascript execution environment. It usually only contains the base javascript language spec libraries and objects along with modules to communicate with OS features (available through commonjs require).