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.0.11 to 0.0.12

46

lib/stratas/index.js

@@ -33,15 +33,37 @@ "use strict";

var calcSalesTurnoverRate = function calcSalesTurnoverRate(strata) {
var sales = strata.sales,
units = strata.units;
var _sales$ = sales[0],
pastYear = _sales$.pastYear,
twoYearsAgo = _sales$.twoYearsAgo,
threeYearsAgo = _sales$.threeYearsAgo;
var turnoverRate = {
pastYear: new _decimal.Decimal(pastYear).dividedBy(units).toNumber(),
twoYearsAgo: new _decimal.Decimal(twoYearsAgo).dividedBy(units).toNumber(),
threeYearsAgo: new _decimal.Decimal(threeYearsAgo).dividedBy(units).toNumber()
var calcSalesTurnoverRate = function calcSalesTurnoverRate(stratas) {
var stratasWithSalesAndUnits = stratas.filter(function (x) {
return x.units;
}).filter(function (x) {
return x.sales.length;
});
var metricsPastYear = stratasWithSalesAndUnits.map(function (x) {
var sales = x.sales,
units = x.units;
var _$orderBy$ = _lodash.default.orderBy(sales, ['at'], ['desc'])[0],
pastYear = _$orderBy$.pastYear,
twoYearsAgo = _$orderBy$.twoYearsAgo,
threeYearsAgo = _$orderBy$.threeYearsAgo;
return {
pastYear: pastYear / units,
twoYearsAgo: twoYearsAgo / units,
threeYearsAgo: threeYearsAgo / units
};
});
var pastYearAverage = (0, _utils.toFixed)((0, _utils.average)(metricsPastYear.map(function (x) {
return x.pastYear;
})), 2);
var twoYearsAgoAverage = (0, _utils.toFixed)((0, _utils.average)(metricsPastYear.map(function (x) {
return x.twoYearsAgo;
})), 2);
var threeYearsAgoAverage = (0, _utils.toFixed)((0, _utils.average)(metricsPastYear.map(function (x) {
return x.threeYearsAgo;
})), 2);
return {
pastYear: pastYearAverage,
twoYearsAgo: twoYearsAgoAverage,
threeYearsAgo: threeYearsAgoAverage
};
return turnoverRate;
};

@@ -48,0 +70,0 @@

{
"name": "@buildingsblock/core",
"version": "0.0.11",
"version": "0.0.12",
"description": "Core code base for Buildingsblock",

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

@@ -35,12 +35,15 @@ import test from 'ava'

test('calcSalesTurnoverRate', (t) => {
const strata = {
const strata = [{
sales: [{ pastYear: 10, twoYearsAgo: 5, threeYearsAgo: 20 }],
units: 100,
}
}, {
sales: [{ pastYear: 15, twoYearsAgo: 40, threeYearsAgo: 35 }],
units: 200,
}]
const result = calcSalesTurnoverRate(strata)
t.is(result.pastYear, 0.1, 'should return turnover rate for past year')
t.is(result.twoYearsAgo, 0.05, 'should return turnover rate for two years ago')
t.is(result.threeYearsAgo, 0.2, 'should return turnover rate for three years ago')
t.is(result.pastYear, 0.09, 'should return turnover rate for past year')
t.is(result.twoYearsAgo, 0.13, 'should return turnover rate for two years ago')
t.is(result.threeYearsAgo, 0.19, 'should return turnover rate for three years ago')
})

Sorry, the diff of this file is not supported yet

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