1
0
mirror of https://github.com/badges/shields.git synced 2025-04-18 19:44:04 +03:00

Docstrings for contributor-count and deprecation-helpers services (#8003)

* add docstrings for contributor-count service

* add docstrings for deprecation-helper service

* remove deprecation-helpers service as it is not used anywhere

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
Prashant Rawat 2022-05-29 23:18:04 +05:30 committed by GitHub
parent bc533c694b
commit d3f1a55503
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 24 deletions

View File

@ -1,5 +1,18 @@
/**
* Common functions and utilities for tasks related to contributor count.
*
* @module
*/
import { metric } from './text-formatters.js'
/**
* Determines the color used for a badge based on the contributor count.
* The color varies from red to bright green as the contributor count increases.
*
* @param {number} contributorCount Contributor count
* @returns {string} Badge color
*/
function contributorColor(contributorCount) {
if (contributorCount > 2) {
return 'brightgreen'
@ -10,6 +23,15 @@ function contributorColor(contributorCount) {
}
}
/**
* Handles rendering concerns of badges that display contributor count.
* Determines the message and color of the badge according to the contributor count.
*
* @param {object} attrs Refer to individual attributes
* @param {string} [attrs.label] If provided then badge label is set to this value
* @param {number} attrs.contributorCount Contributor count
* @returns {object} Badge with label, message and color properties
*/
function renderContributorBadge({ label, contributorCount }) {
return {
label,

View File

@ -1,9 +0,0 @@
import { Deprecated } from './index.js'
function enforceDeprecation(effectiveDate) {
if (Date.now() >= effectiveDate.getTime()) {
throw new Deprecated()
}
}
export { enforceDeprecation }

View File

@ -1,15 +0,0 @@
import { expect } from 'chai'
import { Deprecated } from '../core/base-service/errors.js'
import { enforceDeprecation } from './deprecation-helpers.js'
describe('enforceDeprecation', function () {
it('throws Deprecated for a date in the past', function () {
expect(() => enforceDeprecation(new Date())).to.throw(Deprecated)
})
it('does not throw for a date in the future', function () {
expect(() =>
enforceDeprecation(new Date(Date.now() + 10000))
).not.to.throw()
})
})