The recreational javascript utilities.
- Fork from develop branch.
- Make a PR to develop branch.
Run the npm install command first, it will install in your local machine all the required modules.
npm install
npm run build.
Next, you need to install a web server to serve our app. We suggest to use simplehttpserver.
npm install simplehttpserver -g
simplehttpserver .
npm test
All test should be 100% passed.
const { uniq } = require('./rdash')
const result = uniq([1,1,2,2,3,4,5])
console.log(result)
Output:
1,2,3,4,5
const { contains } = require('./rdash')
const result = contains([1,2,3,4,5], 3)
console.log(result)
Output:
true
const { cumSum } = require('./rdash')
const result = cumSum([1,2,3,4,5])
console.log(result)
Output:
Array [ 1, 3, 6, 10, 15 ]
const { groupBySumAt } = require('./rdash')
var items = [
{key:'key1', value:10},
{key:'key2', value:20},
{key:'key3', value:30},
{key:'key1', value:40}
]
const result = groupBySumAt(items,'key','value')
console.log(result)
Output:
[{"key":"key1","value":50},{"key":"key2","value":20},{"key":"key3","value":30}]
const { sort } = require('./rdash')
const result = sort([10,8,2,1,7,5])
console.log(result)
Output:
1,2,5,7,8,10
const { uniq } = require('./rdash')
const result = uniq([1,1,2,2,3,4,5])
console.log(result)
Output:
1,2,3,4,5
const { duplicates } = require('./rdash')
const result = duplicates([1,8,2,1,7,5,2])
console.log(result)
Output:
[1,2]
const { factorial } = require('./rdash')
const result = factorial(3)
console.log(result)
Output:
6
const { isPrime } = require('./rdash')
const result = isPrime(3)
console.log(result)
Output:
true
const { avg } = require('./rdash')
const result = avg([5, 10, 15, 20, 25])
console.log(result)
Output:
15
const { isPalindrome } = require('./rdash')
console.log(isPalindrome('madam'))
Output:
true