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'; | |
//------------------------------------------------------------------------------ | |
// Rule Definition | |
//------------------------------------------------------------------------------ | |
const msg = 'Please use common.expectsError(fn, err) instead of ' + | |
'assert.throws(fn, common.expectsError(err)).'; | |
function isAssertThrows(node) { |
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
1) OPTIONS when error occurs in response handler should pass error to callback: | |
Error: expected 'true' response body, got 'GET,HEAD' | |
at error (node_modules/supertest/lib/test.js:275:13) | |
at Test._assertBody (node_modules/supertest/lib/test.js:201:16) | |
at Test._assertFunction (node_modules/supertest/lib/test.js:257:11) | |
at Test.assert (node_modules/supertest/lib/test.js:158:18) | |
at assert (node_modules/supertest/lib/test.js:137:12) | |
at node_modules/supertest/lib/test.js:134:5 | |
at Test.Request.callback (node_modules/superagent/lib/node/index.js:691:12) | |
at IncomingMessage.<anonymous> (node_modules/superagent/lib/node/index.js:922:12) |
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 common = require('./test/common'); | |
const { readFileSync } = require('fs'); | |
const { join } = require('path'); | |
const { createSecureContext } = require('tls'); | |
const h2 = require('http2'); | |
const key = loadKey('agent8-key.pem'); | |
const cert = loadKey('agent8-cert.pem'); |
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 h2 = require('http2'); | |
const server = h2.createServer(); | |
server.on('request', (req, res) => res.end()); | |
server.on('timeout', () => console.log('timeout')); | |
server.listen(0, () => { |
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
// Calculate luma (brightness) of a hexadecimal colour | |
// --------------------------------------------------- | |
// You can use this to calculate whether two colours | |
// are suitable to be used as a background and text | |
function hex2luma(hex) { | |
return ( | |
(parseInt(hex.substring(0, 2), 16) * 299) + | |
(parseInt(hex.substring(2, 4), 16) * 587) + | |
(parseInt(hex.substring(4, 6), 16) * 114) |
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
// Convert hex colour to rgba | |
// --------------------------------- | |
// hex: hex colour without leading # | |
// opacity: integer from 0 to 1 | |
function hex2rgba(hex, opacity) { | |
var r = parseInt(hex.substring(0, 2), 16), | |
g = parseInt(hex.substring(2, 4), 16), | |
b = parseInt(hex.substring(4, 6), 16); |
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
// Based on jamespadolsey's gist: https://gist.github.com/527683 | |
// ----------------------------------------------------------------- | |
// Was curious to see what method would yield the best 'performance' | |
// — turns out that using innerHTML and checking for text is | |
// marginally faster than using a Live NodeList. | |
// | |
// Of course, any performance gains can only be seen at 100+ | |
// iterations, but still somewhat interesting. | |
(function (ie) { |