This file contains hidden or 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
var GLOBALNAMESPACE = {}; | |
GLOBALNAMESPACE.moduleObject = (function ($) { | |
var _private = { | |
i: 5, | |
get: function() { | |
console.log('current value: ' + this.i); |
This file contains hidden or 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
// ES6: | |
Array(26).fill().map((_,i)=>String.fromCharCode(97+i)) | |
// Lodash/fp: | |
map(unary(String.fromCharCode),range(97,123)) |
This file contains hidden or 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
// Objective: take returned object from reviews service, filter data for only defined keys, and create new array | |
// Problem: filter isn't the right array function for this job. It returns the keys, instead of the values | |
// example: [["LastModificationTime","Title","Rating","ReviewText"],["LastModificationTime","Title","Rating","ReviewText"],["LastModificationTime","Title","Rating","ReviewText"],["LastModificationTime","Title","Rating","ReviewText"],["LastModificationTime","Title","Rating","ReviewText"]] | |
// map returns everything so if the key doesn't meet the criteria it returns undefined in the array | |
Reviews.getReview().then((returnData) => { | |
this.reviews = returnData.data.Results; | |
let anArray = []; |
This file contains hidden or 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
/** | |
* User authentication code not in its own module | |
*/ | |
var db = require('./db.js'); | |
app.on('/createUser', function(req, res) { | |
var user = req.username, | |
pwd = req.password, | |
email = req.email; |
This file contains hidden or 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
/*! axis.js v1.1.0 | (c) 2014 @toddmotto | https://github.com/toddmotto/axis */ | |
(function (root, factory) { | |
if (typeof define === 'function' && define.amd) { | |
define(factory); | |
} else if (typeof exports === 'object') { | |
module.exports = factory; | |
} else { | |
root.axis = factory(); | |
} | |
})(this, function () { |
This file contains hidden or 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
//Plain objects are not iterable in ES6—that would clash with iterability of data structures. Helper is easy to write. | |
function* objectEntries(obj) { | |
let keys = Reflect.ownKeys(obj); | |
for (let key of keys) { | |
yield [key, obj[key]]; | |
} | |
} |
This file contains hidden or 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
function getDrink(type) { | |
var drinks = { | |
'coke': function() { | |
return 'Coke'; | |
}, | |
'pepsi': function() { | |
return 'Pepsi'; | |
}, | |
'lemonade': function() { | |
return 'Lemonade'; |
This file contains hidden or 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
(function() { | |
'use strict'; | |
let withRectangle = (function() { | |
function area() { | |
console.log('area'); | |
return this.length * this.width; | |
} |
This file contains hidden or 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
(function() { | |
'use strict'; | |
var withCircle = { | |
label:'', | |
area:function() { | |
return Math.PI * this.radius * this.radius; | |
}, | |
grow: function() { |
This file contains hidden or 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
// withViewport.js | |
import React, { Component } from 'react'; | |
import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment'; | |
function withViewport(ComposedComponent) { | |
return class WithViewport extends Component { | |
constructor() { | |
super(); |