function calcBasisFunctions( span, u, p, U ) {

	const N = [];
	const left = [];
	const right = [];
	N[ 0 ] = 1.0;

	for ( let j = 1; j <= p; ++ j ) {

		left[ j ] = u - U[ span + 1 - j ];
		right[ j ] = U[ span + j ] - u;

		let saved = 0.0;

		for ( let r = 0; r < j; ++ r ) {

			const rv = right[ r + 1 ];
			const lv = left[ j - r ];
			const temp = N[ r ] / ( rv + lv );
			N[ r ] = saved + rv * temp;
			saved = lv * temp;

		}

		N[ j ] = saved;

	}

	return N;

}
Calculates basis functions. See The NURBS Book, page 70, algorithm A2.2.

@param {number} span - The span in which `u` lies.
@param {number} u - The parametric value.
@param {number} p - The degree.
@param {Array<number>} U - The knot vector.
@return {Array<number>} Array[p+1] with basis functions values.