diff --git a/jspp.js b/jspp.js index 7a52ce1..50d44b4 100644 --- a/jspp.js +++ b/jspp.js @@ -14,16 +14,40 @@ class JSPlusPlus { async isToxic(sentences) { // Load the model. Users optionally pass in a threshold and an array of // labels to include. - const gen = new JSPlusPlus.General - gen.require("https://cdn.jsdelivr.net/npm/@tensorflow/tfjs") - gen.require("https://cdn.jsdelivr.net/npm/@tensorflow-models/toxicity") + const gen = new JSPlusPlus.General + gen.require("https://cdn.jsdelivr.net/npm/@tensorflow/tfjs") + gen.require("https://cdn.jsdelivr.net/npm/@tensorflow-models/toxicity") let threshold = 0.9; let t = await toxicity.load(threshold).then(model => { return model.classify(sentences).then(predictions => { return predictions }); }); - return t + return t + } + + isPrime = num => { + for(let i = 2, s = Math.sqrt(num); i <= s; i++) { + if(num % i === 0) return false; + } + return num > 1; + } + + sieve(siveTo) { + let primes = [] + siveTo = Number(siveTo) + + for (var i = 1; i < siveTo; i++) { + if (isPrime(i)) { + primes.push(i) + } + } + + if (isPrime(siveTo)) { + primes.push(siveTo) + } + + return primes } async asyncSleep(ms) {