Skip to content

Instantly share code, notes, and snippets.

View jkruse14's full-sized avatar

justin.kruse jkruse14

  • Bobcat
  • Minnesota
View GitHub Profile
@jkruse14
jkruse14 / httpMethods.js
Last active September 11, 2017 13:51
Javascript HttpMethods Object
// source:
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods
const httpMethods = {
CONNECT: 'CCONNECT', // The CONNECT method establishes a tunnel to the server identified by the target resource
DELETE: 'DELETE', // The DELETE method deletes the specified resource
GET: 'GET', // The GET method requests a representation of the specified resource. Requests using GET should only retrieve data
HEAD: 'HEAD', // The HEAD method asks for a response identical to that of a GET request, but without the response body
OPTIONS: 'OPTIONS', // The OPTIONS method is used to describe the communication options for the target resource
PATCH: 'PATCH', // The PATCH method is used to apply partial modifications to a resource
@jkruse14
jkruse14 / flattenArray.js
Last active August 14, 2017 13:55
Flatten an array
//flattens an array of arbitrarily nested arrays without the use of Array.prototype.reduce
//i.e. [1,[2,[3,4]]] => [1,2,3,4]
//returns -1 if input is not an array
function flatten(arr) {
if(!Array.isArray(arr)) {
return -1;
}
let flat = [];
for(let i = 0; i < arr.length; i++) {