Folder restructuring (#86)

This commit is contained in:
József Farkas
2016-08-28 21:30:48 +02:00
committed by GitHub
parent baf2d41f71
commit bb3a2d77b6
93 changed files with 213 additions and 178 deletions

4
test-serializer/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
uhk-config.bin
uhk-config-serialized.json
uhk-config-serialized.bin
test-serializer.js

View File

@@ -0,0 +1,46 @@
import {Serializable} from '../src/config-serializer/Serializable';
import {UhkBuffer} from '../src/config-serializer/UhkBuffer';
import {UhkConfiguration} from '../src/config-serializer/config-items/UhkConfiguration';
let assert = require('assert');
let fs = require('fs');
let uhkConfig = JSON.parse(fs.readFileSync('../src/config-serializer/uhk-config.json'));
let config1Js = uhkConfig;
let config1Ts: Serializable<UhkConfiguration> = new UhkConfiguration().fromJsObject(config1Js);
let config1Buffer = new UhkBuffer();
config1Ts.toBinary(config1Buffer);
let config1BufferContent = config1Buffer.getBufferContent();
fs.writeFileSync('uhk-config.bin', config1BufferContent);
config1Buffer.offset = 0;
console.log();
let config2Ts = new UhkConfiguration().fromBinary(config1Buffer);
console.log('\n');
let config2Js = config2Ts.toJsObject();
let config2Buffer = new UhkBuffer();
config2Ts.toBinary(config2Buffer);
fs.writeFileSync('uhk-config-serialized.json', JSON.stringify(config2Js, undefined, 4));
let config2BufferContent = config1Buffer.getBufferContent();
fs.writeFileSync('uhk-config-serialized.bin', config2BufferContent);
console.log('\n');
let error: boolean;
try {
assert.deepEqual(config1Js, config2Js);
console.log('JSON configurations are identical.');
} catch (error) {
console.log('JSON configurations differ.');
error = true;
}
const buffersContentsAreEqual: boolean = Buffer.compare(config1BufferContent, config2BufferContent) === 0;
if (buffersContentsAreEqual) {
console.log('Binary configurations are identical.');
} else {
console.log('Binary configurations differ.');
error = true;
}
process.exit(error ? 1 : 0);

View File

@@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"experimentalDecorators": true,
"typeRoots": [
"../node_modules/@types"
],
"types": [
"node",
"es6-shim"
]
}
}

View File

@@ -0,0 +1,35 @@
// var webpack = require("webpack");
var webpackFailPlugin = require('webpack-fail-plugin');
module.exports = {
entry: {
main: __dirname + '/test-serializer.ts'
},
target: 'node',
output: {
path: __dirname,
filename: "test-serializer.js"
},
resolve: {
extensions: ['', '.webpack.js', '.web.js', '.ts', '.js'],
alias: {
},
modulesDirectories: [
'../node_modules'
]
},
module: {
loaders: [
{ test: /\.ts$/, loader: 'ts-loader', exclude: /node_modules/ }
]
},
plugins: [
// new webpack.optimize.UglifyJsPlugin({ minimize: true }),
webpackFailPlugin
],
node: {
fs: "empty"
}
}