Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@buildingsblock/core

Package Overview
Dependencies
Maintainers
2
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@buildingsblock/core - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

yarn-error.log

74

lib/stratas/index.js

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = exports.calcAverageContingencyReserveFundPerBudget = exports.calcAverageSalesTurnoverRate = exports.calcContingencyReserveFundContributionsPerSquareFoot = exports.calcContingencyReserveFundPerSquareFoot = exports.calcBudgetPerSquareFoot = exports.calcRepairAndMaintenanceBudgetPerSquareFoot = void 0;
exports.default = exports.calcAverageContingencyReserveFundPerBudget = exports.calcAverageSalesTurnoverRate = exports.calcContingencyReserveFundContributionsPerSquareFoot = exports.calcContingencyReserveFundContributions = exports.calcContingencyReserveFundPerSquareFoot = exports.calcContingencyReserveFund = exports.calcBudgetPerSquareFoot = exports.calcBudget = exports.calcRepairAndMaintenanceBudgetPerSquareFoot = void 0;

@@ -43,2 +43,25 @@ var _lodash = _interopRequireDefault(require("lodash"));

var calcBudget = function calcBudget(stratas) {
var stratasWithBudget = stratas.filter(function (x) {
return x.budget && x.budget.length;
});
if (!stratasWithBudget.length) return {
average: null,
min: null,
max: null
};
var metrics = stratasWithBudget.map(function (x) {
var value = _lodash.default.orderBy(x.budget, ['at'], ['desc'])[0].value;
return new _decimal.Decimal(value);
});
return {
average: (0, _utils.toFixed)((0, _utils.average)(metrics), 2),
min: (0, _utils.toFixed)((0, _utils.min)(metrics), 2),
max: (0, _utils.toFixed)((0, _utils.max)(metrics), 2)
};
};
exports.calcBudget = calcBudget;
var calcBudgetPerSquareFoot = function calcBudgetPerSquareFoot(stratas) {

@@ -70,2 +93,25 @@ var stratasWithBudget = stratas.filter(function (x) {

var calcContingencyReserveFund = function calcContingencyReserveFund(stratas) {
var stratasWithContingencyReserveFund = stratas.filter(function (x) {
return x.contingencyReserveFund && x.contingencyReserveFund.length;
});
if (!stratasWithContingencyReserveFund.length) return {
average: null,
min: null,
max: null
};
var metrics = stratasWithContingencyReserveFund.map(function (x) {
var contingencyReserveFund = _lodash.default.orderBy(x.contingencyReserveFund, ['at'], ['desc'])[0].value;
return new _decimal.Decimal(contingencyReserveFund);
});
return {
average: (0, _utils.toFixed)((0, _utils.average)(metrics), 2),
min: (0, _utils.toFixed)((0, _utils.min)(metrics), 2),
max: (0, _utils.toFixed)((0, _utils.max)(metrics), 2)
};
};
exports.calcContingencyReserveFund = calcContingencyReserveFund;
var calcContingencyReserveFundPerSquareFoot = function calcContingencyReserveFundPerSquareFoot(stratas) {

@@ -97,2 +143,25 @@ var stratasWithContingencyReserveFund = stratas.filter(function (x) {

var calcContingencyReserveFundContributions = function calcContingencyReserveFundContributions(stratas) {
var stratasWithContingencyReserveFundContributions = stratas.filter(function (x) {
return x.contingencyReserveFundContributions && x.contingencyReserveFundContributions.length;
});
if (!stratasWithContingencyReserveFundContributions.length) return {
average: null,
min: null,
max: null
};
var metrics = stratasWithContingencyReserveFundContributions.map(function (x) {
var contingencyReserveFundContributions = _lodash.default.orderBy(x.contingencyReserveFundContributions, ['at'], ['desc'])[0].value;
return new _decimal.Decimal(contingencyReserveFundContributions);
});
return {
average: (0, _utils.toFixed)((0, _utils.average)(metrics), 2),
min: (0, _utils.toFixed)((0, _utils.min)(metrics), 2),
max: (0, _utils.toFixed)((0, _utils.max)(metrics), 2)
};
};
exports.calcContingencyReserveFundContributions = calcContingencyReserveFundContributions;
var calcContingencyReserveFundContributionsPerSquareFoot = function calcContingencyReserveFundContributionsPerSquareFoot(stratas) {

@@ -259,2 +328,5 @@ var stratasWithContingencyReserveFundContributions = stratas.filter(function (x) {

calcContingencyReserveFundContributionsPerSquareFoot: calcContingencyReserveFundContributionsPerSquareFoot,
calcBudget: calcBudget,
calcContingencyReserveFund: calcContingencyReserveFund,
calcContingencyReserveFundContributions: calcContingencyReserveFundContributions,
calcAverageContingencyReserveFundPerBudget: calcAverageContingencyReserveFundPerBudget,

@@ -261,0 +333,0 @@ calcAverageSalesTurnoverRate: calcAverageSalesTurnoverRate,

2

package.json
{
"name": "@buildingsblock/core",
"version": "0.1.0",
"version": "0.1.1",
"description": "Core code base for Eli",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -9,2 +9,6 @@ import test from 'ava'

calcBudget,
calcContingencyReserveFund,
calcContingencyReserveFundContributions,
calcAverageContingencyReserveFundPerBudget,

@@ -207,3 +211,2 @@ calcAverageSalesTurnoverRate,

test('calcSalesTurnoverRate', (t) => {

@@ -293,1 +296,150 @@ const strata = [{

})
test('calcContingencyReserveFundContributions', (t) => {
const stratas = [
{
contingencyReserveFundContributions: [{ value: 70000, at: '2018-01-11' }, { value: 20000, at: '2018-05-11' }],
},
{
contingencyReserveFundContributions: [{ value: 40000 }],
},
{
contingencyReserveFundContributions: [],
},
]
const oneStrata = [
{
contingencyReserveFundContributions: [{ value: 20000 }],
area: { total: 1000 },
},
]
const nullStrata = [
{
contingencyReserveFundContributions: null,
},
]
const emptyStrata = []
const result = calcContingencyReserveFundContributions(stratas)
const oneStrataResult = calcContingencyReserveFundContributions(oneStrata)
const nullStrataResult = calcContingencyReserveFundContributions(nullStrata)
const emptyStrataResult = calcContingencyReserveFundContributions(emptyStrata)
t.is(result.average, 30000, 'should return average for past year')
t.is(result.min, 20000, 'should return min for past year')
t.is(result.max, 40000, 'should return max for past year')
t.is(oneStrataResult.average, 20000, 'should return average for past year')
t.is(oneStrataResult.min, 20000, 'should return min for past year')
t.is(oneStrataResult.max, 20000, 'should return max for past year')
t.is(nullStrataResult.average, null, 'should return average for past year')
t.is(nullStrataResult.min, null, 'should return min for past year')
t.is(nullStrataResult.max, null, 'should return max for past year')
t.is(emptyStrataResult.average, null, 'should return average for past year')
t.is(emptyStrataResult.min, null, 'should return min for past year')
t.is(emptyStrataResult.max, null, 'should return max for past year')
})
test('calcContingencyReserveFund', (t) => {
const stratas = [
{
contingencyReserveFund: [{ value: 70000, at: '2018-01-11' }, { value: 20000, at: '2018-05-11' }],
},
{
contingencyReserveFund: [{ value: 40000 }],
},
{
contingencyReserveFund: [],
},
]
const oneStrata = [
{
contingencyReserveFund: [{ value: 20000 }],
area: { total: 1000 },
},
]
const nullStrata = [
{
contingencyReserveFund: null,
},
]
const emptyStrata = []
const result = calcContingencyReserveFund(stratas)
const oneStrataResult = calcContingencyReserveFund(oneStrata)
const nullStrataResult = calcContingencyReserveFund(nullStrata)
const emptyStrataResult = calcContingencyReserveFund(emptyStrata)
t.is(result.average, 30000, 'should return average for past year')
t.is(result.min, 20000, 'should return min for past year')
t.is(result.max, 40000, 'should return max for past year')
t.is(oneStrataResult.average, 20000, 'should return average for past year')
t.is(oneStrataResult.min, 20000, 'should return min for past year')
t.is(oneStrataResult.max, 20000, 'should return max for past year')
t.is(nullStrataResult.average, null, 'should return average for past year')
t.is(nullStrataResult.min, null, 'should return min for past year')
t.is(nullStrataResult.max, null, 'should return max for past year')
t.is(emptyStrataResult.average, null, 'should return average for past year')
t.is(emptyStrataResult.min, null, 'should return min for past year')
t.is(emptyStrataResult.max, null, 'should return max for past year')
})
test('calcBudget', (t) => {
const stratas = [
{
budget: [{ value: 70000, at: '2018-01-11' }, { value: 20000, at: '2018-05-11' }],
},
{
budget: [{ value: 40000 }],
},
{
budget: [],
},
]
const oneStrata = [
{
budget: [{ value: 20000 }],
},
]
const nullStrata = [
{
budget: null,
},
]
const emptyStrata = []
const result = calcBudget(stratas)
const oneStrataResult = calcBudget(oneStrata)
const nullStrataResult = calcBudget(nullStrata)
const emptyStrataResult = calcBudget(emptyStrata)
t.is(result.average, 30000, 'should return average for past year')
t.is(result.min, 20000, 'should return min for past year')
t.is(result.max, 40000, 'should return max for past year')
t.is(oneStrataResult.average, 20000, 'should return average for past year')
t.is(oneStrataResult.min, 20000, 'should return min for past year')
t.is(oneStrataResult.max, 20000, 'should return max for past year')
t.is(nullStrataResult.average, null, 'should return average for past year')
t.is(nullStrataResult.min, null, 'should return min for past year')
t.is(nullStrataResult.max, null, 'should return max for past year')
t.is(emptyStrataResult.average, null, 'should return average for past year')
t.is(emptyStrataResult.min, null, 'should return min for past year')
t.is(emptyStrataResult.max, null, 'should return max for past year')
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc