Skip to content

Commit

Permalink
refactor for es6
Browse files Browse the repository at this point in the history
  • Loading branch information
mdunisch committed Apr 10, 2017
1 parent 7de3a2c commit 0cdd731
Show file tree
Hide file tree
Showing 21 changed files with 59 additions and 111 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ lololodash
![alt tag](https://raw.github.com/mdunisch/lololodash/master/screen.png)

## Getting Started ##
1. First, install [nodejs](http://nodejs.org) version 0.10 or later.
1. First, install [nodejs](http://nodejs.org) version 4.0 or later.

2. The `nodejs` installation will also install `npm`, the [Node Package Manager](https://www.npmjs.org/).

Expand Down
7 changes: 2 additions & 5 deletions exercises/1_getting_started/exercise.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
'use strict';
const verify = require("../../lib/verify.js");

var verify = require("../../lib/verify.js");
var _ = require("lodash");

var run = {
const run = {
json: [
{
id: 22,
Expand Down
6 changes: 2 additions & 4 deletions exercises/1_getting_started/solution/solution.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict';
const _ = require("lodash");

var _ = require("lodash");

var filterwhere = function (item) {
const filterwhere = function (item) {
return _.filter(item, {active: true});
};

Expand Down
7 changes: 2 additions & 5 deletions exercises/2_sort_me/exercise.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
'use strict';
const verify = require("../../lib/verify.js");

var verify = require("../../lib/verify.js"),
_ = require("lodash");

var run = {
const run = {
json: [
{
article: 2323,
Expand Down
10 changes: 3 additions & 7 deletions exercises/2_sort_me/solution/solution.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
'use strict';
const _ = require("lodash");

var _ = require("lodash");

var sorting = function (collection) {
return _.sortBy(collection, function (item) {
return -item.quantity;
});
const sorting = function (collection) {
return _.sortBy(collection, item => -item.quantity);

/* Also possible:
return _.sortBy(collection,"quantity").reverse();
Expand Down
7 changes: 2 additions & 5 deletions exercises/3_in_every_case/exercise.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
'use strict';
const verify = require("../../lib/verify.js");

var verify = require("../../lib/verify.js"),
_ = require("lodash");

var run = {
const run = {
json: {
Hamburg: { population: 1.698 },
Strasbourg: { population: 0.272 },
Expand Down
9 changes: 5 additions & 4 deletions exercises/3_in_every_case/solution/solution.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
'use strict';
const _ = require("lodash");

var _ = require("lodash");

module.exports = function(collection) {
const inEveryCase = function(collection){

// add a size attribute to the collection based on the item's population
return _.forEach(collection, function(item) {
if (item.population > 1) {
Expand All @@ -14,3 +13,5 @@ module.exports = function(collection) {
}
});
};

module.exports = inEveryCase;
7 changes: 2 additions & 5 deletions exercises/4_everyone_is_min/exercise.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
'use strict';
const verify = require("../../lib/verify.js");

var verify = require("../../lib/verify.js"),
_ = require("lodash");

var run = {
const run = {
json: {
Hamburg: [14, 15, 16, 14, 18, 17, 20, 22, 21, 18, 19, 23],
Munich: [16, 17, 19, 20, 21, 23, 22, 21, 20, 19, 24, 23],
Expand Down
12 changes: 5 additions & 7 deletions exercises/4_everyone_is_min/solution/solution.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
'use strict';

var _ = require("lodash");
const _ = require("lodash");

var tempsort = function (item) {

var result = {
hot: [],
warm: []
};

function check_temp (item) {
return item > 19;
}

// If temp > 19
const check_temp = (item) => item > 19;

_.forEach(item, function (town, townname) {

Expand Down
7 changes: 2 additions & 5 deletions exercises/5_chain_mail/exercise.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
'use strict';
const verify = require("../../lib/verify.js");

var verify = require("../../lib/verify.js");
var _ = require("lodash");

var run = {
const run = {
json: [
'Test', 'Hello', 'World', 'Node', 'JavaScript'
],
Expand Down
12 changes: 3 additions & 9 deletions exercises/5_chain_mail/solution/solution.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
'use strict';

var _ = require("lodash");
const _ = require("lodash");

var wordsmodify = function (arr) {
return _.chain(arr)
.map(function (item) {
return item + 'Chained';
})
.map(function (item) {
return item.toUpperCase();
})
.map(item => item + 'Chained')
.map(item => item.toUpperCase())
.sortBy()
.value();
};
Expand Down
7 changes: 2 additions & 5 deletions exercises/6_count_the_comments/exercise.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
'use strict';
const verify = require("../../lib/verify.js");

var verify = require("../../lib/verify.js"),
_ = require("lodash");

var run = {
const run = {

json: [ { username: "tim", comment: "when you have new workshoppers?" },
{ username: "cat_lover", comment: "wtf? where are all the cats gone?" },
Expand Down
6 changes: 2 additions & 4 deletions exercises/6_count_the_comments/solution/solution.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict';
const _ = require("lodash");

var _ = require("lodash");

var commentcount = function (comments) {
const commentcount = function (comments) {

var counted = [];

Expand Down
7 changes: 2 additions & 5 deletions exercises/7_give_me_an_overview/exercise.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
'use strict';
const verify = require("../../lib/verify.js");

var verify = require("../../lib/verify.js"),
_ = require("lodash");

var run = {
const run = {

json: [
{
Expand Down
6 changes: 2 additions & 4 deletions exercises/7_give_me_an_overview/solution/solution.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict';
const _ = require("lodash");

var _ = require("lodash");

var overview = function (orders) {
const overview = function (orders) {

var overviewarray = [],
total = 0;
Expand Down
7 changes: 2 additions & 5 deletions exercises/8_analyze/exercise.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
'use strict';
const verify = require("../../lib/verify.js");

var verify = require("../../lib/verify.js"),
_ = require("lodash");

var run = {
const run = {
json: [
{
name: "mike",
Expand Down
12 changes: 5 additions & 7 deletions exercises/8_analyze/solution/solution.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
'use strict';
const _ = require("lodash");

var _ = require("lodash");
const analyze = function (item) {

var analyze = function (item) {

var average,
underperform,
overperform;
let average;
let underperform;
let overperform;

// Sort
item = _.sortBy(item, "income");
Expand Down
7 changes: 2 additions & 5 deletions exercises/9_start_templating/exercise.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
'use strict';
const verify = require("../../lib/verify.js");

var verify = require("../../lib/verify.js"),
_ = require("lodash");

var run = {
const run = {
json: {
name: "Tom",
login: [
Expand Down
8 changes: 3 additions & 5 deletions exercises/9_start_templating/solution/solution.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
'use strict';
const _ = require("lodash");

var _ = require("lodash");
const template = function (inputvar) {

var template = function (inputvar) {

var mytemplate = "Hello <%= name %> (logins: <%= login.length %>)";
let mytemplate = "Hello <%= name %> (logins: <%= login.length %>)";

return _.template(mytemplate)(inputvar);
};
Expand Down
21 changes: 7 additions & 14 deletions lololodash.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
#!/usr/bin/env node

'use strict';
const workshopper = require('workshopper');
const updateNotifier = require('update-notifier');
const packageJson = require('./package.json');

var workshopper = require('workshopper'),
path = require('path'),
updateNotifier = require('update-notifier'),
pkg = require('./package.json');

updateNotifier({pkg: pkg}).notify();

function fpath(f) {
return path.join(__dirname, f);
}
updateNotifier({pkg: packageJson}).notify();

workshopper({
name : 'lololodash',
appDir : __dirname,
languages : ['en', 'fr', 'ko']
name: 'lololodash',
appDir: __dirname,
languages: ['en', 'fr', 'ko']
});
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"type": "git",
"url": "https://github.com/mdunisch/lololodash.git"
},
"engines" : {
"node" : ">=4.0.0"
},
"bin": "lololodash.js",
"preferGlobal": true,
"keywords": [
Expand Down

0 comments on commit 0cdd731

Please sign in to comment.