-
Notifications
You must be signed in to change notification settings - Fork 0
#shy-lizard npm-modules #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: empty1
Are you sure you want to change the base?
Changes from all commits
5708dce
d2c2560
e6edb08
865a986
cd43827
fd48518
158701f
2aac683
f5aed5f
7c8ebab
b5c1ae2
f9a0c59
ef5d36a
4e60ac5
f426e4c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| node_modules/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| var express = require('express'); | ||
| var path = require('path'); | ||
| var favicon = require('serve-favicon'); | ||
| var logger = require('morgan'); | ||
| var cookieParser = require('cookie-parser'); | ||
| var bodyParser = require('body-parser'); | ||
|
|
||
| var index = require('./routes/index'); | ||
| var users = require('./routes/users'); | ||
|
|
||
| var app = express(); | ||
|
|
||
| // view engine setup | ||
| app.set('views', path.join(__dirname, 'views')); | ||
| app.set('view engine', 'pug'); | ||
|
|
||
| // uncomment after placing your favicon in /public | ||
| //app.use(favicon(path.join(__dirname, 'public', 'favicon.ico'))); | ||
| app.use(logger('dev')); | ||
| app.use(bodyParser.json()); | ||
| app.use(bodyParser.urlencoded({ extended: false })); | ||
| app.use(cookieParser()); | ||
| app.use(express.static(path.join(__dirname, 'public'))); | ||
|
|
||
| app.use('/', index); | ||
| app.use('/users', users); | ||
|
|
||
| // catch 404 and forward to error handler | ||
| app.use(function(req, res, next) { | ||
| var err = new Error('Not Found'); | ||
| err.status = 404; | ||
| next(err); | ||
| }); | ||
|
|
||
| // error handler | ||
| app.use(function(err, req, res, next) { | ||
| // set locals, only providing error in development | ||
| res.locals.message = err.message; | ||
| res.locals.error = req.app.get('env') === 'development' ? err : {}; | ||
|
|
||
| // render the error page | ||
| res.status(err.status || 500); | ||
| res.render('error'); | ||
| }); | ||
|
|
||
| module.exports = app; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| /** | ||
| * Module dependencies. | ||
| */ | ||
|
|
||
| var app = require('../app'); | ||
| var debug = require('debug')('npm-modules:server'); | ||
| var http = require('http'); | ||
|
|
||
| /** | ||
| * Get port from environment and store in Express. | ||
| */ | ||
|
|
||
| var port = normalizePort(process.env.PORT || '3000'); | ||
| app.set('port', port); | ||
|
|
||
| /** | ||
| * Create HTTP server. | ||
| */ | ||
|
|
||
| var server = http.createServer(app); | ||
|
|
||
| /** | ||
| * Listen on provided port, on all network interfaces. | ||
| */ | ||
|
|
||
| server.listen(port); | ||
| server.on('error', onError); | ||
| server.on('listening', onListening); | ||
|
|
||
| /** | ||
| * Normalize a port into a number, string, or false. | ||
| */ | ||
|
|
||
| function normalizePort(val) { | ||
| var port = parseInt(val, 10); | ||
|
|
||
| if (isNaN(port)) { | ||
| // named pipe | ||
| return val; | ||
| } | ||
|
|
||
| if (port >= 0) { | ||
| // port number | ||
| return port; | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| /** | ||
| * Event listener for HTTP server "error" event. | ||
| */ | ||
|
|
||
| function onError(error) { | ||
| if (error.syscall !== 'listen') { | ||
| throw error; | ||
| } | ||
|
|
||
| var bind = typeof port === 'string' | ||
| ? 'Pipe ' + port | ||
| : 'Port ' + port; | ||
|
|
||
| // handle specific listen errors with friendly messages | ||
| switch (error.code) { | ||
| case 'EACCES': | ||
| console.error(bind + ' requires elevated privileges'); | ||
| process.exit(1); | ||
| break; | ||
| case 'EADDRINUSE': | ||
| console.error(bind + ' is already in use'); | ||
| process.exit(1); | ||
| break; | ||
| default: | ||
| throw error; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Event listener for HTTP server "listening" event. | ||
| */ | ||
|
|
||
| function onListening() { | ||
| var addr = server.address(); | ||
| var bind = typeof addr === 'string' | ||
| ? 'pipe ' + addr | ||
| : 'port ' + addr.port; | ||
| debug('Listening on ' + bind); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| "name": "npm-modules", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "scripts": { | ||
| "start": "node ./bin/www", | ||
| "test": "mocha" | ||
| }, | ||
| "dependencies": { | ||
| "body-parser": "~1.16.0", | ||
| "chai": "^3.5.0", | ||
| "cookie-parser": "~1.4.3", | ||
| "debug": "~2.6.0", | ||
| "express": "~4.14.1", | ||
| "mocha": "^3.2.0", | ||
| "morgan": "~1.7.0", | ||
| "pug": "latest", | ||
| "serve-favicon": "~2.3.2" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <head> | ||
| <title> This is only a Test </title> | ||
| </head> | ||
| <body> | ||
| </body> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| body { | ||
| padding: 50px; | ||
| font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; | ||
| } | ||
|
|
||
| a { | ||
| color: #00B7FF; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| var express = require('express'); | ||
| var router = express.Router(); | ||
|
|
||
| /* GET home page. */ | ||
| router.get('/', function(req, res, next) { | ||
| res.render('index', { title: 'NPM Modules for JS' }); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is rendering index.html instead of index.pug? |
||
| }); | ||
|
|
||
| module.exports = router; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| var express = require('express'); | ||
| var router = express.Router(); | ||
|
|
||
| /* GET users listing. */ | ||
| router.get('/', function(req, res, next) { | ||
| res.send('respond with a resource'); | ||
| }); | ||
|
|
||
| module.exports = router; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module.exports = function (num1,num2){ | ||
| return (num1 + num2) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| module.exports =function ( str ) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a space after the equals sign |
||
| function upperCase(match) { | ||
| return match.toUpperCase() | ||
| } | ||
| return str.replace(/\b[a-z]/g, upperCase).replace(/\s/g, '') | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module.exports = function (num1){ | ||
| return Math.ceil(num1) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd try rewriting |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| module.exports = function (list, size=2) { | ||
|
|
||
| if (list.isArray){ | ||
| return [] | ||
| } | ||
| var newList = [] | ||
| for(var i = 0; i < list.length ; i+=size) { | ||
| var subArray = [] | ||
| for(var j = 0; j < size ; j++) { | ||
| if (list[i+j]) { | ||
| subArray.push(list[i+j]) | ||
| } | ||
|
|
||
| } | ||
| newList.push(subArray) | ||
| } | ||
|
|
||
| return newList | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| module.exports = function(num1 , num2){ | ||
| // 1.5){ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leave out comments in the final product |
||
| return (num1 / num2) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // module.exports = function (array) { | ||
| // for (i = 0; i < array.length; i++) { | ||
| // | ||
| // | ||
| // } | ||
| // return array.filter(/\s/g,'~') | ||
| // } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| module.exports = function min( inputArray ) { | ||
|
|
||
| return Math.min.apply(null, inputArray) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Try to rewrite |
||
|
|
||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module.exports = function (num1,num2){ | ||
| return (num1 * num2) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| // module.exports = function(myArray) { | ||
| // function(){ | ||
| // var result = myArray[Math.floor(Math.random() * myArray.length)] | ||
| // return result | ||
| // } | ||
| // } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| module.exports = function (str, n){ | ||
| var utilities = { | ||
| repeat: function(str, n) { | ||
| return (new Array(n + 1)).join(str); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module.exports = function (sentence, word1, word2){ | ||
| return sentence.replace(word1, word2) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module.exports = function reversearray( array ) { | ||
| return array.reverse() | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module.exports = function (num1,num2){ | ||
| return (num1 - num2) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module.exports = function uppercase( anyString ) { | ||
| return anyString.toUpperCase() | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| module.exports = function upperfirst( str ) { | ||
| function substr(match) { | ||
| return match.toUpperCase() | ||
| } | ||
| return str.replace(/\b[a-z]/g, substr) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| var {expect} = require("chai") | ||
| var add = require("../spec/add") | ||
|
|
||
| describe("add", function() { | ||
| it("should add two numbers", function(){ | ||
| expect(add( 1 , 2 )).to.eql(3) | ||
| }) | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| var {expect} = require("chai") | ||
| var camelcase = require('../spec/camelcase') | ||
| var str = "This Should Be Camelized" | ||
|
|
||
| describe("camelcase", function() { | ||
| it("should camelize any sentence", function() { | ||
| expect(camelcase(str)).to.equal("ThisShouldBeCamelized") | ||
| }) | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| var {expect} = require("chai") | ||
| var ceil = require('../spec/ceil') | ||
|
|
||
| describe("ceil", function() { | ||
| it("should compute number rounded up to precision", function() { | ||
| expect(ceil(3.2)).to.eql(4) | ||
| }) | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| var {expect} = require("chai") | ||
| var chunk = require("../spec/chunk") // change spec and also folder | ||
| // name from spec to source | ||
|
|
||
| describe("chunk", function() { | ||
| it("should split array into chunks according to selected size", function() { | ||
| expect(chunk([1 , 2, 3, 4, 5], 3)).to.eql([[1 , 2 , 3],[4 , 5]]) | ||
| }) | ||
| }) | ||
| // Nest a for loop create variable for new array | ||
| //iterate through the new array to handle chunk size |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| var {expect} = require("chai") | ||
| var divide = require('../spec/divide') | ||
|
|
||
| describe("divide", function() { | ||
| it("should divide num1 by num2", function() { | ||
| expect(divide( 1 , 2 )).to.eql(.5) | ||
| }) | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // var {expect} = require("chai") | ||
| // var join = require('../spec/join') | ||
| // var array = ['this' , 'should' , 'be' , 'easy'] | ||
| // | ||
| // describe("join", function() { | ||
| // it("should convert all elements into string with designated separator", function() { | ||
| // expect(join(array)).to.equal('this~should~be~easy') | ||
| // }) | ||
| // }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| var {expect} = require("chai") | ||
| var min = require('../spec/min') | ||
|
|
||
| describe("min", function() { | ||
| it("should display the lowest number in an array", function() { | ||
| expect(min([4, 1, 2, 3])).to.eql(1) | ||
| }) | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| var {expect} = require("chai") | ||
| var multiply = require("../spec/multiply") | ||
|
|
||
| describe("multiply", function() { | ||
| it("should multiply num1 by num2", function() { | ||
| expect(multiply( 3 , 2 )).to.eql(6) | ||
| }) | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // var {expect} = require("chai") | ||
| // var random = require('../spec/random') | ||
| // | ||
| // var myArray = ['this','is','hard'] | ||
| // | ||
| // describe("random", function() { | ||
| // it("should find a random element in an array", function() { | ||
| // expect(random(myArray)).to.equal(result) | ||
| // }) | ||
| // }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // var {expect} = require("chai") | ||
| // var repeat = require('../spec/repeat') | ||
| // | ||
| // var str = 'cash' | ||
| // var n = 5 | ||
| // | ||
| // | ||
| // | ||
| // describe("repeat", function() { | ||
| // it("should repeat the given string n times", function() { | ||
| // expect(repeat(str, n)).to.equal('cashcashcashcashcash') | ||
| // }) | ||
| // }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only page that comes up when I attempt to load the site