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'; | |
// The only explicit filesystem or module reference in our whole application!!! | |
const container = require('./example-container'); | |
const fileReader = container.build('fileReader'); | |
// installed and system modules are loaded implicitly, no extra declaration needed | |
const path = container.build('path'); | |
const contents = fileReader.readAFile(path.join(__dirname, 'staticFiles', 'myFile.txt')); |
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 path = require('path'); | |
const config = { | |
cwd: path.join(__dirname, 'dependencies'), | |
modulePaths: [ | |
'file-tools', | |
'logging-tools' | |
] |
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 fileReader(fs, logger) { | |
function readAFile(filepath) { | |
try { | |
return fs.readFileSync(filePath, { encoding: 'utf8' }); | |
} catch (e) { | |
logger.log(e.message); | |
return null; | |
} | |
} |
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 logger = require('../loggerFactory').create(); | |
const fs = require('fs'); | |
function readAFile(filepath) { | |
try { | |
return fs.readFileSync(filePath, { encoding: 'utf8' }); | |
} catch (e) { | |
logger.log(e.message); |
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 someStuff = [] | |
(function () { | |
'use strict' | |
someStuff.push(1) | |
const logThings = (x => console.log(x)) | |
[2, 3, 4, 5] |
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 () { | |
'use strict'; | |
const buildCombination = | |
(currentList, values) => | |
values.map((value) => currentList.concat([value])); | |
const buildPartialCombination = | |
(newSet) => | |
(setCombination, value) => |
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
describe('myTest', function () { | |
it('should interact with window', function () { | |
function AudioContext() { | |
this.foo = 'bar'; | |
} | |
AudioContext.prototype = { | |
doThatThingYouDo: sinon.spy() | |
}; |
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 assert = require('chai').assert; | |
const sinon = require('sinon'); | |
const container = require('../../../container'); | |
const motherContainer = require('../../test-utils/mother-container'); | |
const testUtils = require('../../test-utils/test-utils'); | |
require('../../test-utils/approvalsConfig'); |
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 signet = require('signet')(); | |
(function () { | |
signet.defineDuckType('astPosition', { | |
line: 'leftBoundedInt<1>', | |
column: 'leftBoundedInt<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
'use strict'; | |
function astHelper(estraverse, typeHelper) { | |
function noOp() { } | |
function coordsContainedIn(containerCoords, testCoords) { | |
const onOrAfterStart = testCoords.start.line > containerCoords.start.line | |
|| (testCoords.start.line === containerCoords.start.line | |
&& testCoords.start.column >= containerCoords.start.column); |