View inject_behaviour.js
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
// TestSubject.js | |
const ExternalDependency = require('./ExternalDependency') | |
module.exports = class TestSubject { | |
constructor () { | |
this.externalDependency = new ExternalDependency() | |
} | |
isExternalDependencyMocked () { | |
return this.externalDependency.isMocked |
View Error.js
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
module.exports = function CustomError(message) { | |
this.name = this.constructor.name | |
this.message = message | |
Error.captureStackTrace(this, this.constructor) | |
} | |
module.exports.prototype.inspect = function () { | |
return this.stack | |
} |
View extendingSubstackPattern.js
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
//file substack.js | |
module.exports = function() { | |
console.log('main entry point'); | |
}; | |
module.exports.details = function() { | |
console.log('more detailed functionality'); | |
}; | |
View substackPattern.js
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 getDatasetfromJsonData(jsonData){ | |
return jsonData[0].scores; | |
}; | |
function getLabels(dataset) { | |
return Object.keys(dataset) | |
}; | |
function getData(dataset) { | |
return Object.keys(dataset).map(function(key) { |
View callingTheModule.js
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
// ...IN THE CALLER | |
import JSONDataConverter from './JSONDataConverter'; | |
<RadarChart data={JSONDataConverter(data)} width={width} height={height} redraw /> |
View module_pattern.js
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 JSONDataConverter = (function () { | |
var getDatasetfromJsonData = function(jsonData){ | |
return jsonData[0].scores; | |
}; | |
var getLabels = function(dataset) { | |
return Object.keys(dataset) | |
}; | |
var getData = function(dataset) { |
View DataConverter.js
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
class DataConverterContainer extends Component { | |
getDatasetfromJsonData(jsonData){ | |
return jsonData[0].scores; | |
}; | |
getLabels(dataset){ | |
return Object.keys(dataset) | |
}; | |
getData(dataset){ |
View avgNull.js
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
16 lines (14 sloc) 0.36 kB | |
function average(data) { | |
/*Can't find an average function in JS, made one | |
This function is able to handle null values!!!*/ | |
var count = null; | |
var sum = null; | |
for (i=0; i<data.length; i++) { | |
if (data[i]) { | |
count++; |