Comparing version 0.0.2 to 0.0.3
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -6,2 +6,24 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
// HELPER FUNCTIONS | ||
function getMathPIStringNoDecimal() { | ||
// divide by 10 to get decimal on left | ||
var mathPIDivTen = Math.PI / 10; | ||
// convert to string | ||
var mathPIString = '' + mathPIDivTen; | ||
// leave out decimal | ||
return mathPiString.substring(1); | ||
}; | ||
function lengthOfMathPI() { | ||
return getMathPIStringNoDecimal().length; | ||
}; | ||
function getDigitFromMathPI(index) { | ||
return getMathPIStringNoDecimal.charat(index); | ||
}; | ||
// PIBRARY | ||
var pibrary = {}; | ||
@@ -13,6 +35,15 @@ | ||
pibrary.digitAt = function () { | ||
return 3; | ||
/* | ||
* zero-indexed | ||
* 0 would return 3, 1 would return 1, 2 would return 4, etc | ||
*/ | ||
pibrary.digitAt = function (index) { | ||
if (index < lengthOfMathPI()) { | ||
return getDigitFromMathPI(index); | ||
} | ||
// otherwise need to actually calculate digit of pi | ||
return -1; | ||
}; | ||
exports.default = pibrary; |
{ | ||
"name": "pibrary", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "everything pi", | ||
@@ -5,0 +5,0 @@ "main": "lib/pibrary.js", |
@@ -0,1 +1,23 @@ | ||
// HELPER FUNCTIONS | ||
function getMathPIStringNoDecimal () { | ||
// divide by 10 to get decimal on left | ||
const mathPIDivTen = Math.PI / 10; | ||
// convert to string | ||
const mathPIString = '' + mathPIDivTen; | ||
// leave out decimal | ||
return mathPiString.substring(1); | ||
}; | ||
function lengthOfMathPI () { | ||
return getMathPIStringNoDecimal().length; | ||
}; | ||
function getDigitFromMathPI (index) { | ||
return getMathPIStringNoDecimal.charat(index); | ||
}; | ||
// PIBRARY | ||
const pibrary = {}; | ||
@@ -7,6 +29,15 @@ | ||
pibrary.digitAt = function () { | ||
return 3; | ||
/* | ||
* zero-indexed | ||
* 0 would return 3, 1 would return 1, 2 would return 4, etc | ||
*/ | ||
pibrary.digitAt = function (index) { | ||
if ( index < lengthOfMathPI() ) { | ||
return getDigitFromMathPI(index); | ||
} | ||
// otherwise need to actually calculate digit of pi | ||
return -1; | ||
}; | ||
export default pibrary; |
5105
90