Created
April 11, 2017 21:15
-
-
Save jbreckmckye/8f1880adb1c4e9900427601b500f960c to your computer and use it in GitHub Desktop.
Self-instantiating module constructors
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 Module(lodash, THREE, moment) { | |
this.thingy = stuff => lodash.zip(stuff, false); | |
this.majig = whatever => moment().format(whatever); | |
this.zxzzxz = blah => new THREE.TextureLoader().load(blah); | |
} | |
module.exports = new Module( | |
require('lodash'), | |
require('three'), | |
require('moment') | |
); |
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 Module = require('./module').constructor; | |
const mockLodash = mocker(); | |
const mockThree = mocker(); | |
const mockMoment = mocker(); | |
const withMocks = new Module(mockLodash, mockThree, mockMoment); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment