source/grade.js
function getThreshold(fromStep, toStep, now)
{
	let threshold

	// Allows custom thresholds when moving
	// from a specific step to a specific step.
	if (fromStep && (fromStep.id || fromStep.unit)) {
		threshold = toStep[`threshold_for_${fromStep.id || fromStep.unit}`]
	}

	// If no custom threshold is set for this transition
	// then use the usual threshold for the next step.
	if (threshold === undefined) {
		threshold = toStep.threshold
	}

	// Convert threshold to a number.
	if (typeof threshold === 'function') {
		threshold = threshold(now)
	}

	// Throw if no threshold is found.
	if (fromStep && typeof threshold !== 'number') {
		// Babel transforms `typeof` into some "branches"
		// so istanbul will show this as "branch not covered".
		/* istanbul ignore next */
		const type = typeof threshold
		throw new Error(`Each step of a gradation must have a threshold defined except for the first one. Got "${threshold}", ${type}. Step: ${JSON.stringify(toStep)}`)
	}

	return threshold
}
function getThreshold(fromStep, toStep, now)
{
	let threshold

	// Allows custom thresholds when moving
	// from a specific step to a specific step.
	if (fromStep && (fromStep.id || fromStep.unit)) {
		threshold = toStep[`threshold_for_${fromStep.id || fromStep.unit}`]
	}

	// If no custom threshold is set for this transition
	// then use the usual threshold for the next step.
	if (threshold === undefined) {
		threshold = toStep.threshold
	}

	// Convert threshold to a number.
	if (typeof threshold === 'function') {
		threshold = threshold(now)
	}

	// Throw if no threshold is found.
	if (fromStep && typeof threshold !== 'number') {
		// Babel transforms `typeof` into some "branches"
		// so istanbul will show this as "branch not covered".
		/* istanbul ignore next */
		const type = typeof threshold
		throw new Error(`Each step of a gradation must have a threshold defined except for the first one. Got "${threshold}", ${type}. Step: ${JSON.stringify(toStep)}`)
	}

	return threshold
}
function getThreshold ( fromStep , toStep , now ) { let threshold // Allows custom thresholds when moving // from a specific step to a specific step. if ( fromStep && ( fromStep . id || fromStep . unit ) ) { threshold = toStep [ ` ${ fromStep . id || fromStep . unit } ` ] } // If no custom threshold is set for this transition // then use the usual threshold for the next step. if ( threshold === undefined ) { threshold = toStep . threshold } // Convert threshold to a number. if ( typeof threshold === 'function' ) { threshold = threshold ( now ) } // Throw if no threshold is found. if ( fromStep && typeof threshold !== 'number' ) { // Babel transforms `typeof` into some "branches" // so istanbul will show this as "branch not covered". /* istanbul ignore next */ const type = typeof threshold throw new Error ( ` ${ threshold } ${ type } ${ JSON . stringify ( toStep ) } ` ) } return threshold }
Gets threshold for moving from `fromStep` to `next_step`.
@param  {Object} fromStep - From step.
@param  {Object} next_step - To step.
@param  {number} now - The current timestamp.
@return {number}
@throws Will throw if no threshold is found.
Gets threshold for moving from fromStep to next_step .