-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cli, update docs, added changelog, remove innecesary files
- Loading branch information
1 parent
b37538e
commit 19c6757
Showing
14 changed files
with
155 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.*.swp | ||
._* | ||
.DS_Store | ||
.git | ||
.hg | ||
.npmrc | ||
.lock-wscript | ||
.svn | ||
.wafpickle-* | ||
config.gypi | ||
CVS | ||
npm-debug.log | ||
/.idea/ | ||
/src/dev.js | ||
/src/grammar.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Sylver changelog | ||
|
||
## Version 1.0.2 # | ||
- [[]()] . | ||
- [[]()] CLI. | ||
|
||
## Version 1.0.1 # | ||
- [[de802a0](https://github.com/juliandavidmr/sylver/commit/b37538ebb08eaf251cc1b99038a2ca884be4c696)] | ||
Update readme. | ||
|
||
## Version 1.0.0 # | ||
|
||
- [[55aff29](https://github.com/juliandavidmr/sylver/commit/de802a02e6e97450ed8eb95043d134d07c4ef340)] | ||
Basic operations: `+`, `-`, `/`, `*`, `~`, `^`. | ||
- [[de802a0](https://github.com/juliandavidmr/sylver/commit/f99feae1470c2d8ee5608713744977244808d377)] | ||
Trigonometry functions were added: `cos`, `sin`, `tan`, `acos`, `asin`, `atan`, `atanh`, `acosh`, `asinh`, `abs`. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const readline = require('readline'); | ||
const sylver = require('../'); | ||
|
||
const rl = readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout | ||
}); | ||
|
||
module.exports = function () { | ||
rl.on('line', (input) => { | ||
switch (input.trim()) { | ||
case 'exit': | ||
console.log('Exiting the command line interface. Bye :*'); | ||
process.exit(1); | ||
break; | ||
default: | ||
try { | ||
console.log(sylver(input)); | ||
} catch (e) { | ||
console.log("Error: ", e); | ||
} | ||
break; | ||
} | ||
rl.prompt(); | ||
}).on('close', () => { | ||
console.log('Have a great day!'); | ||
process.exit(0); | ||
}); | ||
; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = ` | ||
Usage: sylver [expression] [flags] | ||
A lightweight math library for JavaScript | ||
Options: | ||
-h, --help output usage information | ||
-c, --cli access the command line interface (experimental) | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
var log = console.log; | ||
|
||
|
||
/** | ||
* Has a flag | ||
* @param {Array<string>} args | ||
* @param {string} flag | ||
* @returns {boolean} | ||
*/ | ||
function has(args, flag) { | ||
return (args.indexOf(flag) > -1); | ||
} | ||
|
||
/** | ||
* main cli | ||
* @param {Array} args | ||
*/ | ||
function main(args) { | ||
if (has(args, '-h') || has(args, '--help')) { | ||
log(require('./help')); | ||
} else if (has(args, '-c') || has(args, '--cli')) { | ||
require('./cli')(); | ||
} else { | ||
log('No argument is recognized. Enter sylver --help'); | ||
} | ||
} | ||
|
||
main(process.argv.slice(1)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,14 @@ | ||
var test = require('ava'); | ||
var sylver = require('../') | ||
|
||
test('2 is equal to 2', t => { | ||
t.is(sylver("2"), 2) | ||
}) | ||
|
||
test('3+2 is equal to 5', t => { | ||
t.is(sylver("3+2"), 5) | ||
}) | ||
|
||
test('(3*2)+6 is equal to 12', t => { | ||
t.is(sylver("(3*2)+6"), 12) | ||
}) | ||
|
||
test('Reverse symbol: ~16 is equal to -16', t => { | ||
t.is(sylver("~16"), -16) | ||
}) | ||
|
||
test('Reverse symbol 2: 3*~2 is equal to -6', t => { | ||
t.is(sylver("3*~2"), -6) | ||
}) | ||
|
||
test('The factorial of 7 is 5040', t => { | ||
t.is(sylver("7!"), 5040) | ||
}) | ||
|
||
test('The factorial of 13 is 6227020800', t => { | ||
t.is(sylver("13!"), 6227020800) | ||
}) | ||
var sylver = require('../'); | ||
|
||
test('Basic operations', t => { | ||
t.is(sylver("2"), 2); | ||
t.is(sylver("3+2"), 5); | ||
t.is(sylver("(3*2)+6"), 12); | ||
t.is(sylver("3*2+6"), 12); | ||
t.is(sylver("25+5"), 25); | ||
t.is(sylver("~16"), -16); | ||
t.is(sylver("3*~2"), -6); | ||
t.is(sylver("7!"), 5040); | ||
t.is(sylver("13!"), 6227020800); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
var test = require('ava'); | ||
var sylver = require('../') | ||
|
||
test('Constant PI', t => { | ||
test('Constants', t => { | ||
t.is(sylver("PI"), Math.PI) | ||
}) | ||
|
||
test('Constant E', t => { | ||
t.is(sylver("E"), Math.E) | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters