Basic files

This commit is contained in:
Abhas
2018-12-04 14:04:37 +05:30
commit 111a00f45d
7 changed files with 119 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
# EditorConfig is awesome: http://EditorConfig.org
root = true;
[*]
# Ensure there's no lingering whitespace
trim_trailing_whitespace = true
# Ensure a newline at the end of each file
insert_final_newline = true
[*.js]
# Unix-style newlines
end_of_line = lf
charset = utf-8
indent_style = space
indent_size = 2
+36
View File
@@ -0,0 +1,36 @@
# Logs
logs
*.log
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directory
# Commenting this out is preferred by some people, see
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
node_modules
bower_components
.nyc_output
coverage
tmp
docs
# Users Environment Variables
.lock-wscript
# Editors
.idea
+8
View File
@@ -0,0 +1,8 @@
{
"name": "demo",
"version": "0.0.1",
"main": "src/index.js",
"scripts": {
}
}
+3
View File
@@ -0,0 +1,3 @@
const SIPCalculations = require('./sip');
module.exports = SIPCalculations;
+32
View File
@@ -0,0 +1,32 @@
// @ts-check
const Calculations = {
/**
* @description Get minimum SIP amount
* @returns {number} - Returns here
* @param {Array<number>} priceArray - Input here
*/
getMaxAmount(priceArray) {
const maxPrice = Math.max(...priceArray);
return maxPrice;
},
/**
* Get total value of the order from order config
* @returns {number} - Output A
* @param {import('./types').OrderConfig} orderConfig - Input A
* @param {import('./types').SidPriceMap} sidPriceMap - Input B
*/
calculateOrderTotalValue: function calculateOrderTotalValue(orderConfig, sidPriceMap) {
const totalValue = orderConfig.reduce((prevValue, eachSidConfig) => {
const sidPrice = sidPriceMap[eachSidConfig.sid];
const currentConfigValue = sidPrice * eachSidConfig.shares;
return (prevValue + currentConfigValue);
}, 0);
return totalValue;
}
};
module.exports = Calculations;
+12
View File
@@ -0,0 +1,12 @@
export type sid = string;
export interface OrderConfigElement {
sid: sid;
shares: number,
}
export type OrderConfig = Array<OrderConfigElement>;
export interface SidPriceMap {
[sid: string]: number;
}
+12
View File
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"module": "commonjs",
"allowJs": true
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules"
]
}