replaced by can-namespace
- when looping on objects replaced by
can-reflect.eachKey
- when looping on lists/arrays replaced by
can-reflect.each
can-reflect.eachKey
has better performance
replaced by can-reflect.isPromise
if ! type "brew" > /dev/null; then | |
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"; | |
fi | |
brew tap phinze/homebrew-cask && brew install brew-cask; | |
brew cask install vagrant; | |
brew cask install virtualbox; |
Functional programming gets a bad wrap about being too hard for mere mortals to comprehend. This is nonsense. The concepts are actually quite simple to grasp.
The jargon is the hardest part. A lot of that vocabulary comes from a specialized field of mathematical study called category theory (with a liberal sprinkling of type theory and abstract algebra). This sounds a lot scarier than it is. You can do this!
All examples using ES6 syntax. wrap (foo) => bar
means:
function wrap (foo) {
You don't really need a framework or fancy cutting-edge JavaScript features to do two-way data binding. Let's start basic - first and foremost, you need a way to tell when data changes. Traditionally, this is done via an Observer pattern, but a full-blown implementation of that is a little clunky for nice, lightweight JavaScript. So, if native getters/setters are out, the only mechanism we have are accessors:
var n = 5;
function getN() { return n; }
function setN(newN) { n = newN; }
console.log(getN()); // 5
setN(10);
<?php | |
class EmailAddress | |
{ | |
/** | |
* Undocumented variable | |
* | |
* @var [type] | |
*/ | |
private $address; |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<title>object creation</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> | |
<script src="./suite.js"></script> | |
</head> | |
<body> | |
<h1>Open the console to view the results</h1> |
There are many tutorials and articles available online which explain functional programming. Examples show small functions, which are composed into others which again get composed. It is hard to imagine how it would all work, then come the analogies and then the math. While the math is necessary to understand it can be difficult to grasp initially. The analogies on the other hand, (at least for me) are not relatable. Some articles assume the reader knows the different terminologies of FP. Over all I felt it is not inviting to learn.
This introduction is for those who have had a tough time understanding those analogies, taken the plunge to functional programming but still have not been able to swim. This is yet another tutorial on functional programming
Functions are first class means they are just like anyone else, or rather they are not special, they behave the same as say primitives or strings or objects.
var address; | |
var setAddress = function(address) { | |
/** | |
* @todo add validation here | |
*/ | |
address = address; | |
}; | |
function EmailAddress(anAddress) { |
<?php | |
namespace Todolist\Infrastructure\Persistence\Yii\Respository; | |
use Todolist\Domain\Model\Todo\Todo; | |
use Todolist\Domain\Model\Todo\TodoRepository; | |
use Todolist\Infrastructure\Persistence\Yii\Record\TodoRecord; | |
class TodoActiveRepository implements TodoRepository | |
{ | |
public function forId(TodoId $id) |
function slugify(text) | |
{ | |
return text.toString().toLowerCase() | |
.replace(/\s+/g, '-') // Replace spaces with - | |
.replace(/[^\w\-]+/g, '') // Remove all non-word chars | |
.replace(/\-\-+/g, '-') // Replace multiple - with single - | |
.replace(/^-+/, '') // Trim - from start of text | |
.replace(/-+$/, ''); // Trim - from end of text | |
} |