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 when1 = require('when1'); | |
var when2 = require('when2'); | |
var rejectedPromise = when1.reject(new Error('Intentional failure')); | |
when2(rejectedPromise).done(undefined, function(error){ | |
console.log('Rejection properly handled:', error); | |
}); |
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 2011 Justin Santa Barbara | |
# All Rights Reserved. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); you may | |
# not use this file except in compliance with the License. You may obtain | |
# a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software |
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 WebSocket = require('ws'); | |
var ws = new WebSocket('ws://localhost:7717'); | |
var fs = require('fs'); | |
var loremIpsum = fs.readFileSync(__dirname + '/lipsum.txt', 'utf-8'); | |
ws.on('open', function open() { | |
function spam() { | |
try { | |
console.log('-> send'); |
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
Object.prototype.toString.call(new Date()); // '[object Date]' | |
// Now to have some fun: | |
const suspiciousDate = new Date(); | |
suspiciousDate[Symbol.toStringTag] = 'window'; | |
Object.prototype.toString.call(suspiciousDate); // wut! |
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
const immutable = require('immutable'); | |
const lodash = require('lodash'); | |
const a = new immutable.List([ 1, 2, 3 ]); | |
const b = new immutable.List([ 1, 2, 3 ]) | |
console.log('a.equals(b) => %s', a.equals(b)); | |
console.log('a === b => %s', a === b); | |
console.log('_.isEqual(a, b) => %s', lodash.isEqual(a, b)); | |
const z = new immutable.List([ 1, 2, 3, 4 ]); | |
console.log('_.isEqual(a, z) => %s', lodash.isEqual(a, z)); |
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 BucketCollector() { | |
} | |
BucketCollector.prototype.addToBucket = function addToBucket(item) { | |
this.items.push(item); | |
}; | |
BucketCollector.prototype.items = []; |
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 nonStrict() { | |
console.log('nonStrict: %s', typeof this); | |
})(); | |
(function strict() { | |
'use strict'; | |
console.log('strict: %s', typeof this); | |
})(); |
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
* firing query | |
* query result: 1 | |
* firing query | |
* query result: 1 | |
* firing query | |
* query result: 1 | |
* firing query | |
* query result: 1 | |
* firing query | |
* query result: 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
'use strict'; | |
const Big = require('big.js'); | |
const EventEmitter = require('events'); | |
/** | |
* An EventEmitter that emits subsequent approximations of number Pi. | |
* @extends external:EventEmitter | |
*/ | |
class PiEmitter extends EventEmitter { |
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
<!DOCTYPE html PUBLIC> | |
<html> | |
<head> | |
<title>Root window</title> | |
</head> | |
<body> | |
<p id="greeter">Nothing here yet...</p> | |
<button id="opener">Open a new window</button> | |
<script> | |
window.greet = function greet() { |
OlderNewer