Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions packages/Unit Conversion/Unit_Conversion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

function celsius_to_farenheit(celsius)
{
var farenheit=(celsius*1.8)+32;
return farenheit;
}
function celsius_to_kelvin(celsius)
{
var kelvin=celsius+273.15;
return kelvin;
}
function farenheit_to_celsius(farenheit)
{
var celsius=(farenheit-32)/1.8;
return celsius;
}
function farenheit_to_kelvin(farenheit)
{
kelvin=farenheit_to_celsius(farenheit)+273.15;
return kelvin;
}
function kelvin_to_celsius(kelvin)
{
celsius=kelvin-273.15;
return celsius;
}
function kelvin_to_farenheit(kelvin)
{
farenheit=celsius_to_farenheit(kelvin_to_celsius(kelvin));
return farenheit;
}
console.log(kelvin_to_farenheit(556));
9 changes: 9 additions & 0 deletions packages/Unit Conversion/package-meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://storage.googleapis.com/jscratesmanager.appspot.com/schema/v/1/package-meta.json",
"name": "@jscrates/Unit_Conversion",
"description": "basic unit conversion for temperature",
"version": "0.0.1",
"author": { "name": "Team JSCrates", "url": "https://github.com/jscrates" },
"homepage": "https://github.com/jscrates/packages",
"license": "MIT"
}
26 changes: 26 additions & 0 deletions packages/binary/binary-search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

let binarySearch = function (arr, x, start, end) {

// Base Condition
if (start > end) return false;

// Find the middle index
let mid=Math.floor((start + end)/2);

// Compare mid with given key x
if (arr[mid]===x) return true;

// If element at mid is greater than x,
// search in the left half of mid
if(arr[mid] > x)
return binarySearch(arr, x, start, mid-1);
else

// If element at mid is smaller than x,
// search in the right half of mid
return binarySearch(arr, x, mid+1, end);
}

module.exports = binarySearch


10 changes: 10 additions & 0 deletions packages/binary/package-meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://storage.googleapis.com/jscratesmanager.appspot.com/schema/v/1/package-meta.json",
"name": "@jscrates/binary-search",
"description": "Contains the binary search algo",
"version": "0.0.1",
"author": { "name": "Team JSCrates", "url": "https://github.com/jscrates" },
"homepage": "https://github.com/jscrates/packages",
"license": "MIT"
}

18 changes: 18 additions & 0 deletions packages/binary/quick-sort.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function quicksort(array) {
if (array.length <= 1) {
return array;
}

var pivot = array[0];

var left = [];
var right = [];

for (var i = 1; i < array.length; i++) {
array[i] < pivot ? left.push(array[i]) : right.push(array[i]);
}

return quicksort(left).concat(pivot, quicksort(right));
};

module.exports = quicksort
17 changes: 17 additions & 0 deletions packages/factorial/factorial.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// import * from bodmas
module.exports = function factorial(num) {
if(num < 0){
console.log('Error! Negetive factorial does not exists.');
}
else if(num === 0){
return (`Factorial of ${num} is 1.`);
}
else{
let fact = 1;
for(i=0;i<=num;i++){
fact =mul(fact,i);
}
return (`The factorial of ${num} is ${fact}.`);
}

}
10 changes: 10 additions & 0 deletions packages/factorial/package-meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://storage.googleapis.com/jscratesmanager.appspot.com/schema/v/1/package-meta.json",
"name": "@jscrates/factorial",
"description": "Contains a set of common mathematical operations.",
"version": "0.0.1",
"author": { "name": "Team JSCrates", "url": "https://github.com/jscrates" },
"homepage": "https://github.com/jscrates/packages",
"license": "MIT"
}

118 changes: 118 additions & 0 deletions packages/formulas/formulas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@

//Phy
//Speed/Velocity
function spd(){
// let pi = 3.141592;
var s, d, t;
s = div(d,t);
return s;
}

//Acceleration
function acc(){
var a, s1, s2, t;
a = div(sub(s1,s2),t);
return a;
}

//Momentum
function momen(){
var p, m, v;
p = mul(m,v);
return p;
}

//Centripital Force
function centri(){
var fbasec, m, v, r;
fbasec = div(mul(m,sqr(v)),r);
return fbasec;
}

//Kinetic Energy
function kinetic(){
var K,m,v;
K = 0.5*mul(m,sqr(v));
return K;
}

//Gravitational Force
function gravif(){

let g = mul(6.673,div(10,pow(-11)));
var F, m1, m2, r;
F = mul(g,div(mul(m1,m2),sqr(r)));
return F;
}

//Potential Energy
function potential(){
let M = mul(3.986,pow(10,14));
var U, g, m, r;
U = div(mul(g,M,m),r);
return U;
}

//gravitational Acceleration
function gacc(){
let G = mul(6.673,div(10,pow(-11)));
let M = mul(3.986,pow(10,14));
let R = pow(6.38,pow(10,6));
var g, G, M, R;
g = div(mul(G,M),sqr(R));
return g;
}

//Surface Tension
function surten(){
var S, F, l;
S = div(F,l);
return S;
}

//Frequency
function freq(){
var lam, t;
lam = div(1,t);
return lam;
}

//Capacitance
function capacitance(){
var C, q, V;
C = div(q,V);
return C;
}

//Chem
//De-Broglie's
function debrog(){
let h = mul(6.626,pow(10,-34));
var lam, m, c;
lam = div(h,mul(m,c));
return lam;
}

//Atomic Structure
function atmstruct(){
let h = mul(6.626,pow(10,-34));
var E,v;
E = mul(h,v);
return E;
}

module.exports = {
spd,
acc,
momen,
centri,
kinetic,
gravif,
potential,
gacc,
surten,
freq,
capacitance,
debrog,
atmstruct
}
10 changes: 10 additions & 0 deletions packages/formulas/package-meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://storage.googleapis.com/jscratesmanager.appspot.com/schema/v/1/package-meta.json",
"name": "@jscrates/formulas",
"description": "Contains a set of common mathematical operations.",
"version": "0.0.1",
"author": { "name": "Team JSCrates", "url": "https://github.com/jscrates" },
"homepage": "https://github.com/jscrates/packages",
"license": "MIT"
}

9 changes: 9 additions & 0 deletions packages/piglatin/package-meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://storage.googleapis.com/jscratesmanager.appspot.com/schema/v/1/package-meta.json",
"name": "@jscrates/piglatin",
"description": "converts text into piglatin format",
"version": "0.0.1",
"author": { "name": "Team JSCrates", "url": "https://github.com/jscrates" },
"homepage": "https://github.com/jscrates/packages",
"license": "MIT"
}
16 changes: 16 additions & 0 deletions packages/piglatin/piglatin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function translatePigLatin(str) {
let vowels = ['a', 'e', 'i', 'o', 'u'];
let newStr = "";

if (vowels.indexOf(str[0]) > -1) {
newStr = str + "way";
return newStr;
} else {
let firstMatch = str.match(/[aeiou]/g) || 0;
let vowel = str.indexOf(firstMatch[0]);
newStr = str.substring(vowel) + str.substring(0, vowel) + "ay";
return newStr;
}
}
console.log(translatePigLatin("aniket"));
//
10 changes: 10 additions & 0 deletions packages/random-number/package-meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://storage.googleapis.com/jscratesmanager.appspot.com/schema/v/1/package-meta.json",
"name": "@jscrates/random-number",
"description": "Contains code for random numbers.",
"version": "0.0.1",
"author": { "name": "Team JSCrates", "url": "https://github.com/jscrates" },
"homepage": "https://github.com/jscrates/packages",
"license": "MIT"
}

4 changes: 4 additions & 0 deletions packages/random-number/random-numbers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = function getRandomInt(max) {
return Math.floor(Math.random() * max);
}