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 Checkout = function Checkout(inventory) { | |
inventory = inventory || []; | |
this.basket = {}; | |
this.inventory = {}; | |
inventory.forEach(function (product) { | |
this.inventory[product.code] = new Product(product); | |
}.bind(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
var vm = require('vm'); | |
function checkArr(arr) { | |
return arr instanceof Array; | |
} | |
var context = vm.createContext({ | |
checkArr: checkArr, | |
console: console | |
}); |
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
[ | |
{ | |
"userName": "alphagov", | |
"repo": "datainsight-frontend" | |
}, | |
{ | |
"userName": "alphagov", | |
"repo": "fourth-wall" | |
}, | |
{ |
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
/** | |
Usage: `node domains.js --file <inputfile.csv> | |
**/ | |
var fs = require('fs'); | |
var argh = require('argh').argv; | |
var _ = require('underscore'); | |
var input = argh.file; | |
fs.readFile(input, function (err, filedata) { |
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 winston = require('winston'); | |
var config = require('./config'); | |
var logger = new winston.Logger({ | |
transports: [ | |
new winston.transports.Console({ colorize: true }), | |
new winston.transports.File({ filename: config['app-log'], json: false }) | |
], | |
exceptionHandlers: [ |
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
// example test script for module with http.get | |
// uses sinon, chai and mocha. | |
var Module = require('./my-module-that-does-http'); | |
var http = require('http'); | |
describe('Module', function () { | |
beforeEach(function () { |
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 fs = require('fs'), | |
path =require('path'); | |
var dir = process.argv[2]; | |
if (!dir) { | |
console.error('Folder path must be defined.'); | |
console.log('Usage: node json-linter.js /path/to/test'); | |
process.exit(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
var https = require('https'); | |
var getLatestCoreVersion = function(major, cb) { | |
var json = ''; | |
var req = https.get({ | |
host: 'api.github.com', | |
path: '/repos/mozu/core-theme/releases', | |
headers: { | |
'User-Agent': 'thmaa', | |
'content-length': 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
... | |
"karma": "0.12.24", | |
"karma-browserify": "0.2.1", | |
"karma-chai": "0.1.0", | |
"karma-chrome-launcher": "0.1.5", | |
"karma-firefox-launcher": "0.1.3", | |
"karma-mocha": "0.1.9", | |
"karma-phantomjs-launcher": "0.1.4", | |
"karma-sinon-chai": "0.2.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
var middleware = require('./my-middleware') | |
describe('middleware', function () { | |
var req, res; | |
beforeEach(function () { | |
req = { | |
session: { username: 'lennym' } | |
}, | |
res = {} |
OlderNewer