Prepare for publishing
This commit is contained in:
		
							
								
								
									
										1
									
								
								lib/predictor.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								lib/predictor.js
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										4718
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										4718
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -1,11 +1,12 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "name": "app",
 | 
					  "name": "predictor",
 | 
				
			||||||
  "version": "1.0.0",
 | 
					  "version": "1.0.0",
 | 
				
			||||||
  "description": "",
 | 
					  "description": "",
 | 
				
			||||||
  "main": "index.js",
 | 
					  "module": "lib/predictor.js",
 | 
				
			||||||
  "scripts": {
 | 
					  "scripts": {
 | 
				
			||||||
    "test": "jest",
 | 
					    "test": "jest",
 | 
				
			||||||
    "build": "webpack",
 | 
					    "build:dev": "webpack",
 | 
				
			||||||
 | 
					    "build": "WEBPACK_ENV=build webpack",
 | 
				
			||||||
    "start:dev": "webpack-dev-server",
 | 
					    "start:dev": "webpack-dev-server",
 | 
				
			||||||
    "format": "prettier --tab-width=4 --single-quote --trailing-comma es5 --write '{source,tests}/**/*.js'"
 | 
					    "format": "prettier --tab-width=4 --single-quote --trailing-comma es5 --write '{source,tests}/**/*.js'"
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
@@ -20,6 +21,7 @@
 | 
				
			|||||||
    "babel-preset-env": "^1.6.1",
 | 
					    "babel-preset-env": "^1.6.1",
 | 
				
			||||||
    "bable-loader": "0.0.1-security",
 | 
					    "bable-loader": "0.0.1-security",
 | 
				
			||||||
    "css-loader": "^0.28.11",
 | 
					    "css-loader": "^0.28.11",
 | 
				
			||||||
 | 
					    "deepmerge": "^2.1.1",
 | 
				
			||||||
    "jest": "^22.4.4",
 | 
					    "jest": "^22.4.4",
 | 
				
			||||||
    "prettier": "^1.12.1",
 | 
					    "prettier": "^1.12.1",
 | 
				
			||||||
    "sass-loader": "^7.0.1",
 | 
					    "sass-loader": "^7.0.1",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,12 +2,23 @@ import Journal from './Journal';
 | 
				
			|||||||
import Supervisor from './Supervisor';
 | 
					import Supervisor from './Supervisor';
 | 
				
			||||||
import Daemon from './Daemon';
 | 
					import Daemon from './Daemon';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const DEFAULT_CONFIG = {
 | 
				
			||||||
 | 
					    supervisor_epsilon: 0.01,
 | 
				
			||||||
 | 
					    daemons: [
 | 
				
			||||||
 | 
					        { human: 2, robot: 2, epsilon: 0.01 },
 | 
				
			||||||
 | 
					        { human: 3, robot: 3, epsilon: 0.01 },
 | 
				
			||||||
 | 
					        { human: 4, robot: 4, epsilon: 0.01 },
 | 
				
			||||||
 | 
					        { human: 5, robot: 5, epsilon: 0.01 },
 | 
				
			||||||
 | 
					        { human: 6, robot: 6, epsilon: 0.01 },
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default class Predictor {
 | 
					export default class Predictor {
 | 
				
			||||||
    score;
 | 
					    score;
 | 
				
			||||||
    journal;
 | 
					    journal;
 | 
				
			||||||
    supervisor;
 | 
					    supervisor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    constructor(config) {
 | 
					    constructor(config = DEFAULT_CONFIG) {
 | 
				
			||||||
        this.score = 0;
 | 
					        this.score = 0;
 | 
				
			||||||
        this.journal = new Journal();
 | 
					        this.journal = new Journal();
 | 
				
			||||||
        const daemons = config.daemons.map(daemonConfig => {
 | 
					        const daemons = config.daemons.map(daemonConfig => {
 | 
				
			||||||
@@ -17,7 +28,7 @@ export default class Predictor {
 | 
				
			|||||||
                daemonConfig.epsilon || 0.01
 | 
					                daemonConfig.epsilon || 0.01
 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
        this.supervisor = new Supervisor(daemons, config.epsilon || 0.01);
 | 
					        this.supervisor = new Supervisor(daemons, config.supervisor_epsilon);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pass(value) {
 | 
					    pass(value) {
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										3
									
								
								source/build.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								source/build.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					import Predictor from './Predictor';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export default Predictor;
 | 
				
			||||||
@@ -5,7 +5,13 @@ import Predictor from './Predictor';
 | 
				
			|||||||
new Vue({
 | 
					new Vue({
 | 
				
			||||||
    el: '#app',
 | 
					    el: '#app',
 | 
				
			||||||
    data: {
 | 
					    data: {
 | 
				
			||||||
        predictor: new Predictor(),
 | 
					        predictor: new Predictor({
 | 
				
			||||||
 | 
					            daemons: [
 | 
				
			||||||
 | 
					                { human: 3, robot: 3 },
 | 
				
			||||||
 | 
					                { human: 4, robot: 4 },
 | 
				
			||||||
 | 
					                { human: 5, robot: 5 },
 | 
				
			||||||
 | 
					            ],
 | 
				
			||||||
 | 
					        }),
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    methods: {
 | 
					    methods: {
 | 
				
			||||||
        click(v) {
 | 
					        click(v) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,14 +1,7 @@
 | 
				
			|||||||
const path = require('path');
 | 
					const path = require('path');
 | 
				
			||||||
 | 
					const merge = require('deepmerge');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const baseConfig = {
 | 
				
			||||||
module.exports = {
 | 
					 | 
				
			||||||
    mode: 'development',
 | 
					 | 
				
			||||||
    entry: path.resolve(__dirname, 'source/index.js'),
 | 
					 | 
				
			||||||
    output: {
 | 
					 | 
				
			||||||
        filename: 'app.js',
 | 
					 | 
				
			||||||
        path: path.resolve(__dirname, 'web/dist'),
 | 
					 | 
				
			||||||
        publicPath: 'dist/',
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
    module: {
 | 
					    module: {
 | 
				
			||||||
        rules: [
 | 
					        rules: [
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
@@ -24,6 +17,28 @@ module.exports = {
 | 
				
			|||||||
            },
 | 
					            },
 | 
				
			||||||
        ]
 | 
					        ]
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const buildConfig = {
 | 
				
			||||||
 | 
					    mode: 'production',
 | 
				
			||||||
 | 
					    entry: path.resolve(__dirname, 'source/build.js'),
 | 
				
			||||||
 | 
					    output: {
 | 
				
			||||||
 | 
					        filename: 'predictor.js',
 | 
				
			||||||
 | 
					        path: path.resolve(__dirname, 'lib'),
 | 
				
			||||||
 | 
					        library: 'predictor',
 | 
				
			||||||
 | 
					        libraryTarget: 'umd',
 | 
				
			||||||
 | 
					        umdNamedDefine: true
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const devConfig = {
 | 
				
			||||||
 | 
					    mode: 'development',
 | 
				
			||||||
 | 
					    entry: path.resolve(__dirname, 'source/index.js'),
 | 
				
			||||||
 | 
					    output: {
 | 
				
			||||||
 | 
					        filename: 'app.js',
 | 
				
			||||||
 | 
					        path: path.resolve(__dirname, 'web/dist'),
 | 
				
			||||||
 | 
					        publicPath: 'dist/',
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    resolve: {
 | 
					    resolve: {
 | 
				
			||||||
        alias: {
 | 
					        alias: {
 | 
				
			||||||
            'vue$': 'vue/dist/vue.esm.js'
 | 
					            'vue$': 'vue/dist/vue.esm.js'
 | 
				
			||||||
@@ -36,3 +51,8 @@ module.exports = {
 | 
				
			|||||||
        port: 9000,
 | 
					        port: 9000,
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					module.exports = merge(
 | 
				
			||||||
 | 
					    baseConfig,
 | 
				
			||||||
 | 
					    process.env.WEBPACK_ENV === 'build' ? buildConfig : devConfig
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user