
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
b5-calculate-score
Advanced tools
Calculate score for big five tests
$ npm i b5-calculate-score
Pass an object with property answers. Answers have to be an Array with domain and score. Facet is optional.
const calculateScore = require('b5-calculate-score')
const result = {
"timeElapsed": -51,
"ip": "127.0.0.1",
"lang": "en",
"test": "50-IPIP-NEO-PI-R",
"totalQuestions": 50,
"answers": [
{
"domain": "A",
"facet": "1",
"score": "3"
},
{
"domain": "A",
"facet": "1",
"score": "3"
},
{
"domain": "E",
"facet": "1",
"score": "3"
},
{
"domain": "E",
"facet": "2",
"score": "3"
}
]
}
calculateScore(result)
returns score for each factor
{
'A': {
'score': 6,
'count': 2,
'result': 'neutral',
'facet': {
'1': {
'score': 6,
'count': 2,
'result': 'neutral'
}
}
},
'E': {
'score': 6,
'count': 2,
'result': 'neutral',
'facet': {
'1': {
'score': 3,
'count': 1,
'result': 'neutral'
},
'2': {
'score': 3,
'count': 1,
'result': 'neutral'
}
}
}
}
If you want to override result pass a function as the calculateResult property
The function signature must be
function (score, count) {
'use strict'
// Do something
return 'value'
}
Example
const calculateScore = require('b5-calculate-score')
const calculateResult = (score, count) => {
const average = score / count
let result = 'nøytral'
if (average > 3) {
result = 'høy'
} else if (average < 3) {
result = 'lav'
}
return result
}
const result = {
"timeElapsed": -51,
"ip": "127.0.0.1",
"lang": "en",
"test": "50-IPIP-NEO-PI-R",
"totalQuestions": 50,
"calculateResult": calculateResult,
"answers": [
{
"domain": "A",
"facet": "1",
"score": "3"
},
{
"domain": "A",
"facet": "1",
"score": "3"
},
{
"domain": "E",
"facet": "1",
"score": "3"
},
{
"domain": "E",
"facet": "2",
"score": "3"
}
]
}
calculateScore(result)
Returns
{
'A': {
'score': 6,
'count': 2,
'result': 'nøytral',
'facet': {
'1': {
'score': 6,
'count': 2,
'result': 'nøytral'
}
}
},
'E': {
'score': 6,
'count': 2,
'result': 'nøytral',
'facet': {
'1': {
'score': 3,
'count': 1,
'result': 'nøytral'
},
'2': {
'score': 3,
'count': 1,
'result': 'nøytral'
}
}
}
}
Created with <3 by zrrzzt and maccyber
FAQs
micro webservice that evaluates bigfive questions
The npm package b5-calculate-score receives a total of 56 weekly downloads. As such, b5-calculate-score popularity was classified as not popular.
We found that b5-calculate-score demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.