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
/* Copyright (c) 2012 Rod Vagg <@rvagg> */ | |
var Stream = require('stream').Stream | |
, BufferStream = require('bufferstream') | |
, toEncoding = require('./util').toEncoding | |
, toSlice = require('./util').toSlice | |
, extend = require('./util').extend | |
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 Base () {} | |
Base.prototype = { | |
foo: function () { | |
console.log('.. in Base.foo()') | |
} | |
, dude: function () { | |
console.log('.. in Base.dude()') | |
} |
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
// Compare the following. In this snippet it's unclear in what context these methods are defined | |
, pipe: function (dest) { | |
if (typeof dest.add == 'function' && this._options.type == 'fstream') { | |
this._dataEvent = 'entry' | |
this.on('entry', function (data) { | |
var entry = new BufferStream() | |
entry.path = data.key.toString() | |
entry.type = 'File' | |
entry.props = { |
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
// js3 mode with '(js3-lazy-commas t) and '(js3-curly-indent-offset 2) in .emacs | |
// produces this type of object literals, which is what I want | |
var obj = { | |
name: 'magnus' | |
, number: 314 | |
} | |
// Howver, this fucks up indentation in functions. Here I want TWO spaces. | |
function foo() { | |
var someVar |
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 npm = require('npm') | |
, fs = require('fs') | |
, rimraf = require('rimraf') | |
, _ = require('underscore') | |
, skipVersions = [ '0.2.1' ] | |
, moduleBase = __dirname + '/node_modules/' | |
, levelupBase = moduleBase + 'levelup' | |
if (fs.existsSync(levelupBase)) { | |
rimraf.sync(levelupBase) |
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
/*jshint indent:4*/ | |
var count = 0; | |
while (false) | |
count++; |
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
/*jshint forin:false*/ | |
var key; | |
for (key in obj) {} |
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
/*jshint newcap:false */ | |
function foo(){} | |
var obj = new foo(); |
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 bigBlob = Array.apply(null, Array(1024 * 100)).map(function () { return 'aaaaaaaaaa' }).join('') |
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
#!/usr/bin/env node | |
// This works just fine. | |
var fs = require('fs') | |
, from = fs.createReadStream('./video') | |
, to = fs.createWriteStream('./video-copy') | |
from.pipe(to) |