This file contains hidden or 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
/* | |
* Time for a little data structure and algorithm exercise. | |
* | |
* Websites commonly make use of a "search suggestion" feature. | |
* As you type, options are suggested to you based on what others | |
* have searched for in the past. For example, if I type 'Le', | |
* I will be presented with other things for which people have searched-- | |
* other terms that begin with 'Le', such as "Levi", "Lego", and "Level". | |
* One way to accomplish this is by using a tree structure, breaking each previous | |
* search term into characters and then storing them in a tree, like so: |
This file contains hidden or 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
/* | |
* Import the libaries that we're using. | |
* This is a test of API code, so any libraries | |
* specified in package.json should be available | |
* for import here. | |
*/ | |
import chai = require('chai'); | |
import chaiAsPromised = require("chai-as-promised"); | |
import sinon = require('sinon'); |
This file contains hidden or 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 KarmaServer = KarmaServer = require('karma').Server; | |
gulp.task('test:www', ['compile:www'], function (done) { | |
new KarmaServer({ | |
configFile: __dirname + '/karma.conf.js', | |
singleRun: true | |
}, done).start(); | |
}); |
This file contains hidden or 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 baseUrl = '/base'; | |
var config = { | |
baseUrl: baseUrl, | |
baseUILib: baseUrl + '/src/www/js/lib', | |
baseAPILib: baseUrl + '/node_modules', | |
fileInclusionTest: /spec\..+\.js$/i | |
}; | |
var allTestFiles = []; |
This file contains hidden or 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(config) { | |
config.set({ | |
basePath: '', | |
frameworks: ['mocha', 'requirejs', 'chai-sinon'], | |
// Here, we specify which files Karma should load into the test harness. | |
files: [ | |
// First, load an additional test runner that the karma-requirejs plugin will need. | |
'src/test/karma-test-runner.js', |
This file contains hidden or 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 mocha = require('gulp-mocha'); | |
gulp.task('test:api', ['compile:api'], function() { | |
return gulp.src('api/unit/test/location/**/*.js', { | |
read: false | |
}).pipe(mocha({ | |
reporter: 'spec' | |
})); | |
}); |
This file contains hidden or 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
tsc --module amd task.ts |
This file contains hidden or 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
tsc --target es6 task.ts |
This file contains hidden or 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 router = Express.Router(); | |
var taskManager = new DataManager( | |
new MongoDataDriver(EnvDataConfig.getInstance()), | |
Task | |
); | |
var taskController = new ExpressController(); | |
taskController.manager = taskManager; |
This file contains hidden or 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
export class MongoDataDriver implements IDataDriver { | |
getConnection() : Promise { | |
return new Promise((resolve, reject) => { | |
Mongo.MongoClient.connect(this.config.connectionURL, (err, connection) => { | |
if (err) { | |
reject(err); | |
} | |
resolve(connection); | |
}); | |
}); |
NewerOlder